aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2021-10-01 18:29:18 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2021-10-01 18:29:18 -0300
commitc6bc655ee2ef09449da7ff688a8be19a13db5c4a (patch)
tree71c8f035dd23a0f3f3f53421afc7af19287cf6ea /src/backend
parentd186d233dfde4afb9dff346e13c8adaf4deec6b3 (diff)
downloadpostgresql-c6bc655ee2ef09449da7ff688a8be19a13db5c4a.tar.gz
postgresql-c6bc655ee2ef09449da7ff688a8be19a13db5c4a.zip
Error out if SKIP LOCKED and WITH TIES are both specified
Both bugs #16676[1] and #17141[2] illustrate that the combination of SKIP LOCKED and FETCH FIRST WITH TIES break expectations when it comes to rows returned to other sessions accessing the same row. Since this situation is detectable from the syntax and hard to fix otherwise, forbid for now, with the potential to fix in the future. [1] https://postgr.es/m/16676-fd62c3c835880da6@postgresql.org [2] https://postgr.es/m/17141-913d78b9675aac8e@postgresql.org Backpatch-through: 13, where WITH TIES was introduced Author: David Christensen <david.christensen@crunchydata.com> Discussion: https://postgr.es/m/CAOxo6XLPccCKru3xPMaYDpa+AXyPeWFs+SskrrL+HKwDjJnLhg@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/matview.c3
-rw-r--r--src/backend/parser/gram.y15
2 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 512b00bc656..fbbf769a871 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -185,7 +185,8 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
if (concurrent && stmt->skipData)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("CONCURRENTLY and WITH NO DATA options cannot be used together")));
+ errmsg("%s and %s options cannot be used together",
+ "CONCURRENTLY", "WITH NO DATA")));
/*
* Check that everything is correct for a refresh. Problems at this point
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index e3068a374ee..08f1bf1031c 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -16816,6 +16816,21 @@ insertSelectOptions(SelectStmt *stmt,
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("WITH TIES cannot be specified without ORDER BY clause")));
+ if (limitClause->limitOption == LIMIT_OPTION_WITH_TIES && stmt->lockingClause)
+ {
+ ListCell *lc;
+
+ foreach(lc, stmt->lockingClause)
+ {
+ LockingClause *lock = lfirst_node(LockingClause, lc);
+
+ if (lock->waitPolicy == LockWaitSkip)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("%s and %s options cannot be used together",
+ "SKIP LOCKED", "WITH TIES")));
+ }
+ }
stmt->limitOption = limitClause->limitOption;
}
if (withClause)