From 0da54b9edd8a54daa664751a867c5573822694aa Mon Sep 17 00:00:00 2001 From: Jeevan Chalke Date: Tue, 3 Nov 2026 18:39:26 +0530 Subject: [PATCH v3 3/3] doc: Describe EXECUTE ... INTO with multiple commands in PL/pgSQL. If the command string of EXECUTE contains more than one SQL command, only the result of the last command is assigned to the INTO targets, and STRICT and the too_many_rows extra check apply to that result. This was not documented. --- doc/src/sgml/plpgsql.sgml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 561f6e50d63..4f93c7cf2a8 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1368,6 +1368,17 @@ EXECUTE command-string INT unless the command produces exactly one row. + + If the command string contains more than one SQL command, the results of + all but the last command are discarded, and only the result of the last + command is assigned to the INTO variable(s). + (If a rule replaces the last command with nothing, as + DO INSTEAD NOTHING does, the result of the preceding + command is used.) The STRICT option and the + too_many_rows + extra check apply to the result that is assigned. + + The command string can use parameter values, which are referenced in the command as $1, $2, etc. -- 2.43.0