diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-02-25 18:56:23 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-02-25 18:58:02 -0500 |
commit | 389af951552ff2209eae3e62fa147fef12329d4f (patch) | |
tree | 647af6827c57dc5bd902ec98db80269f950a57f0 /src/backend/parser/parse_target.c | |
parent | 0056066d06067d2d7fc84b31937933b5724347d0 (diff) | |
download | postgresql-389af951552ff2209eae3e62fa147fef12329d4f.tar.gz postgresql-389af951552ff2209eae3e62fa147fef12329d4f.zip |
Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH.
This patch implements data-modifying WITH queries according to the
semantics that the updates all happen with the same command counter value,
and in an unspecified order. Therefore one WITH clause can't see the
effects of another, nor can the outer query see the effects other than
through the RETURNING values. And attempts to do conflicting updates will
have unpredictable results. We'll need to document all that.
This commit just fixes the code; documentation updates are waiting on
author.
Marko Tiikkaja and Hitoshi Harada
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r-- | src/backend/parser/parse_target.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index e9ace37e2d8..c0eaea71a66 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -324,10 +324,7 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle, CommonTableExpr *cte = GetCTEForRTE(pstate, rte, netlevelsup); TargetEntry *ste; - /* should be analyzed by now */ - Assert(IsA(cte->ctequery, Query)); - ste = get_tle_by_resno(((Query *) cte->ctequery)->targetList, - attnum); + ste = get_tle_by_resno(GetCTETargetList(cte), attnum); if (ste == NULL || ste->resjunk) elog(ERROR, "subquery %s does not have attribute %d", rte->eref->aliasname, attnum); @@ -1415,10 +1412,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) CommonTableExpr *cte = GetCTEForRTE(pstate, rte, netlevelsup); TargetEntry *ste; - /* should be analyzed by now */ - Assert(IsA(cte->ctequery, Query)); - ste = get_tle_by_resno(((Query *) cte->ctequery)->targetList, - attnum); + ste = get_tle_by_resno(GetCTETargetList(cte), attnum); if (ste == NULL || ste->resjunk) elog(ERROR, "subquery %s does not have attribute %d", rte->eref->aliasname, attnum); |