Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fSG-000396-0A for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2014 23:37:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W4fSF-00033s-Bd for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2014 23:37:31 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fSE-00033l-6Z for pgsql-bugs@postgresql.org; Sat, 18 Jan 2014 23:37:30 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W4fS6-0001Kj-PD for pgsql-bugs@postgresql.org; Sat, 18 Jan 2014 23:37:29 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 091335F7A9; Sat, 18 Jan 2014 18:37:43 -0500 (EST) Date: Sat, 18 Jan 2014 18:37:43 -0500 From: Stephen Frost To: marko@joh.to Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #8870: PL/PgSQL, SELECT .. INTO and the number of result columns Message-ID: <20140118233743.GA31026@tamriel.snowman.net> References: <20140118232509.26700.59523@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2fHTh5uZTiUOsy+g" Content-Disposition: inline In-Reply-To: <20140118232509.26700.59523@wrigleys.postgresql.org> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.8.0-35-generic (x86_64) X-Uptime: 18:28:56 up 10 days, 20:42, 4 users, load average: 0.05, 0.03, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) 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 --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * marko@joh.to (marko@joh.to) wrote: > I looked more closely into a gripe from Stephen Frost, which lead me into > discovering this behaviour: Well, as I got mentioned here.. The specific gripe I was bitching about on IRC goes thusly: =3D*# do $$ declare f1 int; declare f2 int; declare f3 int; begin select 1, 2, 3 into f1, f2 f3; end $$ language plpgsql; DO The issue above being that when you have a long list of columns being selected into variables, it can be easy to forget a comma and then debugging can be very painful. > Which directly contradicts this statement in the docs > (http://www.postgresql.org/docs/9.3/static/plpgsql-statements.html#PLPGSQ= L-STATEMENTS-SQL-ONEROW): >=20 > "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 type= s, > or else a run-time error occurs." Agreed. > 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. Yeah, I don't entirely follow the logic in that commit. It's strongly discouraged to use 'SELECT * INTO', for pretty obvious reasons. We certainly have no sympathy for users using 'SELECT *' from other languages when the columns get rearranged underneath them (due to a DROP COLUMN or similar). Thanks, Stephen --2fHTh5uZTiUOsy+g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJS2xBHAAoJEO1sijiDR2RVw6UP/2leTKasztwIJr8hZ+mOaqoy IUkmnIIq/Be6wQGOgJ43/V0ViQdNcPaaphP14sTNn8VnnupOG9h+W8sJBV77Q66p LgfnbOk0I3ODsx5Uia+5ryQHgpG2auKXDSjg+eBvGnHBB7hFfseD/ftbUbnQ9nvZ H06VyCDtGkHN018aLnGOSOZMqPqjr01tSZr2qDNf8ByD1/l4syDFN7D8GlAHLV2+ sesxFFsaIIvF2dgFgpPieP0uo9+5krAG09NbkQ4BkDBnHJN0n01tc3oW8LYrmLpD A8iwZt/LWG5Zzj1iQxq7sb/hc+ei6wnOc2geOTyyoqpmSI19ShjuIj+MjdslySNG RXbSUs90iT62X6yiU9aT7PhOkFw0yDcFW1iH8grVVVjD8Gkp9txUVmDeK4ec1LQ1 a17FiLEELkFtMYExO2+/92J3x3ECNaUau+ti+knPMcttD5s5eihqxPwl/0XdE1/2 O1WxZqO4ZoZF6geJ3iyEsanmHu6/6RFTvzfU1O+ntLhQXlFYW/6V+i5si9JTRa50 F6Oi3OV12E5DRZ4cN12ACwzGjq533Xl/d1QkWNSlt0YoyJ6dKNJyrzHmbeon5zFa MbQFemXWoc574tuH9llpMVcX+3mIf0JSdKUtPkE5pKoQJBgVg7pefFhNwWhX31M6 ytypFrIvw/JK7cqV56ut =txqS -----END PGP SIGNATURE----- --2fHTh5uZTiUOsy+g--