]> 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)
commit94edb85d253e5ae066481e4e369ad9e35dea41b5
tree54424c6053dbfdf5b0cad3001028bbd4c0c613e9
parent23c2b76a8322233ce0b2c135c10ad52d48a4a22b
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