pgsql: Check column list length in XMLTABLE/JSON_TABLE alias

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check column list length in XMLTABLE/JSON_TABLE alias
Date: 2022-05-18 18:44:52
Message-ID: E1nrOfE-001MRo-2P@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check column list length in XMLTABLE/JSON_TABLE alias

We weren't checking the length of the column list in the alias clause of
an XMLTABLE or JSON_TABLE function (a "tablefunc" RTE), and it was
possible to make the server crash by passing an overly long one. Fix it
by throwing an error in that case, like the other places that deal with
alias lists.

In passing, modify the equivalent test used for join RTEs to look like
the other ones, which was different for no apparent reason.

This bug came in when XMLTABLE was born in version 10; backpatch to all
stable versions.

Reported-by: Wang Ke <krking(at)zju(dot)edu(dot)cn>
Discussion: https://postgr.es/m/17480-1c9d73565bb28e90@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/16cb7db34f3c0a3b6e2973f6efbc6f2afa58c66a

Modified Files
--------------
src/backend/parser/parse_clause.c | 15 ---------------
src/backend/parser/parse_relation.c | 12 ++++++++++++
src/test/regress/expected/int2.out | 4 ++++
src/test/regress/expected/join.out | 3 +++
src/test/regress/expected/with.out | 5 +++++
src/test/regress/expected/xml.out | 3 +++
src/test/regress/sql/int2.sql | 4 ++++
src/test/regress/sql/join.sql | 3 +++
src/test/regress/sql/with.sql | 3 +++
src/test/regress/sql/xml.sql | 3 +++
10 files changed, 40 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2022-05-18 19:21:48 pgsql: Fix EXPLAIN MERGE output when no tuples are processed
Previous Message Alvaro Herrera 2022-05-18 16:34:56 pgsql: Make EXPLAIN MERGE output format more compact