]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Check column list length in XMLTABLE/JSON_TABLE alias
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 18 May 2022 18:28:31 +0000 (20:28 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 18 May 2022 18:28:31 +0000 (20:28 +0200)
commitade17703def9c8820d1a47cd21f37b1eb5656f89
tree1d8ac970aa47002f889f3f7e9764a738df5d7e26
parent7e59b1219109be1b42d1f3937d09637327a56f5b
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@zju.edu.cn>
Discussion: https://postgr.es/m/17480-1c9d73565bb28e90@postgresql.org
src/backend/parser/parse_clause.c
src/backend/parser/parse_relation.c
src/test/regress/expected/int2.out
src/test/regress/expected/join.out
src/test/regress/expected/with.out
src/test/regress/expected/xml.out
src/test/regress/sql/int2.sql
src/test/regress/sql/join.sql
src/test/regress/sql/with.sql
src/test/regress/sql/xml.sql