Re: Error in PLpgSQL with SELECT INTO and composite types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Error in PLpgSQL with SELECT INTO and composite types
Date: 2009-03-13 21:42:11
Message-ID: 18545.1236980531@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-03-13 23:54:01 Re: BUG #4702: refusal to compute date_trunc('week', '0001-12-09 BC');
Previous Message Roman Kononov 2009-03-13 21:41:02 BUG #4702: refusal to compute date_trunc('week', '0001-12-09 BC');