Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group