7
7
* Portions Copyright (c) 1994, Regents of the University of California
10
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.186.2.1 2009/09/02 17:52:33 tgl Exp $
10
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.186.2.2 2009/10/27 17:11:30 tgl Exp $
12
12
*-------------------------------------------------------------------------
1242
1242
markQueryForLocking(rte->subquery, (Node *) rte->subquery->jointree,
1243
1243
forUpdate, noWait);
1245
else if (rte->rtekind == RTE_CTE)
1248
* We allow FOR UPDATE/SHARE of a WITH query to be propagated into
1249
* the WITH, but it doesn't seem very sane to allow this for a
1250
* reference to an outer-level WITH (compare
1251
* transformLockingClause). Which simplifies life here.
1253
CommonTableExpr *cte = NULL;
1256
if (rte->ctelevelsup > 0 || rte->self_reference)
1258
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1259
errmsg("SELECT FOR UPDATE/SHARE cannot be applied to an outer-level WITH query")));
1260
foreach(lc, qry->cteList)
1262
cte = (CommonTableExpr *) lfirst(lc);
1263
if (strcmp(cte->ctename, rte->ctename) == 0)
1266
if (lc == NULL) /* shouldn't happen */
1267
elog(ERROR, "could not find CTE \"%s\"", rte->ctename);
1268
/* should be analyzed by now */
1269
Assert(IsA(cte->ctequery, Query));
1270
markQueryForLocking((Query *) cte->ctequery,
1271
(Node *) ((Query *) cte->ctequery)->jointree,
1245
/* other RTE types are unaffected by FOR UPDATE */
1275
1247
else if (IsA(jtnode, FromExpr))