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

From marko@joh.to
Subject BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns
Date
Msg-id 20140118232509.26700.59523@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns  (Stephen Frost <sfrost@snowman.net>)
Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8870
Logged by:          Marko Tiikkaja
Email address:      marko@joh.to
PostgreSQL version: 9.3.2
Operating system:   OS X
Description:

I looked more closely into a gripe from Stephen Frost, which lead me into
discovering this behaviour:

=# create function f() returns void as
-# $$declare
$#   f1 int;
$# begin
$# select 1, 2 into f1;
$# end
$# $$ language plpgsql;
CREATE FUNCTION
=# select f();
 f
---

(1 row)

Which directly contradicts this statement in the docs
(http://www.postgresql.org/docs/9.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW):

"If a row or a variable list is used as target, the query's result columns
must exactly match the structure of the target as to number and data types,
or else a run-time error occurs."

This seems to have been broken by commit
8bb3c8fe5413103c30ba8d1bcb3a1f8e46bddf3d.  I strongly believe the
documentation is right in this case, and the behaviour ought to change.

pgsql-bugs by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: pgbench show progress report extremely frequently if "--progress" >= 2148 caused by integer overflow
Next
From: Stephen Frost
Date:
Subject: Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns