On Tue, Feb 07, 2023 at 05:32:07PM -0500, Tom Lane wrote:
> I have just noticed that this patch is generating useless jumbling
> code for node types such as Path nodes and other planner infrastructure
> nodes.  That no doubt contributes to the miserable code coverage rating
> for queryjumblefuncs.*.c, which have enough dead lines to drag down the
> overall rating for all of backend/nodes/.  Shouldn't a little more
> attention have been paid to excluding entire node classes if they can
> never appear in Query?

This one was intentional to let extensions play with jumbling of such
nodes, but perhaps you are right that it makes little sense at this
stage.  If there is an ask for it later, though..  Using
shared_preload_libraries = pg_stat_statements and compute_query_id =
regress shows that numbers go up to 60% for funcs.c and 30% for
switch.c.  Removing nodes like as of the attached brings these numbers
respectively up to 94.5% and 93.5% for a check.  With a check-world, I
measure respectively 96.7% and 96.1% because there is more coverage
for extensions, ALTER SYSTEM and database commands, roughly.

This could also be a file-level policy by enforcing no_query_jumble in
gen_node_support.pl by looking at the header name, still I favor
no_query_jumble to keep all the pg_node_attr() in a single area with
the headers.  Note that the attached includes in 0002 the tweak to
enforce the computation with compute_query_id if you want to test it
yourself and check my numbers.  This is useful IMO as we could detect
missing nodes for all queries (utilities or not), still doing this
change may deserve a separate discussion.  Note that I am not seeing
any "unrecognized node type" in any of the logs for any queries.

As a side note, should we be more aggressive with the tests related to
the jumbling code since it is now in core?  For example, XmlExpr or
MinMaxExpr, which are part of Query nodes that can be jumbled even in
older branches, have zero coverage by default as
coverage.postgresql.org reports, because everything goes through
pg_stat_statements and it includes no queries with such nodes.  My
buildfarm member batta makes sure to stress that no nodes are missing
by overloading pg_stat_statements and compute_query_id = regress in 
the configuration, so no nodes are missing from the computation, still
the coverage could be better across the board.  Expanding the tests of
pg_stat_statements is needed in this area for some time, still could
there be a point in switching compute_query_id = regress so as it is a
synonym of "on" without the EXPLAIN output rather than "auto"?  If the
setting is enforced by pg_regress, the coverage of queryjumble.c would
be so much better, at least..
--
Michael
From 5d8d730e5fc28acdf75e33b00c56c172b400ffe3 Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@paquier.xyz>
Date: Wed, 8 Feb 2023 15:22:28 +0900
Subject: [PATCH 1/2] Mark more nodes with node attribute no_query_jumble

This mostly covers plan and path nodes, which should never be included
in the jumbling because we ignore these in Query nodes.
---
 src/include/nodes/parsenodes.h |   8 +++
 src/include/nodes/pathnodes.h  | 126 ++++++++++++++++++++++++++-------
 src/include/nodes/plannodes.h  | 108 +++++++++++++++++++++++++---
 src/include/nodes/primnodes.h  |   4 ++
 4 files changed, 210 insertions(+), 36 deletions(-)

diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 855da99ec0..29e2940b7d 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1239,6 +1239,8 @@ typedef struct RangeTblEntry
  */
 typedef struct RTEPermissionInfo
 {
+	pg_node_attr(no_query_jumble)
+
 	NodeTag		type;
 
 	Oid			relid;			/* relation OID */
@@ -1596,6 +1598,8 @@ typedef enum CTEMaterialize
 
 typedef struct CTESearchClause
 {
+	pg_node_attr(no_query_jumble)
+
 	NodeTag		type;
 	List	   *search_col_list;
 	bool		search_breadth_first;
@@ -1605,6 +1609,8 @@ typedef struct CTESearchClause
 
 typedef struct CTECycleClause
 {
+	pg_node_attr(no_query_jumble)
+
 	NodeTag		type;
 	List	   *cycle_col_list;
 	char	   *cycle_mark_column;
@@ -1731,6 +1737,8 @@ typedef struct TriggerTransition
  */
 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 */
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
index 0d4b1ec4e4..453dedaec8 100644
--- a/src/include/nodes/pathnodes.h
+++ b/src/include/nodes/pathnodes.h
@@ -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;
 
@@ -1684,6 +1684,8 @@ typedef struct Path
  */
 typedef struct IndexPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	IndexOptInfo *indexinfo;
 	List	   *indexclauses;
@@ -1730,7 +1732,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 */
@@ -1759,6 +1761,8 @@ typedef struct IndexClause
  */
 typedef struct BitmapHeapPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *bitmapqual;		/* IndexPath, BitmapAndPath, BitmapOrPath */
 } BitmapHeapPath;
@@ -1771,6 +1775,8 @@ typedef struct BitmapHeapPath
  */
 typedef struct BitmapAndPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *bitmapquals;	/* IndexPaths and BitmapOrPaths */
 	Selectivity bitmapselectivity;
@@ -1784,6 +1790,8 @@ typedef struct BitmapAndPath
  */
 typedef struct BitmapOrPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *bitmapquals;	/* IndexPaths and BitmapAndPaths */
 	Selectivity bitmapselectivity;
@@ -1798,6 +1806,8 @@ typedef struct BitmapOrPath
  */
 typedef struct TidPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *tidquals;		/* qual(s) involving CTID = something */
 } TidPath;
@@ -1810,6 +1820,8 @@ typedef struct TidPath
  */
 typedef struct TidRangePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *tidrangequals;
 } TidRangePath;
@@ -1824,6 +1836,8 @@ typedef struct TidRangePath
  */
 typedef struct SubqueryScanPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing subquery execution */
 } SubqueryScanPath;
@@ -1840,6 +1854,8 @@ typedef struct SubqueryScanPath
  */
 typedef struct ForeignPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *fdw_outerpath;
 	List	   *fdw_private;
@@ -1868,6 +1884,8 @@ struct CustomPathMethods;
 
 typedef struct CustomPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	uint32		flags;			/* mask of CUSTOMPATH_* flags, see
 								 * nodes/extensible.h */
@@ -1893,6 +1911,8 @@ typedef struct CustomPath
  */
 typedef struct AppendPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *subpaths;		/* list of component Paths */
 	/* Index of first partial path in subpaths; list_length(subpaths) if none */
@@ -1917,6 +1937,8 @@ extern bool is_dummy_rel(RelOptInfo *rel);
  */
 typedef struct MergeAppendPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *subpaths;		/* list of component Paths */
 	Cardinality limit_tuples;	/* hard limit on output tuples, or -1 */
@@ -1931,6 +1953,8 @@ typedef struct MergeAppendPath
  */
 typedef struct GroupResultPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *quals;
 } GroupResultPath;
@@ -1943,6 +1967,8 @@ typedef struct GroupResultPath
  */
 typedef struct MaterialPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;
 } MaterialPath;
@@ -1954,6 +1980,8 @@ typedef struct MaterialPath
  */
 typedef struct MemoizePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* outerpath to cache tuples from */
 	List	   *hash_operators; /* OIDs of hash equality ops for cache keys */
@@ -1989,6 +2017,8 @@ typedef enum UniquePathMethod
 
 typedef struct UniquePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;
 	UniquePathMethod umethod;
@@ -2003,6 +2033,8 @@ typedef struct UniquePath
  */
 typedef struct GatherPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path for each worker */
 	bool		single_copy;	/* don't execute path more than once */
@@ -2015,6 +2047,8 @@ typedef struct GatherPath
  */
 typedef struct GatherMergePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path for each worker */
 	int			num_workers;	/* number of workers sought to help */
@@ -2027,7 +2061,7 @@ typedef struct GatherMergePath
 
 typedef struct JoinPath
 {
-	pg_node_attr(abstract)
+	pg_node_attr(abstract, no_query_jumble)
 
 	Path		path;
 
@@ -2054,6 +2088,8 @@ typedef struct JoinPath
 
 typedef struct NestPath
 {
+	pg_node_attr(no_query_jumble)
+
 	JoinPath	jpath;
 } NestPath;
 
@@ -2094,6 +2130,8 @@ typedef struct NestPath
 
 typedef struct MergePath
 {
+	pg_node_attr(no_query_jumble)
+
 	JoinPath	jpath;
 	List	   *path_mergeclauses;	/* join clauses to be used for merge */
 	List	   *outersortkeys;	/* keys for explicit sort, if any */
@@ -2113,6 +2151,8 @@ typedef struct MergePath
 
 typedef struct HashPath
 {
+	pg_node_attr(no_query_jumble)
+
 	JoinPath	jpath;
 	List	   *path_hashclauses;	/* join clauses used for hashing */
 	int			num_batches;	/* number of batches expected */
@@ -2135,6 +2175,8 @@ typedef struct HashPath
  */
 typedef struct ProjectionPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	bool		dummypp;		/* true if no separate Result is needed */
@@ -2147,6 +2189,8 @@ typedef struct ProjectionPath
  */
 typedef struct ProjectSetPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 } ProjectSetPath;
@@ -2161,6 +2205,8 @@ typedef struct ProjectSetPath
  */
 typedef struct SortPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 } SortPath;
@@ -2173,6 +2219,8 @@ typedef struct SortPath
  */
 typedef struct IncrementalSortPath
 {
+	pg_node_attr(no_query_jumble)
+
 	SortPath	spath;
 	int			nPresortedCols; /* number of presorted columns */
 } IncrementalSortPath;
@@ -2187,6 +2235,8 @@ typedef struct IncrementalSortPath
  */
 typedef struct GroupPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	List	   *groupClause;	/* a list of SortGroupClause's */
@@ -2201,6 +2251,8 @@ typedef struct GroupPath
  */
 typedef struct UpperUniquePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	int			numkeys;		/* number of pathkey columns to compare */
@@ -2215,6 +2267,8 @@ typedef struct UpperUniquePath
  */
 typedef struct AggPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	AggStrategy aggstrategy;	/* basic strategy, see nodes.h */
@@ -2231,7 +2285,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 +2294,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 */
@@ -2257,6 +2311,8 @@ typedef struct RollupData
 
 typedef struct GroupingSetsPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	AggStrategy aggstrategy;	/* basic strategy */
@@ -2270,6 +2326,8 @@ typedef struct GroupingSetsPath
  */
 typedef struct MinMaxAggPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	List	   *mmaggregates;	/* list of MinMaxAggInfo */
 	List	   *quals;			/* HAVING quals, if any */
@@ -2280,6 +2338,8 @@ typedef struct MinMaxAggPath
  */
 typedef struct WindowAggPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	WindowClause *winclause;	/* WindowClause we'll be using */
@@ -2293,6 +2353,8 @@ typedef struct WindowAggPath
  */
 typedef struct SetOpPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	SetOpCmd	cmd;			/* what to do, see nodes.h */
@@ -2308,6 +2370,8 @@ typedef struct SetOpPath
  */
 typedef struct RecursiveUnionPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *leftpath;		/* paths representing input sources */
 	Path	   *rightpath;
@@ -2321,6 +2385,8 @@ typedef struct RecursiveUnionPath
  */
 typedef struct LockRowsPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	List	   *rowMarks;		/* a list of PlanRowMark's */
@@ -2336,6 +2402,8 @@ typedef struct LockRowsPath
  */
 typedef struct ModifyTablePath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* Path producing source data */
 	CmdType		operation;		/* INSERT, UPDATE, DELETE, or MERGE */
@@ -2359,6 +2427,8 @@ typedef struct ModifyTablePath
  */
 typedef struct LimitPath
 {
+	pg_node_attr(no_query_jumble)
+
 	Path		path;
 	Path	   *subpath;		/* path representing input source */
 	Node	   *limitOffset;	/* OFFSET parameter, or NULL if none */
@@ -2509,7 +2579,7 @@ typedef struct LimitPath
 
 typedef struct RestrictInfo
 {
-	pg_node_attr(no_read)
+	pg_node_attr(no_read, no_query_jumble)
 
 	NodeTag		type;
 
@@ -2724,6 +2794,8 @@ typedef struct MergeScanSelCache
 
 typedef struct PlaceHolderVar
 {
+	pg_node_attr(no_query_jumble)
+
 	Expr		xpr;
 
 	/* the represented expression */
@@ -2825,7 +2897,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 +2925,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 +2964,8 @@ typedef struct OuterJoinClauseInfo
 
 typedef struct AppendRelInfo
 {
+	pg_node_attr(no_query_jumble)
+
 	NodeTag		type;
 
 	/*
@@ -2967,7 +3041,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 +3079,7 @@ typedef struct RowIdentityVarInfo
 
 typedef struct PlaceHolderInfo
 {
-	pg_node_attr(no_read)
+	pg_node_attr(no_read, no_query_jumble)
 
 	NodeTag		type;
 
@@ -3038,7 +3112,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 +3190,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 +3370,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 +3404,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;
 
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 4781a9c632..9199c16f6f 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -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;
 
@@ -199,6 +199,8 @@ typedef struct Plan
  */
 typedef struct Result
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	Node	   *resconstantqual;
 } Result;
@@ -211,6 +213,8 @@ typedef struct Result
  */
 typedef struct ProjectSet
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 } ProjectSet;
 
@@ -231,6 +235,8 @@ typedef struct ProjectSet
  */
 typedef struct ModifyTable
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	CmdType		operation;		/* INSERT, UPDATE, DELETE, or MERGE */
 	bool		canSetTag;		/* do we set the command tag/es_processed? */
@@ -265,6 +271,8 @@ struct PartitionPruneInfo;		/* forward reference to struct below */
  */
 typedef struct Append
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	Bitmapset  *apprelids;		/* RTIs of appendrel(s) formed by this node */
 	List	   *appendplans;
@@ -287,6 +295,8 @@ typedef struct Append
  */
 typedef struct MergeAppend
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* RTIs of appendrel(s) formed by this node */
@@ -325,6 +335,8 @@ typedef struct MergeAppend
  */
 typedef struct RecursiveUnion
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* ID of Param representing work table */
@@ -356,6 +368,8 @@ typedef struct RecursiveUnion
  */
 typedef struct BitmapAnd
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	List	   *bitmapplans;
 } BitmapAnd;
@@ -370,6 +384,8 @@ typedef struct BitmapAnd
  */
 typedef struct BitmapOr
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	bool		isshared;
 	List	   *bitmapplans;
@@ -384,7 +400,7 @@ typedef struct BitmapOr
  */
 typedef struct Scan
 {
-	pg_node_attr(abstract)
+	pg_node_attr(abstract, no_query_jumble)
 
 	Plan		plan;
 	Index		scanrelid;		/* relid is index into the range table */
@@ -396,6 +412,8 @@ typedef struct Scan
  */
 typedef struct SeqScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 } SeqScan;
 
@@ -405,6 +423,8 @@ typedef struct SeqScan
  */
 typedef struct SampleScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	/* use struct pointer to avoid including parsenodes.h here */
 	struct TableSampleClause *tablesample;
@@ -449,6 +469,8 @@ typedef struct SampleScan
  */
 typedef struct IndexScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	Oid			indexid;		/* OID of index to scan */
 	List	   *indexqual;		/* list of index quals (usually OpExprs) */
@@ -492,6 +514,8 @@ typedef struct IndexScan
  */
 typedef struct IndexOnlyScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	Oid			indexid;		/* OID of index to scan */
 	List	   *indexqual;		/* list of index quals (usually OpExprs) */
@@ -520,6 +544,8 @@ typedef struct IndexOnlyScan
  */
 typedef struct BitmapIndexScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	Oid			indexid;		/* OID of index to scan */
 	bool		isshared;		/* Create shared bitmap if set */
@@ -538,6 +564,8 @@ typedef struct BitmapIndexScan
  */
 typedef struct BitmapHeapScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	List	   *bitmapqualorig; /* index quals, in standard expr form */
 } BitmapHeapScan;
@@ -552,6 +580,8 @@ typedef struct BitmapHeapScan
  */
 typedef struct TidScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	List	   *tidquals;		/* qual(s) involving CTID = something */
 } TidScan;
@@ -565,6 +595,8 @@ typedef struct TidScan
  */
 typedef struct TidRangeScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	List	   *tidrangequals;	/* qual(s) involving CTID op something */
 } TidRangeScan;
@@ -598,6 +630,8 @@ typedef enum SubqueryScanStatus
 
 typedef struct SubqueryScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	Plan	   *subplan;
 	SubqueryScanStatus scanstatus;
@@ -609,6 +643,8 @@ typedef struct SubqueryScan
  */
 typedef struct FunctionScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	List	   *functions;		/* list of RangeTblFunction nodes */
 	bool		funcordinality; /* WITH ORDINALITY */
@@ -620,6 +656,8 @@ typedef struct FunctionScan
  */
 typedef struct ValuesScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	List	   *values_lists;	/* list of expression lists */
 } ValuesScan;
@@ -630,6 +668,8 @@ typedef struct ValuesScan
  */
 typedef struct TableFuncScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	TableFunc  *tablefunc;		/* table function node */
 } TableFuncScan;
@@ -640,6 +680,8 @@ typedef struct TableFuncScan
  */
 typedef struct CteScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	int			ctePlanId;		/* ID of init SubPlan for CTE */
 	int			cteParam;		/* ID of Param representing CTE output */
@@ -651,6 +693,8 @@ typedef struct CteScan
  */
 typedef struct NamedTuplestoreScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	char	   *enrname;		/* Name given to Ephemeral Named Relation */
 } NamedTuplestoreScan;
@@ -661,6 +705,8 @@ typedef struct NamedTuplestoreScan
  */
 typedef struct WorkTableScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	int			wtParam;		/* ID of Param representing work table */
 } WorkTableScan;
@@ -707,6 +753,8 @@ typedef struct WorkTableScan
  */
 typedef struct ForeignScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	CmdType		operation;		/* SELECT/INSERT/UPDATE/DELETE */
 	Index		resultRelation; /* direct modification target's RT index */
@@ -739,6 +787,8 @@ struct CustomScanMethods;
 
 typedef struct CustomScan
 {
+	pg_node_attr(no_query_jumble)
+
 	Scan		scan;
 	uint32		flags;			/* mask of CUSTOMPATH_* flags, see
 								 * nodes/extensible.h */
@@ -786,7 +836,7 @@ typedef struct CustomScan
  */
 typedef struct Join
 {
-	pg_node_attr(abstract)
+	pg_node_attr(abstract, no_query_jumble)
 
 	Plan		plan;
 	JoinType	jointype;
@@ -807,13 +857,15 @@ typedef struct Join
  */
 typedef struct NestLoop
 {
+	pg_node_attr(no_query_jumble)
+
 	Join		join;
 	List	   *nestParams;		/* list of NestLoopParam nodes */
 } 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 */
@@ -833,6 +885,8 @@ typedef struct NestLoopParam
  */
 typedef struct MergeJoin
 {
+	pg_node_attr(no_query_jumble)
+
 	Join		join;
 
 	/* Can we skip mark/restore calls? */
@@ -862,6 +916,8 @@ typedef struct MergeJoin
  */
 typedef struct HashJoin
 {
+	pg_node_attr(no_query_jumble)
+
 	Join		join;
 	List	   *hashclauses;
 	List	   *hashoperators;
@@ -880,6 +936,8 @@ typedef struct HashJoin
  */
 typedef struct Material
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 } Material;
 
@@ -889,6 +947,8 @@ typedef struct Material
  */
 typedef struct Memoize
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* size of the two arrays below */
@@ -931,6 +991,8 @@ typedef struct Memoize
  */
 typedef struct Sort
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* number of sort-key columns */
@@ -955,6 +1017,8 @@ typedef struct Sort
  */
 typedef struct IncrementalSort
 {
+	pg_node_attr(no_query_jumble)
+
 	Sort		sort;
 	int			nPresortedCols; /* number of presorted columns */
 } IncrementalSort;
@@ -967,6 +1031,8 @@ typedef struct IncrementalSort
  */
 typedef struct Group
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* number of grouping columns */
@@ -996,6 +1062,8 @@ typedef struct Group
  */
 typedef struct Agg
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* basic strategy, see nodes.h */
@@ -1038,6 +1106,8 @@ typedef struct Agg
  */
 typedef struct WindowAgg
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* ID referenced by window functions */
@@ -1112,6 +1182,8 @@ typedef struct WindowAgg
  */
 typedef struct Unique
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* number of columns to check for uniqueness */
@@ -1140,6 +1212,8 @@ typedef struct Unique
  */
 typedef struct Gather
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	int			num_workers;	/* planned number of worker processes */
 	int			rescan_param;	/* ID of Param that signals a rescan, or -1 */
@@ -1155,6 +1229,8 @@ typedef struct Gather
  */
 typedef struct GatherMerge
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* planned number of worker processes */
@@ -1197,6 +1273,8 @@ typedef struct GatherMerge
  */
 typedef struct Hash
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/*
@@ -1217,6 +1295,8 @@ typedef struct Hash
  */
 typedef struct SetOp
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* what to do, see nodes.h */
@@ -1256,6 +1336,8 @@ typedef struct SetOp
  */
 typedef struct LockRows
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 	List	   *rowMarks;		/* a list of PlanRowMark's */
 	int			epqParam;		/* ID of Param for EvalPlanQual re-eval */
@@ -1270,6 +1352,8 @@ typedef struct LockRows
  */
 typedef struct Limit
 {
+	pg_node_attr(no_query_jumble)
+
 	Plan		plan;
 
 	/* OFFSET parameter, or NULL if none */
@@ -1377,7 +1461,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 +1509,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 +1536,7 @@ typedef struct PartitionPruneInfo
  */
 typedef struct PartitionedRelPruneInfo
 {
-	pg_node_attr(no_equal)
+	pg_node_attr(no_equal, no_query_jumble)
 
 	NodeTag		type;
 
@@ -1495,7 +1579,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;
@@ -1530,6 +1614,8 @@ typedef struct PartitionPruneStep
  */
 typedef struct PartitionPruneStepOp
 {
+	pg_node_attr(no_query_jumble)
+
 	PartitionPruneStep step;
 
 	StrategyNumber opstrategy;
@@ -1552,6 +1638,8 @@ typedef enum PartitionPruneCombineOp
 
 typedef struct PartitionPruneStepCombine
 {
+	pg_node_attr(no_query_jumble)
+
 	PartitionPruneStep step;
 
 	PartitionPruneCombineOp combineOp;
@@ -1570,7 +1658,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 */
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 6d740be5c0..1be1642d92 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -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;
-- 
2.39.1

From f7fa4a46c03187d01d1ac3d943aa132dad0a3a52 Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@paquier.xyz>
Date: Wed, 8 Feb 2023 15:42:50 +0900
Subject: [PATCH 2/2] Switch compute_query_id = regress to mean "on" and force
 it in pg_regress

This is just a tweak to for tests with such code paths,
---
 src/include/nodes/queryjumble.h | 2 ++
 src/backend/commands/explain.c  | 2 +-
 src/test/regress/pg_regress.c   | 3 ++-
 doc/src/sgml/config.sgml        | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/include/nodes/queryjumble.h b/src/include/nodes/queryjumble.h
index 204b8f74fd..3aa7d93255 100644
--- a/src/include/nodes/queryjumble.h
+++ b/src/include/nodes/queryjumble.h
@@ -80,6 +80,8 @@ IsQueryIdEnabled(void)
 		return false;
 	if (compute_query_id == COMPUTE_QUERY_ID_ON)
 		return true;
+	if (compute_query_id == COMPUTE_QUERY_ID_REGRESS)
+		return true;
 	return query_id_enabled;
 }
 
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index fbbf28cf06..5aba713348 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -777,7 +777,7 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
 	ExplainPrintSettings(es);
 
 	/*
-	 * COMPUTE_QUERY_ID_REGRESS means COMPUTE_QUERY_ID_AUTO, but we don't show
+	 * COMPUTE_QUERY_ID_REGRESS means COMPUTE_QUERY_ID_ON, but we don't show
 	 * the queryid in any of the EXPLAIN plans to keep stable the results
 	 * generated by regression test suites.
 	 */
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 6cd5998b9d..d3aafa156c 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -1876,8 +1876,9 @@ create_database(const char *dbname)
 					 "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
 					 "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
 					 "ALTER DATABASE \"%s\" SET bytea_output TO 'hex';"
+					 "ALTER DATABASE \"%s\" SET compute_query_id TO 'regress';"
 					 "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
-					 dbname, dbname, dbname, dbname, dbname, dbname);
+					 dbname, dbname, dbname, dbname, dbname, dbname, dbname);
 	psql_end_command(buf, "postgres");
 
 	/*
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index d190be1925..b1bb3435a5 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -8226,7 +8226,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
         <literal>on</literal> (always enabled), <literal>auto</literal>,
         which lets modules such as <xref linkend="pgstatstatements"/>
         automatically enable it, and <literal>regress</literal> which
-        has the same effect as <literal>auto</literal>, except that the
+        has the same effect as <literal>on</literal>, except that the
         query identifier is not shown in the <literal>EXPLAIN</literal> output
         in order to facilitate automated regression testing.
         The default is <literal>auto</literal>.
-- 
2.39.1

Attachment: signature.asc
Description: PGP signature

Reply via email to