plpgsql: Apply the too_many_rows check to EXECUTE ... INTO

EXECUTE ... INTO without STRICT silently discarded all but the first
result row even when plpgsql.extra_warnings or plpgsql.extra_errors
included too_many_rows.  Although the documented check was not limited
to static SQL, dynamic SQL only checked for multiple rows when STRICT
was specified.

Honor the too_many_rows setting for dynamic SQL as well, reporting a
warning or error as configured.  STRICT continues to require exactly
one row regardless of these settings.

Also add a hint to errors reported when EXECUTE ... INTO STRICT returns
multiple rows.

Do not backpatch, since enabling this check can cause previously
successful statements to fail.

Author: Jeevan Chalke <[email protected]>
Reviewed-by: Pavel Stehule <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: 
https://postgr.es/m/CAM2+6=WikOK3t=ln+jhznbchro3uy0tzvpupygnz9youtwn...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5ffc82103773eea1ab5aa699edc301d4f03de4ce

Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c          | 22 ++++++++++++++++------
src/test/regress/expected/plpgsql.out | 20 ++++++++++++++++++++
src/test/regress/sql/plpgsql.sql      | 14 ++++++++++++++
3 files changed, 50 insertions(+), 6 deletions(-)

Reply via email to