From 51bc070c098721fd91ae729408365a222c3d1959 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Fri, 10 Feb 2023 11:21:57 +0900
Subject: [PATCH v2 2/2] Switch compute_query_id = regress to mean "on" and
 force it in pg_regress

This is just a tweak to force the tests to go through the query
jumbling.
---
 src/include/nodes/queryjumble.h      | 2 ++
 src/backend/commands/explain.c       | 2 +-
 src/backend/nodes/queryjumblefuncs.c | 2 +-
 src/test/regress/pg_regress.c        | 3 ++-
 doc/src/sgml/config.sgml             | 2 +-
 5 files changed, 7 insertions(+), 4 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/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index d7fd72d70f..4d594106ec 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -257,7 +257,7 @@ _jumbleNode(JumbleState *jstate, Node *node)
 
 		default:
 			/* Only a warning, since we can stumble along anyway */
-			elog(WARNING, "unrecognized node type: %d",
+			elog(ERROR, "unrecognized node type: %d",
 				 (int) nodeTag(expr));
 			break;
 	}
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 8c56b134a8..56f8dac286 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

