diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-01 11:12:56 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-01 11:12:56 -0400 |
commit | 1103033aedc10295eb689a4b7158f21ef4c14a11 (patch) | |
tree | 0d8f24b4d84edc7531a7dd1a44e16a9c56ba07fc /src/backend/parser/analyze.c | |
parent | eb89cb43a0d0e401e71b8e2345b5f5bc8b2755a1 (diff) | |
download | postgresql-1103033aedc10295eb689a4b7158f21ef4c14a11.tar.gz postgresql-1103033aedc10295eb689a4b7158f21ef4c14a11.zip |
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.
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r-- | src/backend/parser/analyze.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 201b88d1adb..9cede29d6a8 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -3019,7 +3019,7 @@ CheckSelectLocking(Query *qry, LockClauseStrength strength) translator: %s is a SQL row locking clause such as FOR UPDATE */ errmsg("%s is not allowed with DISTINCT clause", LCS_asString(strength)))); - if (qry->groupClause != NIL) + if (qry->groupClause != NIL || qry->groupingSets != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), /*------ |