summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane2011-02-25 23:56:23 +0000
committerTom Lane2011-02-25 23:58:02 +0000
commit389af951552ff2209eae3e62fa147fef12329d4f (patch)
tree647af6827c57dc5bd902ec98db80269f950a57f0 /src/backend/utils
parent0056066d06067d2d7fc84b31937933b5724347d0 (diff)
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/utils')
-rw-r--r--src/backend/utils/adt/ruleutils.c2
-rw-r--r--src/backend/utils/cache/plancache.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index d9b359465a2..025edf08386 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -4138,7 +4138,7 @@ get_name_for_var_field(Var *var, int fieldno,
if (lc != NULL)
{
Query *ctequery = (Query *) cte->ctequery;
- TargetEntry *ste = get_tle_by_resno(ctequery->targetList,
+ TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte),
attnum);
if (ste == NULL || ste->resjunk)
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index dc911e00aca..949608001ea 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -922,6 +922,7 @@ PlanCacheComputeResultDesc(List *stmt_list)
switch (ChoosePortalStrategy(stmt_list))
{
case PORTAL_ONE_SELECT:
+ case PORTAL_ONE_MOD_WITH:
node = (Node *) linitial(stmt_list);
if (IsA(node, Query))
{