Re: PL/PGSQL bug in handling composite types - Mailing list pgsql-hackers

From Tom Lane
Subject Re: PL/PGSQL bug in handling composite types
Date
Msg-id 22674.1335413878@sss.pgh.pa.us
Whole thread Raw
In response to PL/PGSQL bug in handling composite types  (Boszormenyi Zoltan <zb@cybertec.at>)
List pgsql-hackers
Boszormenyi Zoltan <zb@cybertec.at> writes:
> we have found a way to make pl/pgsql throw an error for
> a legitimate use case that works in plain SQL.

The fact that it doesn't work the way you thought doesn't make it a bug.

plpgsql expects an assignment "INTO row_variable" to be supplied from
one select column per field in the composite variable.  So instead of
executing 'select (max(id),min(d))::mytype from x1', try executing
'select max(id),min(d) from x1'.

If we were to change this, we would break a lot of existing plpgsql
code; or, if we tried to support both usages, we would create nasty
semantic ambiguities for single-column composites.  Possibly the
documentation in "39.5.3. Executing a Query with a Single-row Result"
could be improved though.  To my eyes, it does say that this is what
happens, but it doesn't really emphasize the point that the SELECT's
output has to be "exploded" not delivered as a single composite column.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: psql omits row count under "\x auto"
Next
From: Robert Haas
Date:
Subject: Re: Temporary tables under hot standby