Relocate partition pruning structs to a saner place.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 10 Jun 2018 20:30:14 +0000 (16:30 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 10 Jun 2018 20:30:14 +0000 (16:30 -0400)
These struct definitions were originally dropped into primnodes.h,
which is a poor choice since that's mainly intended for primitive
expression node types; these are not in that category.  What they
are is auxiliary info in Plan trees, so move them to plannodes.h.

For consistency, also relocate some related code that was apparently
placed with the aid of a dartboard.

There's no interesting code changes in this commit, just reshuffling.

David Rowley and Tom Lane

Discussion: https://postgr.es/m/CAFj8pRBjrufA3ocDm8o4LPGNye9Y+pm1b9kCwode4X04CULG3g@mail.gmail.com

src/backend/executor/execPartition.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/plan/createplan.c
src/include/nodes/nodes.h
src/include/nodes/plannodes.h
src/include/nodes/primnodes.h

index 6c461c91b237041b48a1c28a41cae2d790036cab..5a04b3524d0869d0e02811adcde0b0692f22fad0 100644 (file)
@@ -1434,7 +1434,7 @@ ExecSetupPartitionPruneState(PlanState *planstate, List *partitionpruneinfo)
    i = 0;
    foreach(lc, partitionpruneinfo)
    {
-       PartitionPruneInfo *pinfo = (PartitionPruneInfo *) lfirst(lc);
+       PartitionPruneInfo *pinfo = castNode(PartitionPruneInfo, lfirst(lc));
        PartitionPruningData *pprune = &prunedata[i];
        PartitionPruneContext *context = &pprune->context;
        PartitionDesc partdesc;
index db14a99e4422512c5c76021474fa8d3f1ae29790..0e08dcaa3e6d9237949450d84064c0a2a385d66b 100644 (file)
@@ -242,9 +242,9 @@ _copyAppend(const Append *from)
    /*
     * copy remainder of node
     */
-   COPY_NODE_FIELD(partitioned_rels);
    COPY_NODE_FIELD(appendplans);
    COPY_SCALAR_FIELD(first_partial_plan);
+   COPY_NODE_FIELD(partitioned_rels);
    COPY_NODE_FIELD(part_prune_infos);
 
    return newnode;
@@ -1176,6 +1176,58 @@ _copyPlanRowMark(const PlanRowMark *from)
    return newnode;
 }
 
+static PartitionPruneInfo *
+_copyPartitionPruneInfo(const PartitionPruneInfo *from)
+{
+   PartitionPruneInfo *newnode = makeNode(PartitionPruneInfo);
+
+   COPY_SCALAR_FIELD(reloid);
+   COPY_NODE_FIELD(pruning_steps);
+   COPY_BITMAPSET_FIELD(present_parts);
+   COPY_SCALAR_FIELD(nparts);
+   COPY_SCALAR_FIELD(nexprs);
+   COPY_POINTER_FIELD(subnode_map, from->nparts * sizeof(int));
+   COPY_POINTER_FIELD(subpart_map, from->nparts * sizeof(int));
+   COPY_POINTER_FIELD(hasexecparam, from->nexprs * sizeof(bool));
+   COPY_SCALAR_FIELD(do_initial_prune);
+   COPY_SCALAR_FIELD(do_exec_prune);
+   COPY_BITMAPSET_FIELD(execparamids);
+
+   return newnode;
+}
+
+/*
+ * _copyPartitionPruneStepOp
+ */
+static PartitionPruneStepOp *
+_copyPartitionPruneStepOp(const PartitionPruneStepOp *from)
+{
+   PartitionPruneStepOp *newnode = makeNode(PartitionPruneStepOp);
+
+   COPY_SCALAR_FIELD(step.step_id);
+   COPY_SCALAR_FIELD(opstrategy);
+   COPY_NODE_FIELD(exprs);
+   COPY_NODE_FIELD(cmpfns);
+   COPY_BITMAPSET_FIELD(nullkeys);
+
+   return newnode;
+}
+
+/*
+ * _copyPartitionPruneStepCombine
+ */
+static PartitionPruneStepCombine *
+_copyPartitionPruneStepCombine(const PartitionPruneStepCombine *from)
+{
+   PartitionPruneStepCombine *newnode = makeNode(PartitionPruneStepCombine);
+
+   COPY_SCALAR_FIELD(step.step_id);
+   COPY_SCALAR_FIELD(combineOp);
+   COPY_NODE_FIELD(source_stepids);
+
+   return newnode;
+}
+
 /*
  * _copyPlanInvalItem
  */
@@ -2134,58 +2186,6 @@ _copyOnConflictExpr(const OnConflictExpr *from)
    return newnode;
 }
 
-/*
- * _copyPartitionPruneStepOp
- */
-static PartitionPruneStepOp *
-_copyPartitionPruneStepOp(const PartitionPruneStepOp *from)
-{
-   PartitionPruneStepOp *newnode = makeNode(PartitionPruneStepOp);
-
-   COPY_SCALAR_FIELD(step.step_id);
-   COPY_SCALAR_FIELD(opstrategy);
-   COPY_NODE_FIELD(exprs);
-   COPY_NODE_FIELD(cmpfns);
-   COPY_BITMAPSET_FIELD(nullkeys);
-
-   return newnode;
-}
-
-/*
- * _copyPartitionPruneStepCombine
- */
-static PartitionPruneStepCombine *
-_copyPartitionPruneStepCombine(const PartitionPruneStepCombine *from)
-{
-   PartitionPruneStepCombine *newnode = makeNode(PartitionPruneStepCombine);
-
-   COPY_SCALAR_FIELD(step.step_id);
-   COPY_SCALAR_FIELD(combineOp);
-   COPY_NODE_FIELD(source_stepids);
-
-   return newnode;
-}
-
-static PartitionPruneInfo *
-_copyPartitionPruneInfo(const PartitionPruneInfo *from)
-{
-   PartitionPruneInfo *newnode = makeNode(PartitionPruneInfo);
-
-   COPY_SCALAR_FIELD(reloid);
-   COPY_NODE_FIELD(pruning_steps);
-   COPY_BITMAPSET_FIELD(present_parts);
-   COPY_SCALAR_FIELD(nparts);
-   COPY_SCALAR_FIELD(nexprs);
-   COPY_POINTER_FIELD(subnode_map, from->nparts * sizeof(int));
-   COPY_POINTER_FIELD(subpart_map, from->nparts * sizeof(int));
-   COPY_POINTER_FIELD(hasexecparam, from->nexprs * sizeof(bool));
-   COPY_SCALAR_FIELD(do_initial_prune);
-   COPY_SCALAR_FIELD(do_exec_prune);
-   COPY_BITMAPSET_FIELD(execparamids);
-
-   return newnode;
-}
-
 /* ****************************************************************
  *                     relation.h copy functions
  *
@@ -4904,6 +4904,15 @@ copyObjectImpl(const void *from)
        case T_PlanRowMark:
            retval = _copyPlanRowMark(from);
            break;
+       case T_PartitionPruneInfo:
+           retval = _copyPartitionPruneInfo(from);
+           break;
+       case T_PartitionPruneStepOp:
+           retval = _copyPartitionPruneStepOp(from);
+           break;
+       case T_PartitionPruneStepCombine:
+           retval = _copyPartitionPruneStepCombine(from);
+           break;
        case T_PlanInvalItem:
            retval = _copyPlanInvalItem(from);
            break;
@@ -5064,12 +5073,6 @@ copyObjectImpl(const void *from)
        case T_OnConflictExpr:
            retval = _copyOnConflictExpr(from);
            break;
-       case T_PartitionPruneStepOp:
-           retval = _copyPartitionPruneStepOp(from);
-           break;
-       case T_PartitionPruneStepCombine:
-           retval = _copyPartitionPruneStepCombine(from);
-           break;
 
            /*
             * RELATION NODES
@@ -5092,9 +5095,6 @@ copyObjectImpl(const void *from)
        case T_PlaceHolderInfo:
            retval = _copyPlaceHolderInfo(from);
            break;
-       case T_PartitionPruneInfo:
-           retval = _copyPartitionPruneInfo(from);
-           break;
 
            /*
             * VALUE NODES
index 5895262c4a8fe0cc7cb24bef8f0953af11cf1929..19879aeb463c2b2d4f6f11ce60715e48afa0388c 100644 (file)
@@ -399,9 +399,9 @@ _outAppend(StringInfo str, const Append *node)
 
    _outPlanInfo(str, (const Plan *) node);
 
-   WRITE_NODE_FIELD(partitioned_rels);
    WRITE_NODE_FIELD(appendplans);
    WRITE_INT_FIELD(first_partial_plan);
+   WRITE_NODE_FIELD(partitioned_rels);
    WRITE_NODE_FIELD(part_prune_infos);
 }
 
@@ -1010,6 +1010,58 @@ _outPlanRowMark(StringInfo str, const PlanRowMark *node)
    WRITE_BOOL_FIELD(isParent);
 }
 
+static void
+_outPartitionPruneInfo(StringInfo str, const PartitionPruneInfo *node)
+{
+   int         i;
+
+   WRITE_NODE_TYPE("PARTITIONPRUNEINFO");
+
+   WRITE_OID_FIELD(reloid);
+   WRITE_NODE_FIELD(pruning_steps);
+   WRITE_BITMAPSET_FIELD(present_parts);
+   WRITE_INT_FIELD(nparts);
+   WRITE_INT_FIELD(nexprs);
+
+   appendStringInfoString(str, " :subnode_map");
+   for (i = 0; i < node->nparts; i++)
+       appendStringInfo(str, " %d", node->subnode_map[i]);
+
+   appendStringInfoString(str, " :subpart_map");
+   for (i = 0; i < node->nparts; i++)
+       appendStringInfo(str, " %d", node->subpart_map[i]);
+
+   appendStringInfoString(str, " :hasexecparam");
+   for (i = 0; i < node->nexprs; i++)
+       appendStringInfo(str, " %s", booltostr(node->hasexecparam[i]));
+
+   WRITE_BOOL_FIELD(do_initial_prune);
+   WRITE_BOOL_FIELD(do_exec_prune);
+   WRITE_BITMAPSET_FIELD(execparamids);
+}
+
+static void
+_outPartitionPruneStepOp(StringInfo str, const PartitionPruneStepOp *node)
+{
+   WRITE_NODE_TYPE("PARTITIONPRUNESTEPOP");
+
+   WRITE_INT_FIELD(step.step_id);
+   WRITE_INT_FIELD(opstrategy);
+   WRITE_NODE_FIELD(exprs);
+   WRITE_NODE_FIELD(cmpfns);
+   WRITE_BITMAPSET_FIELD(nullkeys);
+}
+
+static void
+_outPartitionPruneStepCombine(StringInfo str, const PartitionPruneStepCombine *node)
+{
+   WRITE_NODE_TYPE("PARTITIONPRUNESTEPCOMBINE");
+
+   WRITE_INT_FIELD(step.step_id);
+   WRITE_ENUM_FIELD(combineOp, PartitionPruneCombineOp);
+   WRITE_NODE_FIELD(source_stepids);
+}
+
 static void
 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
 {
@@ -1694,28 +1746,6 @@ _outFromExpr(StringInfo str, const FromExpr *node)
    WRITE_NODE_FIELD(quals);
 }
 
-static void
-_outPartitionPruneStepOp(StringInfo str, const PartitionPruneStepOp *node)
-{
-   WRITE_NODE_TYPE("PARTITIONPRUNESTEPOP");
-
-   WRITE_INT_FIELD(step.step_id);
-   WRITE_INT_FIELD(opstrategy);
-   WRITE_NODE_FIELD(exprs);
-   WRITE_NODE_FIELD(cmpfns);
-   WRITE_BITMAPSET_FIELD(nullkeys);
-}
-
-static void
-_outPartitionPruneStepCombine(StringInfo str, const PartitionPruneStepCombine *node)
-{
-   WRITE_NODE_TYPE("PARTITIONPRUNESTEPCOMBINE");
-
-   WRITE_INT_FIELD(step.step_id);
-   WRITE_ENUM_FIELD(combineOp, PartitionPruneCombineOp);
-   WRITE_NODE_FIELD(source_stepids);
-}
-
 static void
 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
 {
@@ -1731,36 +1761,6 @@ _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
    WRITE_NODE_FIELD(exclRelTlist);
 }
 
-static void
-_outPartitionPruneInfo(StringInfo str, const PartitionPruneInfo *node)
-{
-   int         i;
-
-   WRITE_NODE_TYPE("PARTITIONPRUNEINFO");
-
-   WRITE_OID_FIELD(reloid);
-   WRITE_NODE_FIELD(pruning_steps);
-   WRITE_BITMAPSET_FIELD(present_parts);
-   WRITE_INT_FIELD(nparts);
-   WRITE_INT_FIELD(nexprs);
-
-   appendStringInfoString(str, " :subnode_map");
-   for (i = 0; i < node->nparts; i++)
-       appendStringInfo(str, " %d", node->subnode_map[i]);
-
-   appendStringInfoString(str, " :subpart_map");
-   for (i = 0; i < node->nparts; i++)
-       appendStringInfo(str, " %d", node->subpart_map[i]);
-
-   appendStringInfoString(str, " :hasexecparam");
-   for (i = 0; i < node->nexprs; i++)
-       appendStringInfo(str, " %s", booltostr(node->hasexecparam[i]));
-
-   WRITE_BOOL_FIELD(do_initial_prune);
-   WRITE_BOOL_FIELD(do_exec_prune);
-   WRITE_BITMAPSET_FIELD(execparamids);
-}
-
 /*****************************************************************************
  *
  * Stuff from relation.h.
@@ -3827,6 +3827,15 @@ outNode(StringInfo str, const void *obj)
            case T_PlanRowMark:
                _outPlanRowMark(str, obj);
                break;
+           case T_PartitionPruneInfo:
+               _outPartitionPruneInfo(str, obj);
+               break;
+           case T_PartitionPruneStepOp:
+               _outPartitionPruneStepOp(str, obj);
+               break;
+           case T_PartitionPruneStepCombine:
+               _outPartitionPruneStepCombine(str, obj);
+               break;
            case T_PlanInvalItem:
                _outPlanInvalItem(str, obj);
                break;
@@ -3983,15 +3992,6 @@ outNode(StringInfo str, const void *obj)
            case T_OnConflictExpr:
                _outOnConflictExpr(str, obj);
                break;
-           case T_PartitionPruneStepOp:
-               _outPartitionPruneStepOp(str, obj);
-               break;
-           case T_PartitionPruneStepCombine:
-               _outPartitionPruneStepCombine(str, obj);
-               break;
-           case T_PartitionPruneInfo:
-               _outPartitionPruneInfo(str, obj);
-               break;
            case T_Path:
                _outPath(str, obj);
                break;
index da58aad4b32e365bb053e06c5f2a9a99c1b5d09e..f41e590a1552cc923a49b99dd6c92fc04ff69717 100644 (file)
@@ -1328,52 +1328,6 @@ _readOnConflictExpr(void)
    READ_DONE();
 }
 
-static PartitionPruneStepOp *
-_readPartitionPruneStepOp(void)
-{
-   READ_LOCALS(PartitionPruneStepOp);
-
-   READ_INT_FIELD(step.step_id);
-   READ_INT_FIELD(opstrategy);
-   READ_NODE_FIELD(exprs);
-   READ_NODE_FIELD(cmpfns);
-   READ_BITMAPSET_FIELD(nullkeys);
-
-   READ_DONE();
-}
-
-static PartitionPruneStepCombine *
-_readPartitionPruneStepCombine(void)
-{
-   READ_LOCALS(PartitionPruneStepCombine);
-
-   READ_INT_FIELD(step.step_id);
-   READ_ENUM_FIELD(combineOp, PartitionPruneCombineOp);
-   READ_NODE_FIELD(source_stepids);
-
-   READ_DONE();
-}
-
-static PartitionPruneInfo *
-_readPartitionPruneInfo(void)
-{
-   READ_LOCALS(PartitionPruneInfo);
-
-   READ_OID_FIELD(reloid);
-   READ_NODE_FIELD(pruning_steps);
-   READ_BITMAPSET_FIELD(present_parts);
-   READ_INT_FIELD(nparts);
-   READ_INT_FIELD(nexprs);
-   READ_INT_ARRAY(subnode_map, local_node->nparts);
-   READ_INT_ARRAY(subpart_map, local_node->nparts);
-   READ_BOOL_ARRAY(hasexecparam, local_node->nexprs);
-   READ_BOOL_FIELD(do_initial_prune);
-   READ_BOOL_FIELD(do_exec_prune);
-   READ_BITMAPSET_FIELD(execparamids);
-
-   READ_DONE();
-}
-
 /*
  * Stuff from parsenodes.h.
  */
@@ -1505,6 +1459,10 @@ _readDefElem(void)
    READ_DONE();
 }
 
+/*
+ * Stuff from plannodes.h.
+ */
+
 /*
  * _readPlannedStmt
  */
@@ -1651,9 +1609,9 @@ _readAppend(void)
 
    ReadCommonPlan(&local_node->plan);
 
-   READ_NODE_FIELD(partitioned_rels);
    READ_NODE_FIELD(appendplans);
    READ_INT_FIELD(first_partial_plan);
+   READ_NODE_FIELD(partitioned_rels);
    READ_NODE_FIELD(part_prune_infos);
 
    READ_DONE();
@@ -2365,6 +2323,52 @@ _readPlanRowMark(void)
    READ_DONE();
 }
 
+static PartitionPruneInfo *
+_readPartitionPruneInfo(void)
+{
+   READ_LOCALS(PartitionPruneInfo);
+
+   READ_OID_FIELD(reloid);
+   READ_NODE_FIELD(pruning_steps);
+   READ_BITMAPSET_FIELD(present_parts);
+   READ_INT_FIELD(nparts);
+   READ_INT_FIELD(nexprs);
+   READ_INT_ARRAY(subnode_map, local_node->nparts);
+   READ_INT_ARRAY(subpart_map, local_node->nparts);
+   READ_BOOL_ARRAY(hasexecparam, local_node->nexprs);
+   READ_BOOL_FIELD(do_initial_prune);
+   READ_BOOL_FIELD(do_exec_prune);
+   READ_BITMAPSET_FIELD(execparamids);
+
+   READ_DONE();
+}
+
+static PartitionPruneStepOp *
+_readPartitionPruneStepOp(void)
+{
+   READ_LOCALS(PartitionPruneStepOp);
+
+   READ_INT_FIELD(step.step_id);
+   READ_INT_FIELD(opstrategy);
+   READ_NODE_FIELD(exprs);
+   READ_NODE_FIELD(cmpfns);
+   READ_BITMAPSET_FIELD(nullkeys);
+
+   READ_DONE();
+}
+
+static PartitionPruneStepCombine *
+_readPartitionPruneStepCombine(void)
+{
+   READ_LOCALS(PartitionPruneStepCombine);
+
+   READ_INT_FIELD(step.step_id);
+   READ_ENUM_FIELD(combineOp, PartitionPruneCombineOp);
+   READ_NODE_FIELD(source_stepids);
+
+   READ_DONE();
+}
+
 /*
  * _readPlanInvalItem
  */
@@ -2619,12 +2623,6 @@ parseNodeString(void)
        return_value = _readFromExpr();
    else if (MATCH("ONCONFLICTEXPR", 14))
        return_value = _readOnConflictExpr();
-   else if (MATCH("PARTITIONPRUNESTEPOP", 20))
-       return_value = _readPartitionPruneStepOp();
-   else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
-       return_value = _readPartitionPruneStepCombine();
-   else if (MATCH("PARTITIONPRUNEINFO", 18))
-       return_value = _readPartitionPruneInfo();
    else if (MATCH("RTE", 3))
        return_value = _readRangeTblEntry();
    else if (MATCH("RANGETBLFUNCTION", 16))
@@ -2725,6 +2723,12 @@ parseNodeString(void)
        return_value = _readNestLoopParam();
    else if (MATCH("PLANROWMARK", 11))
        return_value = _readPlanRowMark();
+   else if (MATCH("PARTITIONPRUNEINFO", 18))
+       return_value = _readPartitionPruneInfo();
+   else if (MATCH("PARTITIONPRUNESTEPOP", 20))
+       return_value = _readPartitionPruneStepOp();
+   else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
+       return_value = _readPartitionPruneStepCombine();
    else if (MATCH("PLANINVALITEM", 13))
        return_value = _readPlanInvalItem();
    else if (MATCH("SUBPLAN", 7))
index ca2e0527dbce5411cda1a9b213f9d41343e48865..cf82b7052dbf55ce7285d06d61f5d7139fa7ba8e 100644 (file)
@@ -5426,9 +5426,9 @@ make_append(List *appendplans, int first_partial_plan,
    plan->qual = NIL;
    plan->lefttree = NULL;
    plan->righttree = NULL;
-   node->partitioned_rels = partitioned_rels;
    node->appendplans = appendplans;
    node->first_partial_plan = first_partial_plan;
+   node->partitioned_rels = partitioned_rels;
    node->part_prune_infos = partpruneinfos;
    return node;
 }
index adb159a6dab17e2b09e09b3dbaab5c3124655dda..43f1552241cacae9589136d9bf2fa8bc711175c6 100644 (file)
@@ -87,6 +87,9 @@ typedef enum NodeTag
    /* these aren't subclasses of Plan: */
    T_NestLoopParam,
    T_PlanRowMark,
+   T_PartitionPruneInfo,
+   T_PartitionPruneStepOp,
+   T_PartitionPruneStepCombine,
    T_PlanInvalItem,
 
    /*
@@ -192,10 +195,6 @@ typedef enum NodeTag
    T_FromExpr,
    T_OnConflictExpr,
    T_IntoClause,
-   T_PartitionPruneStep,
-   T_PartitionPruneStepOp,
-   T_PartitionPruneStepCombine,
-   T_PartitionPruneInfo,
 
    /*
     * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
index f2dda82e66a4a3a4ea3ec73ee4733202c5674b4b..00e0416a24bcb35c6fe46466f95b40e6b2cc7a9a 100644 (file)
@@ -15,6 +15,7 @@
 #define PLANNODES_H
 
 #include "access/sdir.h"
+#include "access/stratnum.h"
 #include "lib/stringinfo.h"
 #include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
@@ -248,8 +249,6 @@ typedef struct ModifyTable
 typedef struct Append
 {
    Plan        plan;
-   /* RT indexes of non-leaf tables in a partition tree */
-   List       *partitioned_rels;
    List       *appendplans;
 
    /*
@@ -258,10 +257,11 @@ typedef struct Append
     */
    int         first_partial_plan;
 
-   /*
-    * Mapping details for run-time subplan pruning, one per partitioned_rels
-    */
-   List       *part_prune_infos;
+   /* RT indexes of non-leaf tables in a partition tree */
+   List       *partitioned_rels;
+
+   /* Info for run-time subplan pruning, one entry per partitioned_rels */
+   List       *part_prune_infos;   /* List of PartitionPruneInfo */
 } Append;
 
 /* ----------------
@@ -1046,6 +1046,108 @@ typedef struct PlanRowMark
 } PlanRowMark;
 
 
+/*
+ * Node types to represent partition pruning information.
+ */
+
+/*
+ * PartitionPruneInfo - Details required to allow the executor to prune
+ * partitions.
+ *
+ * Here we store mapping details to allow translation of a partitioned table's
+ * index into subnode indexes for node types which support arbitrary numbers
+ * of sub nodes, such as Append.
+ */
+typedef struct PartitionPruneInfo
+{
+   NodeTag     type;
+   Oid         reloid;         /* Oid of partition rel */
+   List       *pruning_steps;  /* List of PartitionPruneStep, see below */
+   Bitmapset  *present_parts;  /* Indexes of all partitions which subnodes
+                                * are present for. */
+   int         nparts;         /* Length of subnode_map[] and subpart_map[] */
+   int         nexprs;         /* Length of hasexecparam[] */
+   int        *subnode_map;    /* subnode index by partition id, or -1 */
+   int        *subpart_map;    /* subpart index by partition id, or -1 */
+   bool       *hasexecparam;   /* true if corresponding pruning_step contains
+                                * any PARAM_EXEC Params. */
+   bool        do_initial_prune;   /* true if pruning should be performed
+                                    * during executor startup. */
+   bool        do_exec_prune;  /* true if pruning should be performed during
+                                * executor run. */
+   Bitmapset  *execparamids;   /* All PARAM_EXEC Param IDs in pruning_steps */
+} PartitionPruneInfo;
+
+/*
+ * Abstract Node type for partition pruning steps (there are no concrete
+ * Nodes of this type).
+ *
+ * step_id is the global identifier of the step within its pruning context.
+ */
+typedef struct PartitionPruneStep
+{
+   NodeTag     type;
+   int         step_id;
+} PartitionPruneStep;
+
+/*
+ * PartitionPruneStepOp - Information to prune using a set of mutually AND'd
+ *                         OpExpr clauses
+ *
+ * This contains information extracted from up to partnatts OpExpr clauses,
+ * where partnatts is the number of partition key columns.  'opstrategy' is the
+ * strategy of the operator in the clause matched to the last partition key.
+ * 'exprs' contains expressions which comprise the lookup key to be passed to
+ * the partition bound search function.  'cmpfns' contains the OIDs of
+ * comparison function used to compare aforementioned expressions with
+ * partition bounds.  Both 'exprs' and 'cmpfns' contain the same number of
+ * items up to partnatts items.
+ *
+ * Once we find the offset of a partition bound using the lookup key, we
+ * determine which partitions to include in the result based on the value of
+ * 'opstrategy'.  For example, if it were equality, we'd return just the
+ * partition that would contain that key or a set of partitions if the key
+ * didn't consist of all partitioning columns.  For non-equality strategies,
+ * we'd need to include other partitions as appropriate.
+ *
+ * 'nullkeys' is the set containing the offset of the partition keys (0 to
+ * partnatts - 1) that were matched to an IS NULL clause.  This is only
+ * considered for hash partitioning as we need to pass which keys are null
+ * to the hash partition bound search function.  It is never possible to
+ * have an expression be present in 'exprs' for a given partition key and
+ * the corresponding bit set in 'nullkeys'.
+ */
+typedef struct PartitionPruneStepOp
+{
+   PartitionPruneStep step;
+
+   StrategyNumber opstrategy;
+   List       *exprs;
+   List       *cmpfns;
+   Bitmapset  *nullkeys;
+} PartitionPruneStepOp;
+
+/*
+ * PartitionPruneStepCombine - Information to prune using a BoolExpr clause
+ *
+ * For BoolExpr clauses, we combine the set of partitions determined for each
+ * of the argument clauses.
+ */
+typedef enum PartitionPruneCombineOp
+{
+   PARTPRUNE_COMBINE_UNION,
+   PARTPRUNE_COMBINE_INTERSECT
+} PartitionPruneCombineOp;
+
+typedef struct PartitionPruneStepCombine
+{
+   PartitionPruneStep step;
+
+   PartitionPruneCombineOp combineOp;
+   List       *source_stepids;
+} PartitionPruneStepCombine;
+
+
 /*
  * Plan invalidation info
  *
index ef297cfaeda9e3010f7d84f772d0058659800ccd..1b4b0d75afa042a44930773cfe66ea347f1c69ef 100644 (file)
@@ -18,7 +18,6 @@
 #define PRIMNODES_H
 
 #include "access/attnum.h"
-#include "access/stratnum.h"
 #include "nodes/bitmapset.h"
 #include "nodes/pg_list.h"
 
@@ -1507,107 +1506,4 @@ typedef struct OnConflictExpr
    List       *exclRelTlist;   /* tlist of the EXCLUDED pseudo relation */
 } OnConflictExpr;
 
-
-/*
- * Node types to represent a partition pruning step.
- */
-
-/*
- * The base Node type.  step_id is the global identifier of a given step
- * within a given pruning context.
- */
-typedef struct PartitionPruneStep
-{
-   NodeTag     type;
-   int         step_id;
-} PartitionPruneStep;
-
-/*----------
- * PartitionPruneStepOp - Information to prune using a set of mutually AND'd
- *                         OpExpr clauses
- *
- * This contains information extracted from up to partnatts OpExpr clauses,
- * where partnatts is the number of partition key columns.  'opstrategy' is the
- * strategy of the operator in the clause matched to the last partition key.
- * 'exprs' contains expressions which comprise the lookup key to be passed to
- * the partition bound search function.  'cmpfns' contains the OIDs of
- * comparison function used to compare aforementioned expressions with
- * partition bounds.  Both 'exprs' and 'cmpfns' contain the same number of
- * items up to partnatts items.
- *
- * Once we find the offset of a partition bound using the lookup key, we
- * determine which partitions to include in the result based on the value of
- * 'opstrategy'.  For example, if it were equality, we'd return just the
- * partition that would contain that key or a set of partitions if the key
- * didn't consist of all partitioning columns.  For non-equality strategies,
- * we'd need to include other partitions as appropriate.
- *
- * 'nullkeys' is the set containing the offset of the partition keys (0 to
- * partnatts - 1) that were matched to an IS NULL clause.  This is only
- * considered for hash partitioning as we need to pass which keys are null
- * to the hash partition bound search function.  It is never possible to
- * have an expression be present in 'exprs' for a given partition key and
- * the corresponding bit set in 'nullkeys'.
- *----------
- */
-typedef struct PartitionPruneStepOp
-{
-   PartitionPruneStep step;
-
-   StrategyNumber opstrategy;
-   List       *exprs;
-   List       *cmpfns;
-   Bitmapset  *nullkeys;
-} PartitionPruneStepOp;
-
-/*----------
- * PartitionPruneStepCombine - Information to prune using a BoolExpr clause
- *
- * For BoolExpr clauses, we combine the set of partitions determined for each
- * of its argument clauses.
- *----------
- */
-typedef enum PartitionPruneCombineOp
-{
-   PARTPRUNE_COMBINE_UNION,
-   PARTPRUNE_COMBINE_INTERSECT
-} PartitionPruneCombineOp;
-
-typedef struct PartitionPruneStepCombine
-{
-   PartitionPruneStep step;
-
-   PartitionPruneCombineOp combineOp;
-   List       *source_stepids;
-} PartitionPruneStepCombine;
-
-/*----------
- * PartitionPruneInfo - Details required to allow the executor to prune
- * partitions.
- *
- * Here we store mapping details to allow translation of a partitioned table's
- * index into subnode indexes for node types which support arbitrary numbers
- * of sub nodes, such as Append.
- *----------
- */
-typedef struct PartitionPruneInfo
-{
-   NodeTag     type;
-   Oid         reloid;         /* Oid of partition rel */
-   List       *pruning_steps;  /* List of PartitionPruneStep */
-   Bitmapset  *present_parts;  /* Indexes of all partitions which subnodes
-                                * are present for. */
-   int         nparts;         /* Length of subnode_map[] and subpart_map[] */
-   int         nexprs;         /* Length of hasexecparam[] */
-   int        *subnode_map;    /* subnode index by partition id, or -1 */
-   int        *subpart_map;    /* subpart index by partition id, or -1 */
-   bool       *hasexecparam;   /* true if corresponding pruning_step contains
-                                * any PARAM_EXEC Params. */
-   bool        do_initial_prune;   /* true if pruning should be performed
-                                    * during executor startup. */
-   bool        do_exec_prune;  /* true if pruning should be performed during
-                                * executor run. */
-   Bitmapset  *execparamids;   /* All PARAM_EXEC Param IDs in pruning_steps */
-} PartitionPruneInfo;
-
 #endif                         /* PRIMNODES_H */