Re: Error in PLpgSQL with SELECT INTO and composite types - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Error in PLpgSQL with SELECT INTO and composite types
Date
Msg-id 18545.1236980531@sss.pgh.pa.us
Whole thread Raw
In response to Error in PLpgSQL with SELECT INTO and composite types  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-bugs
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
>    SELECT '("(1)")'::btype INTO bvar;  -- Should work, but errors

No, because it's expecting the SELECT to yield a separate column for
each column of the composite variable bvar.  Something like

SELECT ('("(1)")'::btype).* INTO bvar;

would be correct.  To make it work the way you're thinking would break
a lot of code that expects the existing semantics --- instead of

select expr1, expr2 into two_column_record_var from ...

people would have to write something like

select row(expr1, expr2) into two_column_record_var from ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Error in PLpgSQL with SELECT INTO and composite types
Next
From: "Roman Kononov"
Date:
Subject: BUG #4702: refusal to compute date_trunc('week', '0001-12-09 BC');