Skip to content

Commit 2a507f6

Browse files
committed
Mark more nodes with attribute no_query_jumble
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
1 parent 6ded4a5 commit 2a507f6

File tree

7 files changed

+54
-39
lines changed

7 files changed

+54
-39
lines changed

src/backend/nodes/gen_node_support.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ sub elem
121121
my @no_copy;
122122
# node types we don't want equal support for
123123
my @no_equal;
124-
# node types we don't want jumble support for
124+
# node types we don't want query jumble support for
125125
my @no_query_jumble;
126126
# node types we don't want read support for
127127
my @no_read;
@@ -422,6 +422,8 @@ sub elem
422422
if elem $supertype, @no_equal;
423423
push @no_read, $in_struct
424424
if elem $supertype, @no_read;
425+
push @no_query_jumble, $in_struct
426+
if elem $supertype, @no_query_jumble;
425427
}
426428
}
427429

src/include/nodes/nodes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ typedef enum NodeTag
7777
*
7878
* Node types can be supertypes of other types whether or not they are marked
7979
* abstract: if a node struct appears as the first field of another struct
80-
* type, then it is the supertype of that type. The no_copy, no_equal, and
81-
* no_read node attributes are automatically inherited from the supertype.
82-
* (Notice that nodetag_only does not inherit, so it's not quite equivalent
83-
* to a combination of other attributes.)
80+
* type, then it is the supertype of that type. The no_copy, no_equal,
81+
* no_query_jumble and no_read node attributes are automatically inherited
82+
* from the supertype. (Notice that nodetag_only does not inherit, so it's
83+
* not quite equivalent to a combination of other attributes.)
8484
*
8585
* Valid node field attributes:
8686
*

src/include/nodes/parsenodes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,9 +1728,14 @@ typedef struct TriggerTransition
17281728
*
17291729
* stmt_location/stmt_len identify the portion of the source text string
17301730
* containing this raw statement (useful for multi-statement strings).
1731+
*
1732+
* This is irrelevant for query jumbling, as this is not used in parsed
1733+
* queries.
17311734
*/
17321735
typedef struct RawStmt
17331736
{
1737+
pg_node_attr(no_query_jumble)
1738+
17341739
NodeTag type;
17351740
Node *stmt; /* raw parse tree */
17361741
int stmt_location; /* start location, or -1 if unknown */

src/include/nodes/pathnodes.h

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ typedef enum UpperRelationKind
9494
*/
9595
typedef struct PlannerGlobal
9696
{
97-
pg_node_attr(no_copy_equal, no_read)
97+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
9898

9999
NodeTag type;
100100

@@ -194,7 +194,7 @@ typedef struct PlannerInfo PlannerInfo;
194194

195195
struct PlannerInfo
196196
{
197-
pg_node_attr(no_copy_equal, no_read)
197+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
198198

199199
NodeTag type;
200200

@@ -853,7 +853,7 @@ typedef enum RelOptKind
853853

854854
typedef struct RelOptInfo
855855
{
856-
pg_node_attr(no_copy_equal, no_read)
856+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
857857

858858
NodeTag type;
859859

@@ -1098,7 +1098,7 @@ typedef struct IndexOptInfo IndexOptInfo;
10981098

10991099
struct IndexOptInfo
11001100
{
1101-
pg_node_attr(no_copy_equal, no_read)
1101+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
11021102

11031103
NodeTag type;
11041104

@@ -1208,7 +1208,7 @@ struct IndexOptInfo
12081208
*/
12091209
typedef struct ForeignKeyOptInfo
12101210
{
1211-
pg_node_attr(custom_read_write, no_copy_equal, no_read)
1211+
pg_node_attr(custom_read_write, no_copy_equal, no_read, no_query_jumble)
12121212

12131213
NodeTag type;
12141214

@@ -1258,7 +1258,7 @@ typedef struct ForeignKeyOptInfo
12581258
*/
12591259
typedef struct StatisticExtInfo
12601260
{
1261-
pg_node_attr(no_copy_equal, no_read)
1261+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
12621262

12631263
NodeTag type;
12641264

@@ -1309,7 +1309,7 @@ typedef struct StatisticExtInfo
13091309
*/
13101310
typedef struct JoinDomain
13111311
{
1312-
pg_node_attr(no_copy_equal, no_read)
1312+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
13131313

13141314
NodeTag type;
13151315

@@ -1371,7 +1371,7 @@ typedef struct JoinDomain
13711371
*/
13721372
typedef struct EquivalenceClass
13731373
{
1374-
pg_node_attr(custom_read_write, no_copy_equal, no_read)
1374+
pg_node_attr(custom_read_write, no_copy_equal, no_read, no_query_jumble)
13751375

13761376
NodeTag type;
13771377

@@ -1422,7 +1422,7 @@ typedef struct EquivalenceClass
14221422
*/
14231423
typedef struct EquivalenceMember
14241424
{
1425-
pg_node_attr(no_copy_equal, no_read)
1425+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
14261426

14271427
NodeTag type;
14281428

@@ -1455,7 +1455,7 @@ typedef struct EquivalenceMember
14551455
*/
14561456
typedef struct PathKey
14571457
{
1458-
pg_node_attr(no_read)
1458+
pg_node_attr(no_read, no_query_jumble)
14591459

14601460
NodeTag type;
14611461

@@ -1503,7 +1503,7 @@ typedef enum VolatileFunctionStatus
15031503
*/
15041504
typedef struct PathTarget
15051505
{
1506-
pg_node_attr(no_copy_equal, no_read)
1506+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
15071507

15081508
NodeTag type;
15091509

@@ -1550,7 +1550,7 @@ typedef struct PathTarget
15501550
*/
15511551
typedef struct ParamPathInfo
15521552
{
1553-
pg_node_attr(no_copy_equal, no_read)
1553+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
15541554

15551555
NodeTag type;
15561556

@@ -1596,7 +1596,7 @@ typedef struct ParamPathInfo
15961596
*/
15971597
typedef struct Path
15981598
{
1599-
pg_node_attr(no_copy_equal, no_read)
1599+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
16001600

16011601
NodeTag type;
16021602

@@ -1730,7 +1730,7 @@ typedef struct IndexPath
17301730
*/
17311731
typedef struct IndexClause
17321732
{
1733-
pg_node_attr(no_copy_equal, no_read)
1733+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
17341734

17351735
NodeTag type;
17361736
struct RestrictInfo *rinfo; /* original restriction or join clause */
@@ -2231,7 +2231,7 @@ typedef struct AggPath
22312231

22322232
typedef struct GroupingSetData
22332233
{
2234-
pg_node_attr(no_copy_equal, no_read)
2234+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
22352235

22362236
NodeTag type;
22372237
List *set; /* grouping set as list of sortgrouprefs */
@@ -2240,7 +2240,7 @@ typedef struct GroupingSetData
22402240

22412241
typedef struct RollupData
22422242
{
2243-
pg_node_attr(no_copy_equal, no_read)
2243+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
22442244

22452245
NodeTag type;
22462246
List *groupClause; /* applicable subset of parse->groupClause */
@@ -2509,7 +2509,7 @@ typedef struct LimitPath
25092509

25102510
typedef struct RestrictInfo
25112511
{
2512-
pg_node_attr(no_read)
2512+
pg_node_attr(no_read, no_query_jumble)
25132513

25142514
NodeTag type;
25152515

@@ -2724,6 +2724,8 @@ typedef struct MergeScanSelCache
27242724

27252725
typedef struct PlaceHolderVar
27262726
{
2727+
pg_node_attr(no_query_jumble)
2728+
27272729
Expr xpr;
27282730

27292731
/* the represented expression */
@@ -2825,7 +2827,7 @@ typedef struct SpecialJoinInfo SpecialJoinInfo;
28252827

28262828
struct SpecialJoinInfo
28272829
{
2828-
pg_node_attr(no_read)
2830+
pg_node_attr(no_read, no_query_jumble)
28292831

28302832
NodeTag type;
28312833
Relids min_lefthand; /* base+OJ relids in minimum LHS for join */
@@ -2853,7 +2855,7 @@ struct SpecialJoinInfo
28532855
*/
28542856
typedef struct OuterJoinClauseInfo
28552857
{
2856-
pg_node_attr(no_copy_equal, no_read)
2858+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
28572859

28582860
NodeTag type;
28592861
RestrictInfo *rinfo; /* a mergejoinable outer-join clause */
@@ -2892,6 +2894,8 @@ typedef struct OuterJoinClauseInfo
28922894

28932895
typedef struct AppendRelInfo
28942896
{
2897+
pg_node_attr(no_query_jumble)
2898+
28952899
NodeTag type;
28962900

28972901
/*
@@ -2967,7 +2971,7 @@ typedef struct AppendRelInfo
29672971
*/
29682972
typedef struct RowIdentityVarInfo
29692973
{
2970-
pg_node_attr(no_copy_equal, no_read)
2974+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
29712975

29722976
NodeTag type;
29732977

@@ -3005,7 +3009,7 @@ typedef struct RowIdentityVarInfo
30053009

30063010
typedef struct PlaceHolderInfo
30073011
{
3008-
pg_node_attr(no_read)
3012+
pg_node_attr(no_read, no_query_jumble)
30093013

30103014
NodeTag type;
30113015

@@ -3038,7 +3042,7 @@ typedef struct PlaceHolderInfo
30383042
*/
30393043
typedef struct MinMaxAggInfo
30403044
{
3041-
pg_node_attr(no_copy_equal, no_read)
3045+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
30423046

30433047
NodeTag type;
30443048

@@ -3116,7 +3120,7 @@ typedef struct MinMaxAggInfo
31163120
*/
31173121
typedef struct PlannerParamItem
31183122
{
3119-
pg_node_attr(no_copy_equal, no_read)
3123+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
31203124

31213125
NodeTag type;
31223126

@@ -3296,7 +3300,7 @@ typedef struct JoinCostWorkspace
32963300
*/
32973301
typedef struct AggInfo
32983302
{
3299-
pg_node_attr(no_copy_equal, no_read)
3303+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
33003304

33013305
NodeTag type;
33023306

@@ -3330,7 +3334,7 @@ typedef struct AggInfo
33303334
*/
33313335
typedef struct AggTransInfo
33323336
{
3333-
pg_node_attr(no_copy_equal, no_read)
3337+
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
33343338

33353339
NodeTag type;
33363340

src/include/nodes/plannodes.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*/
4747
typedef struct PlannedStmt
4848
{
49-
pg_node_attr(no_equal)
49+
pg_node_attr(no_equal, no_query_jumble)
5050

5151
NodeTag type;
5252

@@ -122,7 +122,7 @@ typedef struct PlannedStmt
122122
*/
123123
typedef struct Plan
124124
{
125-
pg_node_attr(abstract, no_equal)
125+
pg_node_attr(abstract, no_equal, no_query_jumble)
126126

127127
NodeTag type;
128128

@@ -813,7 +813,7 @@ typedef struct NestLoop
813813

814814
typedef struct NestLoopParam
815815
{
816-
pg_node_attr(no_equal)
816+
pg_node_attr(no_equal, no_query_jumble)
817817

818818
NodeTag type;
819819
int paramno; /* number of the PARAM_EXEC Param to set */
@@ -1377,7 +1377,7 @@ typedef enum RowMarkType
13771377
*/
13781378
typedef struct PlanRowMark
13791379
{
1380-
pg_node_attr(no_equal)
1380+
pg_node_attr(no_equal, no_query_jumble)
13811381

13821382
NodeTag type;
13831383
Index rti; /* range table index of markable relation */
@@ -1425,7 +1425,7 @@ typedef struct PlanRowMark
14251425
*/
14261426
typedef struct PartitionPruneInfo
14271427
{
1428-
pg_node_attr(no_equal)
1428+
pg_node_attr(no_equal, no_query_jumble)
14291429

14301430
NodeTag type;
14311431
Bitmapset *root_parent_relids;
@@ -1452,7 +1452,7 @@ typedef struct PartitionPruneInfo
14521452
*/
14531453
typedef struct PartitionedRelPruneInfo
14541454
{
1455-
pg_node_attr(no_equal)
1455+
pg_node_attr(no_equal, no_query_jumble)
14561456

14571457
NodeTag type;
14581458

@@ -1495,7 +1495,7 @@ typedef struct PartitionedRelPruneInfo
14951495
*/
14961496
typedef struct PartitionPruneStep
14971497
{
1498-
pg_node_attr(abstract, no_equal)
1498+
pg_node_attr(abstract, no_equal, no_query_jumble)
14991499

15001500
NodeTag type;
15011501
int step_id;
@@ -1570,7 +1570,7 @@ typedef struct PartitionPruneStepCombine
15701570
*/
15711571
typedef struct PlanInvalItem
15721572
{
1573-
pg_node_attr(no_equal)
1573+
pg_node_attr(no_equal, no_query_jumble)
15741574

15751575
NodeTag type;
15761576
int cacheId; /* a syscache ID, see utils/syscache.h */

src/include/nodes/primnodes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ typedef struct SubLink
982982
*/
983983
typedef struct SubPlan
984984
{
985+
pg_node_attr(no_query_jumble)
986+
985987
Expr xpr;
986988
/* Fields copied from original SubLink: */
987989
SubLinkType subLinkType; /* see above */
@@ -1029,6 +1031,8 @@ typedef struct SubPlan
10291031
*/
10301032
typedef struct AlternativeSubPlan
10311033
{
1034+
pg_node_attr(no_query_jumble)
1035+
10321036
Expr xpr;
10331037
List *subplans; /* SubPlan(s) with equivalent results */
10341038
} AlternativeSubPlan;

src/include/utils/rel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ typedef struct RelationData
268268
*/
269269
typedef struct ForeignKeyCacheInfo
270270
{
271-
pg_node_attr(no_equal, no_read)
271+
pg_node_attr(no_equal, no_read, no_query_jumble)
272272

273273
NodeTag type;
274274
/* oid of the constraint itself */

0 commit comments

Comments
 (0)