]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Jun 2021 15:12:56 +0000 (11:12 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Jun 2021 15:12:56 +0000 (11:12 -0400)
commite5b0fffa17f610f03f03952c8c4a247c39e61292
tree35a58c0c2e79e89ff1ac35e27994a90c5c89a2ab
parentd2505681211b4803cae916e9f4c2331943f851dc
Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE.

This case should be disallowed, just as FOR UPDATE with a plain
GROUP BY is disallowed; FOR UPDATE only makes sense when each row
of the query result can be identified with a single table row.
However, we missed teaching CheckSelectLocking() to check
groupingSets as well as groupClause, so that it would allow
degenerate grouping sets.  That resulted in a bad plan and
a null-pointer dereference in the executor.

Looking around for other instances of the same bug, the only one
I found was in examine_simple_variable().  That'd just lead to
silly estimates, but it should be fixed too.

Per private report from Yaoguang Chen.
Back-patch to all supported branches.
src/backend/parser/analyze.c
src/backend/utils/adt/selfuncs.c
src/test/regress/expected/errors.out
src/test/regress/sql/errors.sql