Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cef5U-0008Ng-Vk for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Feb 2017 09:44:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cef5U-0004KW-Ft for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Feb 2017 09:44:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cef4p-0003VA-9Z for pgsql-bugs@postgresql.org; Fri, 17 Feb 2017 09:43:43 +0000 Received: from smtp-out.abv.bg ([194.153.145.80]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cef4h-0007DM-GT for pgsql-bugs@postgresql.org; Fri, 17 Feb 2017 09:43:42 +0000 Received: from nm33.abv.bg (nm33.ni.bg [192.168.151.4]) by smtp-out.abv.bg (Postfix) with ESMTP id 20F3426E90; Fri, 17 Feb 2017 11:43:33 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=abv.bg; s=smtp-out; t=1487324613; bh=sR7malaK73cG3DuTpIt/fA4fuh1n+zATgyBH+dLEurc=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=A7gR177sT9HksJ7qAEEiKPhC8mWKOyVHOqNdaq/kwiCRf4xWpxRr/JJbzXWEj9cay l6HUYI42amhqfjU0KhOAwOyQ0vCOsIiQ9hKLXwy00JJppvef4F1PbNawhYIjRiIQBE FkdrDPR/KFXFEz+mMHSSbrYxy93XPk4Kf6RZSlvM= Received: from nm33.abv.bg (localhost [127.0.0.1]) by nm33.abv.bg (Postfix) with ESMTP id 0AFC0120BCA; Fri, 17 Feb 2017 11:43:33 +0200 (EET) Date: Fri, 17 Feb 2017 11:43:33 +0200 (EET) From: Stefan Stefanov To: Pavel Stehule Cc: "\"\"\"pgsql-bugs@postgresql.org\"\"\"" Message-ID: <698980665.694760.1487324613043.JavaMail.apache@nm33.abv.bg> In-Reply-To: References: <20170217075821.6101.49074@wrigleys.postgresql.org> Subject: Re: BUG #14549: pl/pgsql parser MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_694759_87799353.1487324613016" X-Mailer: AbvMail 3.0 X-Originating-IP: 78.83.236.238 X-Pg-Spam-Score: -1.7 (-) 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 ------=_Part_694759_87799353.1487324613016 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Thanks Pavel. Different columns and data types tolerance is ok, however what about wrong and meaningless syntax? Best, Stefan >-------- Оригинално писмо -------- >От: Pavel Stehule pavel.stehule@gmail.com >Относно: Re: [BUGS] BUG #14549: pl/pgsql parser >До: stefanov.sm@abv.bg >Изпратено на: 17.02.2017 11:19 Hi 2017-02-17 8:58 GMT+01:00 stefanov.sm@abv.bg > : The following bug has been logged on the website: Bug reference: 14549 Logged by: Stefan Stefanov Email address: stefanov.sm@abv.bg PostgreSQL version: 9.5.3 Operating system: Red Hat, 64 bit Description: Hi all, I found (the hard way) that in pl/pgsql SELECT INTO statement a syntax error may remain unnoticed. This simple example works as expected and produces '1, 2, 3' notice. DO language plpgsql $$ DECLARE vara integer; varb integer; varc integer; BEGIN SELECT 1, 2, 3 INTO vara, varb, varc; RAISE NOTICE '% % %', vara, varb, varc; END; $$; However if you omit a comma (or even replace the comma with AS) between varb and varc in the INTO list then no syntax error is produced and the resulting notice is '1 2 '. DO language plpgsql $$ DECLARE vara integer; varb integer; varc integer; BEGIN SELECT 1, 2, 3 INTO vara, varb AS varc; RAISE NOTICE '% % %', vara, varb, varc; END; $$; A few more clearly erratic combinations of SELECT expressions and the INTO list also 'work' and issue misleading results. Same in functions. For me it produced a bug that was difficult to see and track. Best, Stefan It is not a bug - plpgsql is designed be tolerant to different columns and data types in left and right part of assignment. You can use some tools for easy detecting these issues: 1. plpgsql_check https://github.com/okbob/plpgsql_check - it is available in community repository 2. prepared extra_checks https://commitfest.postgresql.org/13/962/ Regards Pavel -- Sent via pgsql-bugs mailing list ( pgsql-bugs@postgresql.org ) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ------=_Part_694759_87799353.1487324613016 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thanks Pavel.
Different columns and data types tolerance is ok, however = what about wrong and meaningless syntax?
Best,
Stefan


>-------- =D0=9E=D1=80=D0=B8=D0=B3=D0=B8=D0=BD=D0=B0=D0=BB=D0=BD=D0=BE = =D0=BF=D0=B8=D1=81=D0=BC=D0=BE --------
>=D0=9E=D1=82: Pavel Stehule pavel.stehule@gmail.com
>=D0=9E=D1=82=D0=BD=D0=BE=D1=81=D0=BD=D0=BE: Re: [BUGS] BUG #14549:= pl/pgsql parser
>=D0=94=D0=BE: stefanov.sm@abv.bg
>=D0=98=D0=B7=D0=BF=D1=80=D0=B0=D1=82=D0=B5=D0=BD=D0=BE =D0=BD=D0= =B0: 17.02.2017 11:19

=20 =20
Hi

2017-02-17 8:58 GMT+01:00=20 < The following bug has been logged on the website:
=20
Bug reference:      14549
Logged by:          Stefan Stefanov
Email address:     =20
stefano= v.sm@abv.bg
PostgreSQL version: 9.5.3
Operating system:   Red Hat, 64 bit
Description:
=20
Hi all,
I found (the hard way) that in pl/pgsql SELECT INTO statement a= syntax error
may remain unnoticed.
This simple example works as expected and produces '1, 2, 3' no= tice.
=20
DO language plpgsql
$$
DECLARE
 vara integer;
 varb integer;
 varc integer;
BEGIN
 SELECT 1, 2, 3 INTO vara, varb, varc;
 RAISE NOTICE '% % %', vara, varb, varc;
END;
$$;
=20
However if you omit a comma (or even replace the comma with AS)= between varb
and varc in the INTO list then no syntax error is produced and = the resulting
notice is '1 2 <NULL>'.
=20
DO language plpgsql
$$
DECLARE
 vara integer;
 varb integer;
 varc integer;
BEGIN
 SELECT 1, 2, 3 INTO vara, varb AS varc;
 RAISE NOTICE '% % %', vara, varb, varc;
END;
$$;
=20
A few more clearly erratic combinations of SELECT expressions a= nd the INTO
list also 'work' and issue misleading results.
Same in functions. For me it produced a bug that was difficult = to see and
track.
=20
Best,
Stefan
=20

It is not a bug - plpgsql is designed be tolerant to different colum= ns and data types in left and right part of assignment.

You can use some tools for easy detecting these issues:

1. plpgsql_check=20 https://github.com/okbob/plpgsql_check - it is available in community = repository
2. prepared extra_checks=20 https://commitfest.postgresql.org/13/962/

Regards

Pavel

 


--
Sent via = pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to you= r subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
=

=20 =20 ------=_Part_694759_87799353.1487324613016--