pgsql: Fix Assert failure in XMLTABLE parser

From: Richard Guo <rguo(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix Assert failure in XMLTABLE parser
Date: 2025-05-15 08:28:40
Message-ID: E1uFTxI-001l26-1m@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix Assert failure in XMLTABLE parser

In an XMLTABLE expression, columns can be marked NOT NULL, and the
parser internally fabricates an option named "is_not_null" to
represent this. However, the parser also allows users to specify
arbitrary option names. This creates a conflict: a user can
explicitly use "is_not_null" as an option name and assign it a
non-Boolean value, which violates internal assumptions and triggers an
assertion failure.

To fix, this patch checks whether a user-supplied name collides with
the internally reserved option name and raises an error if so.
Additionally, the internal name is renamed to "__pg__is_not_null" to
further reduce the risk of collision with user-defined names.

Reported-by: Евгений Горбанев <gorbanyoves(at)basealt(dot)ru>
Author: Richard Guo <guofenglinux(at)gmail(dot)com>
Reviewed-by: Alvaro Herrera <alvherre(at)kurilemu(dot)de>
Discussion: https://postgr.es/m/6bac9886-65bf-4cec-96bd-e304159f28db@basealt.ru
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/666103090f1d18e26388aef1ee5840d86cb8604b

Modified Files
--------------
src/backend/parser/gram.y | 15 +++++++++++----
src/test/regress/expected/xml.out | 4 ++++
src/test/regress/expected/xml_1.out | 4 ++++
src/test/regress/expected/xml_2.out | 4 ++++
src/test/regress/sql/xml.sql | 2 ++
5 files changed, 25 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2025-05-16 03:11:00 Re: pgsql: With GB18030, prevent SIGSEGV from reading past end of allocatio
Previous Message Richard Guo 2025-05-15 08:24:30 pgsql: Fix Assert failure in XMLTABLE parser