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 | e5b0fffa17f610f03f03952c8c4a247c39e61292 (patch) | |
tree | 35a58c0c2e79e89ff1ac35e27994a90c5c89a2ab /src/backend/utils/adt/selfuncs.c | |
parent | d2505681211b4803cae916e9f4c2331943f851dc (diff) | |
download | postgresql-e5b0fffa17f610f03f03952c8c4a247c39e61292.tar.gz postgresql-e5b0fffa17f610f03f03952c8c4a247c39e61292.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/utils/adt/selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index e96bfce4dc3..c2aeb4b947e 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -5150,7 +5150,8 @@ examine_simple_variable(PlannerInfo *root, Var *var, * of learning something even with it. */ if (subquery->setOperations || - subquery->groupClause) + subquery->groupClause || + subquery->groupingSets) return; /* |