summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/analyze.c2
-rw-r--r--src/backend/utils/adt/selfuncs.c3
-rw-r--r--src/test/regress/expected/errors.out5
-rw-r--r--src/test/regress/sql/errors.sql4
4 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 502b1036854..b903b89466c 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -2566,7 +2566,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),
/*------
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 5aa8308b057..72e9409b784 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -4746,7 +4746,8 @@ examine_simple_variable(PlannerInfo *root, Var *var,
* of learning something even with it.
*/
if (subquery->setOperations ||
- subquery->groupClause)
+ subquery->groupClause ||
+ subquery->groupingSets)
return;
/*
diff --git a/src/test/regress/expected/errors.out b/src/test/regress/expected/errors.out
index 210e5ff39cb..848f2c03de7 100644
--- a/src/test/regress/expected/errors.out
+++ b/src/test/regress/expected/errors.out
@@ -50,6 +50,11 @@ select distinct on (foobar) * from pg_database;
ERROR: column "foobar" does not exist
LINE 1: select distinct on (foobar) * from pg_database;
^
+-- grouping with FOR UPDATE
+select null from pg_database group by datname for update;
+ERROR: FOR UPDATE is not allowed with GROUP BY clause
+select null from pg_database group by grouping sets (()) for update;
+ERROR: FOR UPDATE is not allowed with GROUP BY clause
--
-- DELETE
-- missing relation name (this had better not wildcard!)
diff --git a/src/test/regress/sql/errors.sql b/src/test/regress/sql/errors.sql
index cd370b4781e..1b2c7d391af 100644
--- a/src/test/regress/sql/errors.sql
+++ b/src/test/regress/sql/errors.sql
@@ -37,6 +37,10 @@ select * from pg_database where pg_database.datname = nonesuch;
-- bad attribute name in select distinct on
select distinct on (foobar) * from pg_database;
+-- grouping with FOR UPDATE
+select null from pg_database group by datname for update;
+select null from pg_database group by grouping sets (()) for update;
+
--
-- DELETE