]> granicus.if.org Git - postgresql/blobdiff - src/backend/nodes/outfuncs.c
Support UPDATE/DELETE WHERE CURRENT OF cursor_name, per SQL standard.
[postgresql] / src / backend / nodes / outfuncs.c
index 0600f63b5567616427dab633f0f4c3d5793d5623..869905f0cc548e01b42ecf74f314bbc850b43597 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.299 2007/02/19 07:03:27 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.310 2007/06/11 01:16:22 tgl Exp $
  *
  * NOTES
  *       Every node type that can appear in stored rules' parsetrees *must*
@@ -234,6 +234,25 @@ _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
  *     Stuff from plannodes.h
  */
 
+static void
+_outPlannedStmt(StringInfo str, PlannedStmt *node)
+{
+       WRITE_NODE_TYPE("PLANNEDSTMT");
+
+       WRITE_ENUM_FIELD(commandType, CmdType);
+       WRITE_BOOL_FIELD(canSetTag);
+       WRITE_NODE_FIELD(planTree);
+       WRITE_NODE_FIELD(rtable);
+       WRITE_NODE_FIELD(resultRelations);
+       WRITE_NODE_FIELD(utilityStmt);
+       WRITE_NODE_FIELD(intoClause);
+       WRITE_NODE_FIELD(subplans);
+       WRITE_BITMAPSET_FIELD(rewindPlanIDs);
+       WRITE_NODE_FIELD(returningLists);
+       WRITE_NODE_FIELD(rowMarks);
+       WRITE_INT_FIELD(nParamExec);
+}
+
 /*
  * print the basic stuff of all nodes that inherit from Plan
  */
@@ -251,7 +270,6 @@ _outPlanInfo(StringInfo str, Plan *node)
        WRITE_NODE_FIELD(initPlan);
        WRITE_BITMAPSET_FIELD(extParam);
        WRITE_BITMAPSET_FIELD(allParam);
-       WRITE_INT_FIELD(nParamExec);
 }
 
 /*
@@ -400,6 +418,7 @@ _outSubqueryScan(StringInfo str, SubqueryScan *node)
        _outScanInfo(str, (Scan *) node);
 
        WRITE_NODE_FIELD(subplan);
+       WRITE_NODE_FIELD(subrtable);
 }
 
 static void
@@ -635,6 +654,18 @@ _outRangeVar(StringInfo str, RangeVar *node)
        WRITE_NODE_FIELD(alias);
 }
 
+static void
+_outIntoClause(StringInfo str, IntoClause *node)
+{
+       WRITE_NODE_TYPE("INTOCLAUSE");
+
+       WRITE_NODE_FIELD(rel);
+       WRITE_NODE_FIELD(colNames);
+       WRITE_NODE_FIELD(options);
+       WRITE_ENUM_FIELD(onCommit, OnCommitAction);
+       WRITE_STRING_FIELD(tableSpaceName);
+}
+
 static void
 _outVar(StringInfo str, Var *node)
 {
@@ -655,6 +686,7 @@ _outConst(StringInfo str, Const *node)
        WRITE_NODE_TYPE("CONST");
 
        WRITE_OID_FIELD(consttype);
+       WRITE_INT_FIELD(consttypmod);
        WRITE_INT_FIELD(constlen);
        WRITE_BOOL_FIELD(constbyval);
        WRITE_BOOL_FIELD(constisnull);
@@ -695,9 +727,9 @@ _outArrayRef(StringInfo str, ArrayRef *node)
 {
        WRITE_NODE_TYPE("ARRAYREF");
 
-       WRITE_OID_FIELD(refrestype);
        WRITE_OID_FIELD(refarraytype);
        WRITE_OID_FIELD(refelemtype);
+       WRITE_INT_FIELD(reftypmod);
        WRITE_NODE_FIELD(refupperindexpr);
        WRITE_NODE_FIELD(reflowerindexpr);
        WRITE_NODE_FIELD(refexpr);
@@ -796,9 +828,8 @@ _outSubPlan(StringInfo str, SubPlan *node)
        WRITE_ENUM_FIELD(subLinkType, SubLinkType);
        WRITE_NODE_FIELD(testexpr);
        WRITE_NODE_FIELD(paramIds);
-       WRITE_NODE_FIELD(plan);
        WRITE_INT_FIELD(plan_id);
-       WRITE_NODE_FIELD(rtable);
+       WRITE_OID_FIELD(firstColType);
        WRITE_BOOL_FIELD(useHashTable);
        WRITE_BOOL_FIELD(unknownEqFalse);
        WRITE_NODE_FIELD(setParam);
@@ -839,6 +870,29 @@ _outRelabelType(StringInfo str, RelabelType *node)
        WRITE_ENUM_FIELD(relabelformat, CoercionForm);
 }
 
+static void
+_outCoerceViaIO(StringInfo str, CoerceViaIO *node)
+{
+       WRITE_NODE_TYPE("COERCEVIAIO");
+
+       WRITE_NODE_FIELD(arg);
+       WRITE_OID_FIELD(resulttype);
+       WRITE_ENUM_FIELD(coerceformat, CoercionForm);
+}
+
+static void
+_outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
+{
+       WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
+
+       WRITE_NODE_FIELD(arg);
+       WRITE_OID_FIELD(elemfuncid);
+       WRITE_OID_FIELD(resulttype);
+       WRITE_INT_FIELD(resulttypmod);
+       WRITE_BOOL_FIELD(isExplicit);
+       WRITE_ENUM_FIELD(coerceformat, CoercionForm);
+}
+
 static void
 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
 {
@@ -1004,6 +1058,15 @@ _outSetToDefault(StringInfo str, SetToDefault *node)
        WRITE_INT_FIELD(typeMod);
 }
 
+static void
+_outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
+{
+       WRITE_NODE_TYPE("CURRENTOFEXPR");
+
+       WRITE_UINT_FIELD(cvarno);
+       WRITE_STRING_FIELD(cursor_name);
+}
+
 static void
 _outTargetEntry(StringInfo str, TargetEntry *node)
 {
@@ -1232,7 +1295,10 @@ _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
 
        /* NB: this isn't a complete set of fields */
        WRITE_NODE_FIELD(paramlist);
-       WRITE_INT_FIELD(next_plan_id);
+       WRITE_NODE_FIELD(subplans);
+       WRITE_NODE_FIELD(subrtables);
+       WRITE_BITMAPSET_FIELD(rewindPlanIDs);
+       WRITE_NODE_FIELD(finalrtable);
 }
 
 static void
@@ -1245,6 +1311,8 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
        WRITE_NODE_FIELD(glob);
        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(eq_classes);
        WRITE_NODE_FIELD(canon_pathkeys);
@@ -1288,6 +1356,7 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
        WRITE_UINT_FIELD(pages);
        WRITE_FLOAT_FIELD(tuples, "%.0f");
        WRITE_NODE_FIELD(subplan);
+       WRITE_NODE_FIELD(subrtable);
        WRITE_NODE_FIELD(baserestrictinfo);
        WRITE_NODE_FIELD(joininfo);
        WRITE_BOOL_FIELD(has_eclass_joins);
@@ -1390,7 +1459,8 @@ _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
        WRITE_NODE_TYPE("INNERINDEXSCANINFO");
        WRITE_BITMAPSET_FIELD(other_relids);
        WRITE_BOOL_FIELD(isouterjoin);
-       WRITE_NODE_FIELD(best_innerpath);
+       WRITE_NODE_FIELD(cheapest_startup_innerpath);
+       WRITE_NODE_FIELD(cheapest_total_innerpath);
 }
 
 static void
@@ -1402,6 +1472,7 @@ _outOuterJoinInfo(StringInfo str, OuterJoinInfo *node)
        WRITE_BITMAPSET_FIELD(min_righthand);
        WRITE_BOOL_FIELD(is_full_join);
        WRITE_BOOL_FIELD(lhs_strict);
+       WRITE_BOOL_FIELD(delay_upper_joins);
 }
 
 static void
@@ -1470,7 +1541,6 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
        WRITE_NODE_FIELD(indexParams);
        WRITE_NODE_FIELD(options);
        WRITE_NODE_FIELD(whereClause);
-       WRITE_NODE_FIELD(rangetable);
        WRITE_BOOL_FIELD(unique);
        WRITE_BOOL_FIELD(primary);
        WRITE_BOOL_FIELD(isconstraint);
@@ -1501,11 +1571,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
        WRITE_NODE_TYPE("SELECT");
 
        WRITE_NODE_FIELD(distinctClause);
-       WRITE_NODE_FIELD(into);
-       WRITE_NODE_FIELD(intoColNames);
-       WRITE_NODE_FIELD(intoOptions);
-       WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
-       WRITE_STRING_FIELD(intoTableSpaceName);
+       WRITE_NODE_FIELD(intoClause);
        WRITE_NODE_FIELD(targetList);
        WRITE_NODE_FIELD(fromClause);
        WRITE_NODE_FIELD(whereClause);
@@ -1650,10 +1716,7 @@ _outQuery(StringInfo str, Query *node)
                appendStringInfo(str, " :utilityStmt <>");
 
        WRITE_INT_FIELD(resultRelation);
-       WRITE_NODE_FIELD(into);
-       WRITE_NODE_FIELD(intoOptions);
-       WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
-       WRITE_STRING_FIELD(intoTableSpaceName);
+       WRITE_NODE_FIELD(intoClause);
        WRITE_BOOL_FIELD(hasAggs);
        WRITE_BOOL_FIELD(hasSubLinks);
        WRITE_NODE_FIELD(rtable);
@@ -1668,8 +1731,6 @@ _outQuery(StringInfo str, Query *node)
        WRITE_NODE_FIELD(limitCount);
        WRITE_NODE_FIELD(rowMarks);
        WRITE_NODE_FIELD(setOperations);
-       WRITE_NODE_FIELD(resultRelations);
-       WRITE_NODE_FIELD(returningLists);
 }
 
 static void
@@ -1988,6 +2049,9 @@ _outNode(StringInfo str, void *obj)
                appendStringInfoChar(str, '{');
                switch (nodeTag(obj))
                {
+                       case T_PlannedStmt:
+                               _outPlannedStmt(str, obj);
+                               break;
                        case T_Plan:
                                _outPlan(str, obj);
                                break;
@@ -2072,6 +2136,9 @@ _outNode(StringInfo str, void *obj)
                        case T_RangeVar:
                                _outRangeVar(str, obj);
                                break;
+                       case T_IntoClause:
+                               _outIntoClause(str, obj);
+                               break;
                        case T_Var:
                                _outVar(str, obj);
                                break;
@@ -2117,6 +2184,12 @@ _outNode(StringInfo str, void *obj)
                        case T_RelabelType:
                                _outRelabelType(str, obj);
                                break;
+                       case T_CoerceViaIO:
+                               _outCoerceViaIO(str, obj);
+                               break;
+                       case T_ArrayCoerceExpr:
+                               _outArrayCoerceExpr(str, obj);
+                               break;
                        case T_ConvertRowtypeExpr:
                                _outConvertRowtypeExpr(str, obj);
                                break;
@@ -2165,6 +2238,9 @@ _outNode(StringInfo str, void *obj)
                        case T_SetToDefault:
                                _outSetToDefault(str, obj);
                                break;
+                       case T_CurrentOfExpr:
+                               _outCurrentOfExpr(str, obj);
+                               break;
                        case T_TargetEntry:
                                _outTargetEntry(str, obj);
                                break;