summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-10-10 01:43:50 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-10-10 01:43:50 +0000
commit8a5849b7ff24c637a1140c26fc171e45c9142005 (patch)
tree8f660c08709c999c3a4299436312390c53231b01 /src/backend/nodes
parentb865d2758255b767e30dc5f23c7c7d209e716f3b (diff)
downloadpostgresql-8a5849b7ff24c637a1140c26fc171e45c9142005.tar.gz
Split the processing of INSERT/UPDATE/DELETE operations out of execMain.c.
They are now handled by a new plan node type called ModifyTable, which is placed at the top of the plan tree. In itself this change doesn't do much, except perhaps make the handling of RETURNING lists and inherited UPDATEs a tad less klugy. But it is necessary preparation for the intended extension of allowing RETURNING queries inside WITH. Marko Tiikkaja
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/copyfuncs.c32
-rw-r--r--src/backend/nodes/outfuncs.c22
2 files changed, 47 insertions, 7 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 27c231701d..cee7cb8ded 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.442 2009/10/08 02:39:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.443 2009/10/10 01:43:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,6 +77,7 @@ _copyPlannedStmt(PlannedStmt *from)
PlannedStmt *newnode = makeNode(PlannedStmt);
COPY_SCALAR_FIELD(commandType);
+ COPY_SCALAR_FIELD(hasReturning);
COPY_SCALAR_FIELD(canSetTag);
COPY_NODE_FIELD(planTree);
COPY_NODE_FIELD(rtable);
@@ -85,7 +86,6 @@ _copyPlannedStmt(PlannedStmt *from)
COPY_NODE_FIELD(intoClause);
COPY_NODE_FIELD(subplans);
COPY_BITMAPSET_FIELD(rewindPlanIDs);
- COPY_NODE_FIELD(returningLists);
COPY_NODE_FIELD(rowMarks);
COPY_NODE_FIELD(relationOids);
COPY_NODE_FIELD(invalItems);
@@ -155,6 +155,30 @@ _copyResult(Result *from)
}
/*
+ * _copyModifyTable
+ */
+static ModifyTable *
+_copyModifyTable(ModifyTable *from)
+{
+ ModifyTable *newnode = makeNode(ModifyTable);
+
+ /*
+ * copy node superclass fields
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+ /*
+ * copy remainder of node
+ */
+ COPY_SCALAR_FIELD(operation);
+ COPY_NODE_FIELD(resultRelations);
+ COPY_NODE_FIELD(plans);
+ COPY_NODE_FIELD(returningLists);
+
+ return newnode;
+}
+
+/*
* _copyAppend
*/
static Append *
@@ -171,7 +195,6 @@ _copyAppend(Append *from)
* copy remainder of node
*/
COPY_NODE_FIELD(appendplans);
- COPY_SCALAR_FIELD(isTarget);
return newnode;
}
@@ -3482,6 +3505,9 @@ copyObject(void *from)
case T_Result:
retval = _copyResult(from);
break;
+ case T_ModifyTable:
+ retval = _copyModifyTable(from);
+ break;
case T_Append:
retval = _copyAppend(from);
break;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 79665ed12a..a776f9fe3e 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.366 2009/10/08 02:39:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.367 2009/10/10 01:43:49 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -242,6 +242,7 @@ _outPlannedStmt(StringInfo str, PlannedStmt *node)
WRITE_NODE_TYPE("PLANNEDSTMT");
WRITE_ENUM_FIELD(commandType, CmdType);
+ WRITE_BOOL_FIELD(hasReturning);
WRITE_BOOL_FIELD(canSetTag);
WRITE_NODE_FIELD(planTree);
WRITE_NODE_FIELD(rtable);
@@ -250,7 +251,6 @@ _outPlannedStmt(StringInfo str, PlannedStmt *node)
WRITE_NODE_FIELD(intoClause);
WRITE_NODE_FIELD(subplans);
WRITE_BITMAPSET_FIELD(rewindPlanIDs);
- WRITE_NODE_FIELD(returningLists);
WRITE_NODE_FIELD(rowMarks);
WRITE_NODE_FIELD(relationOids);
WRITE_NODE_FIELD(invalItems);
@@ -319,6 +319,19 @@ _outResult(StringInfo str, Result *node)
}
static void
+_outModifyTable(StringInfo str, ModifyTable *node)
+{
+ WRITE_NODE_TYPE("MODIFYTABLE");
+
+ _outPlanInfo(str, (Plan *) node);
+
+ WRITE_ENUM_FIELD(operation, CmdType);
+ WRITE_NODE_FIELD(resultRelations);
+ WRITE_NODE_FIELD(plans);
+ WRITE_NODE_FIELD(returningLists);
+}
+
+static void
_outAppend(StringInfo str, Append *node)
{
WRITE_NODE_TYPE("APPEND");
@@ -326,7 +339,6 @@ _outAppend(StringInfo str, Append *node)
_outPlanInfo(str, (Plan *) node);
WRITE_NODE_FIELD(appendplans);
- WRITE_BOOL_FIELD(isTarget);
}
static void
@@ -1501,7 +1513,6 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
WRITE_UINT_FIELD(query_level);
WRITE_NODE_FIELD(join_rel_list);
WRITE_NODE_FIELD(resultRelations);
- WRITE_NODE_FIELD(returningLists);
WRITE_NODE_FIELD(init_plans);
WRITE_NODE_FIELD(cte_plan_ids);
WRITE_NODE_FIELD(eq_classes);
@@ -2408,6 +2419,9 @@ _outNode(StringInfo str, void *obj)
case T_Result:
_outResult(str, obj);
break;
+ case T_ModifyTable:
+ _outModifyTable(str, obj);
+ break;
case T_Append:
_outAppend(str, obj);
break;