Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns
Date: 2014-01-22 02:48:08
Message-ID: 25096.1390358888@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Marko Tiikkaja <marko(at)joh(dot)to> writes:
> On 1/19/14, 1:50 AM, I wrote:
>> But making this check at run time doesn't seem too hard. How broken
>> does the attached look?

> A bit broken, now that I look at it in detail. In particular, I could
> see someone doing something like:

> CREATE TABLE lotsofcolumns(f1 int, f2 int, f3 int, ..);

> DECLARE
> f1 int;
> f2 int;
> BEGIN
> SELECT * INTO f1, f2 FROM lotsofcolumns;

> I can't say I think this is a good idea, but not sure breaking this case
> is worth it either.

Um, I thought the whole point was to complain about that. If this isn't a
mistake, how can you consistently maintain the other one is?

> In bug #8893 there was some discussion which I interpreted to mean that
> we could improve this a bit by checking the number of returned columns
> during compile time if there's no * in the target list. Attached is a
> crude patch attempting to do that, which appears to be working. Any
> thoughts?

Ick. I thought you wanted to do this at first execution, anyway, not in
pl_gram.y.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2014-01-22 07:46:29 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Previous Message Marko Tiikkaja 2014-01-22 01:19:34 Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns