Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fnq-0003u0-O6 for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2014 23:59:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W4fnp-0006WS-Hx for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2014 23:59:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fno-0006WF-LL for pgsql-bugs@postgresql.org; Sat, 18 Jan 2014 23:59:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fng-0007o0-GJ for pgsql-bugs@postgresql.org; Sat, 18 Jan 2014 23:59:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s0INxcJw025795; Sat, 18 Jan 2014 18:59:38 -0500 From: Tom Lane To: marko@joh.to cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns In-reply-to: <20140118232509.26700.59523@wrigleys.postgresql.org> References: <20140118232509.26700.59523@wrigleys.postgresql.org> Comments: In-reply-to marko@joh.to message dated "Sat, 18 Jan 2014 23:25:09 +0000" Date: Sat, 18 Jan 2014 18:59:38 -0500 Message-ID: <25794.1390089578@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org marko@joh.to writes: > =# 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) > This seems to have been broken by commit > 8bb3c8fe5413103c30ba8d1bcb3a1f8e46bddf3d. Did you really test against a pre-2001 plpgsql? The comments in that commit are correct as far as they go: we *must* be willing to accept tuples with more or fewer attributes than the row has fields, or unpleasant things will happen with code that is correct on its face, if the table it's fetching from has inheritance children and/or has been subject to ALTER TABLE. ISTM what you're really asking for is a compile time (not run-time) check that the number of INTO targets matches the nominal number of output columns of the query. Not sure how difficult that is, but it'd be more likely to be successful than messing with the run-time behavior in exec_move_row. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs