Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns
Date
Msg-id CAFj8pRDcuvTDNi7PyFfi8MRN7ROwNYoDMKBv2tk6=ZwLe1HSNA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns  (Marko Tiikkaja <marko@joh.to>)
List pgsql-bugs
2014/1/22 Marko Tiikkaja <marko@joh.to>

> On 1/22/14, 3:48 AM, Tom Lane wrote:
>
>  Marko Tiikkaja <marko@joh.to> writes:
>>
>>>     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?
>>
>
> I'm sure you can see a difference between explicitly listing the wrong
> number of columns and using * to ignore trailing columns.  That said, this
> *should* be an error according to the documentation, so it's probably not
> the end of the world if we break it.
>
>
>  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.
>>
>
> Catching these errors at compile time would be ideal.  If we also want to
> catch the * cases we could also check the result structure before the first
> execution.
>

It is exactly it what is done by plpgsql_check_function - without
introduction new dependencies and without possible performance impacts.

Regards

Pavel




>
>
> Regards,
> Marko Tiikkaja
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

pgsql-bugs by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns
Next
From: rahuljadhav119@gmail.com
Date:
Subject: BUG #8929: Drupal Website not working on Postgres 9.2