From 0da54b9edd8a54daa664751a867c5573822694aa Mon Sep 17 00:00:00 2001
From: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
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 <replaceable class="command">command-string</replaceable> <optional> INT
      unless the command produces exactly one row.
     </para>
 
+    <para>
+     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 <literal>INTO</literal> variable(s).
+     (If a rule replaces the last command with nothing, as
+     <literal>DO INSTEAD NOTHING</literal> does, the result of the preceding
+     command is used.)  The <literal>STRICT</literal> option and the
+     <link linkend="plpgsql-extra-checks-too-many-rows"><varname>too_many_rows</varname></link>
+     extra check apply to the result that is assigned.
+    </para>
+
     <para>
      The command string can use parameter values, which are referenced
      in the command as <literal>$1</literal>, <literal>$2</literal>, etc.
-- 
2.43.0

