pgsql: Fix error code for null FOR PORTION OF target

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix error code for null FOR PORTION OF target
Date: 2026-08-21 12:15:47
Message-ID: E1wxO9y-00000001VtL-1IOF@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix error code for null FOR PORTION OF target

When the target expression of FOR PORTION OF (...) evaluated to NULL,
ExecInitModifyTable raised an error without an errcode, so clients got
the internal error code XX000 for a user-reachable condition.
Oversight in commit 8e72d914c52.

To fix, report ERRCODE_NULL_VALUE_NOT_ALLOWED, and reword the message
to "FOR PORTION OF target must not be null", matching similar executor
messages such as "frame starting offset must not be null".

Bug: #19630
Reported-by: Zheng Wang <hackerzheng666(at)gmail(dot)com>
Reported-by: Yanjie Zhao
Reported-by: Yiyang Liu
Author: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/19630-9f10ca28426295fa%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c16a1b4f2ce8e88ec40d1465c01e327ab8721524

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 5 +++--
src/test/regress/expected/for_portion_of.out | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-08-21 16:52:03 pgsql: Ensure TOAST storage parameters have unsettable defaults.
Previous Message Etsuro Fujita 2026-08-21 08:54:22 pgsql: Fix typos in comments.