if (stmt->lockingClause)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("SELECT FOR UPDATE/SHARE cannot be applied to VALUES")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s cannot be applied to VALUES",
+ LCS_asString(((LockingClause *)
+ linitial(stmt->lockingClause))->strength))));
qry->rtable = pstate->p_rtable;
qry->jointree = makeFromExpr(pstate->p_joinlist, NULL);
if (lockingClause)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
+ LCS_asString(((LockingClause *)
+ linitial(lockingClause))->strength))));
/* Process the WITH clause independently of all else */
if (withClause)
if (stmt->lockingClause)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
+ LCS_asString(((LockingClause *)
+ linitial(stmt->lockingClause))->strength))));
/*
* If an internal node of a set-op tree has ORDER BY, LIMIT, FOR UPDATE,
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_HOLD))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("DECLARE CURSOR WITH HOLD ... FOR UPDATE/SHARE is not supported"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("DECLARE CURSOR WITH HOLD ... %s is not supported",
+ LCS_asString(((RowMarkClause *)
+ linitial(result->rowMarks))->strength)),
errdetail("Holdable cursors must be READ ONLY.")));
/* FOR UPDATE and SCROLL are not compatible */
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_SCROLL))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("DECLARE SCROLL CURSOR ... FOR UPDATE/SHARE is not supported"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("DECLARE SCROLL CURSOR ... %s is not supported",
+ LCS_asString(((RowMarkClause *)
+ linitial(result->rowMarks))->strength)),
errdetail("Scrollable cursors must be READ ONLY.")));
/* FOR UPDATE and INSENSITIVE are not compatible */
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_INSENSITIVE))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("DECLARE INSENSITIVE CURSOR ... FOR UPDATE/SHARE is not supported"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("DECLARE INSENSITIVE CURSOR ... %s is not supported",
+ LCS_asString(((RowMarkClause *)
+ linitial(result->rowMarks))->strength)),
errdetail("Insensitive cursors must be READ ONLY.")));
/* We won't need the raw querytree any more */
}
+char *
+LCS_asString(LockClauseStrength strength)
+{
+ switch (strength)
+ {
+ case LCS_FORKEYSHARE:
+ return "FOR KEY SHARE";
+ case LCS_FORSHARE:
+ return "FOR SHARE";
+ case LCS_FORNOKEYUPDATE:
+ return "FOR NO KEY UPDATE";
+ case LCS_FORUPDATE:
+ return "FOR UPDATE";
+ }
+ return "FOR some"; /* shouldn't happen */
+}
+
/*
* Check for features that are not supported with FOR [KEY] UPDATE/SHARE.
*
if (qry->setOperations)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with UNION/INTERSECT/EXCEPT")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (qry->distinctClause != NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with DISTINCT clause")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with DISTINCT clause",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (qry->groupClause != NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with GROUP BY clause")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with GROUP BY clause",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (qry->havingQual != NULL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with HAVING clause")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with HAVING clause",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (qry->hasAggs)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with aggregate functions")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with aggregate functions",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (qry->hasWindowFuncs)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with window functions")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with window functions",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
if (expression_returns_set((Node *) qry->targetList))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks are not allowed with set-returning functions in the target list")));
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s is not allowed with set-returning functions in the target list",
+ LCS_asString(((RowMarkClause *)
+ linitial(qry->rowMarks))->strength))));
}
/*
if (thisrel->catalogname || thisrel->schemaname)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("row-level locks must specify unqualified relation names"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s must specify unqualified relation names",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
i = 0;
case RTE_JOIN:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks cannot be applied to a join"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s cannot be applied to a join",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
break;
case RTE_FUNCTION:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks cannot be applied to a function"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s cannot be applied to a function",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
break;
case RTE_VALUES:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks cannot be applied to VALUES"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s cannot be applied to VALUES",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
break;
case RTE_CTE:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("row-level locks cannot be applied to a WITH query"),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("%s cannot be applied to a WITH query",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
break;
default:
if (rt == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
- errmsg("relation \"%s\" in row-level lock clause not found in FROM clause",
- thisrel->relname),
+ /*------
+ translator: %s is a SQL row locking clause such as FOR UPDATE */
+ errmsg("relation \"%s\" in %s clause not found in FROM clause",
+ thisrel->relname,
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
}
}