From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE.
Date: Tue, 01 Jun 2021 15:13:38 +0000
Message-ID: <E1lo65K-0007HX-Cg@gemulon.postgresql.org> (raw)
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.
Branch
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/762fe98b1ba63101bbf1fe8fcd1e23532d2c4f41
Modified Files
--------------
src/backend/parser/analyze.c | 2 +-
src/backend/utils/adt/selfuncs.c | 3 ++-
src/test/regress/expected/errors.out | 5 +++++
src/test/regress/sql/errors.sql | 4 ++++
4 files changed, 12 insertions(+), 2 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE.
In-Reply-To: <E1lo65K-0007HX-Cg@gemulon.postgresql.org>
References: <E1lo65K-0007HX-Cg@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox