Mark more nodes with attribute no_query_jumble
authorMichael Paquier <michael@paquier.xyz>
Mon, 13 Feb 2023 00:07:33 +0000 (09:07 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 13 Feb 2023 00:07:33 +0000 (09:07 +0900)
This commit removes most of the Plan and Path nodes, which should never
be included in the query jumbling because we ignore these in Query
nodes.  This is facilitated by making no_query_jumble an inherited
attribute, like no_copy, no_equal and no_read when the supertype of a
node is found as marked with that.

RawStmt is not used in parsed queries, so it can be removed from the
query jumbling.  A couple of nodes defined in pathnodes.h, plannodes.h
and primnodes.h with NodeTag as supertype need to be marked
individually.

Forcing the execution of the query jumbling code with compute_query_id =
auto while pg_stat_statements is loaded brings the code coverage of
queryjumblefuncs.funcs.c to 95.6%.

The core code does not yet include a way to enforce the execution in
query jumbling except in pg_stat_statements, so the numbers I am
mentioning above will not reflect on the default coverage report with
just what is done in this commit.

Reported-by: Tom Lane
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/3344827.1675809127@sss.pgh.pa.us

src/backend/nodes/gen_node_support.pl
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/nodes/pathnodes.h
src/include/nodes/plannodes.h
src/include/nodes/primnodes.h
src/include/utils/rel.h

index 19ed29657c12b330484e882a2f935bb466ff5b96..ecbcadb8bf57e827161ba15bb32f165d42402307 100644 (file)
@@ -121,7 +121,7 @@ my %node_type_info;
 my @no_copy;
 # node types we don't want equal support for
 my @no_equal;
-# node types we don't want jumble support for
+# node types we don't want query jumble support for
 my @no_query_jumble;
 # node types we don't want read support for
 my @no_read;
@@ -422,6 +422,8 @@ foreach my $infile (@ARGV)
                                                  if elem $supertype, @no_equal;
                                                push @no_read, $in_struct
                                                  if elem $supertype, @no_read;
+                                               push @no_query_jumble, $in_struct
+                                                 if elem $supertype, @no_query_jumble;
                                        }
                                }
 
index 75dfe1919d75a4c91c3cc68d0f3049a80234375c..bdfef0f461d9d59b7842ce78872fdff62edf4cbc 100644 (file)
@@ -77,10 +77,10 @@ typedef enum NodeTag
  *
  * Node types can be supertypes of other types whether or not they are marked
  * abstract: if a node struct appears as the first field of another struct
- * type, then it is the supertype of that type.  The no_copy, no_equal, and
- * no_read node attributes are automatically inherited from the supertype.
- * (Notice that nodetag_only does not inherit, so it's not quite equivalent
- * to a combination of other attributes.)
+ * type, then it is the supertype of that type.  The no_copy, no_equal,
+ * no_query_jumble and no_read node attributes are automatically inherited
+ * from the supertype.  (Notice that nodetag_only does not inherit, so it's
+ * not quite equivalent to a combination of other attributes.)
  *
  * Valid node field attributes:
  *
index eafdb083ea47aeeeb5a359503a0bca6fadda3b00..f7d7f10f7dc57270acb898c5c70cc1ef37b702ee 100644 (file)
@@ -1728,9 +1728,14 @@ typedef struct TriggerTransition
  *
  * stmt_location/stmt_len identify the portion of the source text string
  * containing this raw statement (useful for multi-statement strings).
+ *
+ * This is irrelevant for query jumbling, as this is not used in parsed
+ * queries.
  */
 typedef struct RawStmt
 {
+       pg_node_attr(no_query_jumble)
+
        NodeTag         type;
        Node       *stmt;                       /* raw parse tree */
        int                     stmt_location;  /* start location, or -1 if unknown */
index 0d4b1ec4e42a77f34791df05005b11f613a38b05..be4d791212c39b72c44c681caea172ad1eea01c5 100644 (file)
@@ -94,7 +94,7 @@ typedef enum UpperRelationKind
  */
 typedef struct PlannerGlobal
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -194,7 +194,7 @@ typedef struct PlannerInfo PlannerInfo;
 
 struct PlannerInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -853,7 +853,7 @@ typedef enum RelOptKind
 
 typedef struct RelOptInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1098,7 +1098,7 @@ typedef struct IndexOptInfo IndexOptInfo;
 
 struct IndexOptInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1208,7 +1208,7 @@ struct IndexOptInfo
  */
 typedef struct ForeignKeyOptInfo
 {
-       pg_node_attr(custom_read_write, no_copy_equal, no_read)
+       pg_node_attr(custom_read_write, no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1258,7 +1258,7 @@ typedef struct ForeignKeyOptInfo
  */
 typedef struct StatisticExtInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1309,7 +1309,7 @@ typedef struct StatisticExtInfo
  */
 typedef struct JoinDomain
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1371,7 +1371,7 @@ typedef struct JoinDomain
  */
 typedef struct EquivalenceClass
 {
-       pg_node_attr(custom_read_write, no_copy_equal, no_read)
+       pg_node_attr(custom_read_write, no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1422,7 +1422,7 @@ typedef struct EquivalenceClass
  */
 typedef struct EquivalenceMember
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1455,7 +1455,7 @@ typedef struct EquivalenceMember
  */
 typedef struct PathKey
 {
-       pg_node_attr(no_read)
+       pg_node_attr(no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1503,7 +1503,7 @@ typedef enum VolatileFunctionStatus
  */
 typedef struct PathTarget
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1550,7 +1550,7 @@ typedef struct PathTarget
  */
 typedef struct ParamPathInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1596,7 +1596,7 @@ typedef struct ParamPathInfo
  */
 typedef struct Path
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -1730,7 +1730,7 @@ typedef struct IndexPath
  */
 typedef struct IndexClause
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
        struct RestrictInfo *rinfo; /* original restriction or join clause */
@@ -2231,7 +2231,7 @@ typedef struct AggPath
 
 typedef struct GroupingSetData
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
        List       *set;                        /* grouping set as list of sortgrouprefs */
@@ -2240,7 +2240,7 @@ typedef struct GroupingSetData
 
 typedef struct RollupData
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
        List       *groupClause;        /* applicable subset of parse->groupClause */
@@ -2509,7 +2509,7 @@ typedef struct LimitPath
 
 typedef struct RestrictInfo
 {
-       pg_node_attr(no_read)
+       pg_node_attr(no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -2724,6 +2724,8 @@ typedef struct MergeScanSelCache
 
 typedef struct PlaceHolderVar
 {
+       pg_node_attr(no_query_jumble)
+
        Expr            xpr;
 
        /* the represented expression */
@@ -2825,7 +2827,7 @@ typedef struct SpecialJoinInfo SpecialJoinInfo;
 
 struct SpecialJoinInfo
 {
-       pg_node_attr(no_read)
+       pg_node_attr(no_read, no_query_jumble)
 
        NodeTag         type;
        Relids          min_lefthand;   /* base+OJ relids in minimum LHS for join */
@@ -2853,7 +2855,7 @@ struct SpecialJoinInfo
  */
 typedef struct OuterJoinClauseInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
        RestrictInfo *rinfo;            /* a mergejoinable outer-join clause */
@@ -2892,6 +2894,8 @@ typedef struct OuterJoinClauseInfo
 
 typedef struct AppendRelInfo
 {
+       pg_node_attr(no_query_jumble)
+
        NodeTag         type;
 
        /*
@@ -2967,7 +2971,7 @@ typedef struct AppendRelInfo
  */
 typedef struct RowIdentityVarInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -3005,7 +3009,7 @@ typedef struct RowIdentityVarInfo
 
 typedef struct PlaceHolderInfo
 {
-       pg_node_attr(no_read)
+       pg_node_attr(no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -3038,7 +3042,7 @@ typedef struct PlaceHolderInfo
  */
 typedef struct MinMaxAggInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -3116,7 +3120,7 @@ typedef struct MinMaxAggInfo
  */
 typedef struct PlannerParamItem
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -3296,7 +3300,7 @@ typedef struct JoinCostWorkspace
  */
 typedef struct AggInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
@@ -3330,7 +3334,7 @@ typedef struct AggInfo
  */
 typedef struct AggTransInfo
 {
-       pg_node_attr(no_copy_equal, no_read)
+       pg_node_attr(no_copy_equal, no_read, no_query_jumble)
 
        NodeTag         type;
 
index 4781a9c63251f0e0aef1555ef1d4ff68027bbc36..659bd05c0c11841d9987d50dd389a1ff3403501b 100644 (file)
@@ -46,7 +46,7 @@
  */
 typedef struct PlannedStmt
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
 
@@ -122,7 +122,7 @@ typedef struct PlannedStmt
  */
 typedef struct Plan
 {
-       pg_node_attr(abstract, no_equal)
+       pg_node_attr(abstract, no_equal, no_query_jumble)
 
        NodeTag         type;
 
@@ -813,7 +813,7 @@ typedef struct NestLoop
 
 typedef struct NestLoopParam
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
        int                     paramno;                /* number of the PARAM_EXEC Param to set */
@@ -1377,7 +1377,7 @@ typedef enum RowMarkType
  */
 typedef struct PlanRowMark
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
        Index           rti;                    /* range table index of markable relation */
@@ -1425,7 +1425,7 @@ typedef struct PlanRowMark
  */
 typedef struct PartitionPruneInfo
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
        Bitmapset  *root_parent_relids;
@@ -1452,7 +1452,7 @@ typedef struct PartitionPruneInfo
  */
 typedef struct PartitionedRelPruneInfo
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
 
@@ -1495,7 +1495,7 @@ typedef struct PartitionedRelPruneInfo
  */
 typedef struct PartitionPruneStep
 {
-       pg_node_attr(abstract, no_equal)
+       pg_node_attr(abstract, no_equal, no_query_jumble)
 
        NodeTag         type;
        int                     step_id;
@@ -1570,7 +1570,7 @@ typedef struct PartitionPruneStepCombine
  */
 typedef struct PlanInvalItem
 {
-       pg_node_attr(no_equal)
+       pg_node_attr(no_equal, no_query_jumble)
 
        NodeTag         type;
        int                     cacheId;                /* a syscache ID, see utils/syscache.h */
index 6d740be5c0a47953043f66fa63f763677dc25d89..1be1642d927e2ed77348faa62dd2c107e8c2c1a4 100644 (file)
@@ -982,6 +982,8 @@ typedef struct SubLink
  */
 typedef struct SubPlan
 {
+       pg_node_attr(no_query_jumble)
+
        Expr            xpr;
        /* Fields copied from original SubLink: */
        SubLinkType subLinkType;        /* see above */
@@ -1029,6 +1031,8 @@ typedef struct SubPlan
  */
 typedef struct AlternativeSubPlan
 {
+       pg_node_attr(no_query_jumble)
+
        Expr            xpr;
        List       *subplans;           /* SubPlan(s) with equivalent results */
 } AlternativeSubPlan;
index af9785038d39bcd9e8c22a0bad3b869b8a85fcb1..67f994cb3e2e1538afbfded41b112aee5fe38abd 100644 (file)
@@ -268,7 +268,7 @@ typedef struct RelationData
  */
 typedef struct ForeignKeyCacheInfo
 {
-       pg_node_attr(no_equal, no_read)
+       pg_node_attr(no_equal, no_read, no_query_jumble)
 
        NodeTag         type;
        /* oid of the constraint itself */