Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2a3c84a

Browse files
author
Alexandra Pervushina
committed
Set aqo_show_details and aqo_show_hash to true as default; add additional checks for compute_query_id to not print details in regress mode
1 parent e0f0d38 commit 2a3c84a

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

aqo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ _PG_init(void)
167167
"Show query and node hash on explain.",
168168
"Hash value depend on each instance and is not good to enable it in regression or TAP tests.",
169169
&aqo_show_hash,
170-
false,
170+
true,
171171
PGC_USERSET,
172172
0,
173173
NULL,
@@ -180,7 +180,7 @@ _PG_init(void)
180180
"Show AQO state on a query.",
181181
NULL,
182182
&aqo_show_details,
183-
false,
183+
true,
184184
PGC_USERSET,
185185
0,
186186
NULL,

postprocessing.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ should_learn(PlanState *ps, AQOPlanNode *node, aqo_obj_stat *ctx,
314314
if (ctx->learn && nrows > predicted * 1.2)
315315
{
316316
/* This node s*/
317-
if (aqo_show_details)
317+
if (aqo_show_details && compute_query_id != COMPUTE_QUERY_ID_REGRESS)
318318
elog(NOTICE,
319319
"[AQO] Learn on a plan node ("UINT64_FORMAT", %d), "
320320
"predicted rows: %.0lf, updated prediction: %.0lf",
@@ -330,7 +330,8 @@ should_learn(PlanState *ps, AQOPlanNode *node, aqo_obj_stat *ctx,
330330
{
331331
/* This is much more reliable data. So we can correct our prediction. */
332332
if (ctx->learn && aqo_show_details &&
333-
fabs(nrows - predicted) / predicted > 0.2)
333+
fabs(nrows - predicted) / predicted > 0.2 &&
334+
compute_query_id != COMPUTE_QUERY_ID_REGRESS)
334335
elog(NOTICE,
335336
"[AQO] Learn on a finished plan node ("UINT64_FORMAT", %d), "
336337
"predicted rows: %.0lf, updated prediction: %.0lf",
@@ -985,7 +986,7 @@ print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
985986
(*aqo_ExplainOnePlan_next)(plannedstmt, into, es, queryString,
986987
params, planduration, queryEnv);
987988

988-
if (IsQueryDisabled() || !aqo_show_details)
989+
if (IsQueryDisabled() || !aqo_show_details || compute_query_id == COMPUTE_QUERY_ID_REGRESS)
989990
return;
990991

991992
/* Report to user about aqo state only in verbose mode */
@@ -1022,7 +1023,7 @@ print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
10221023
*/
10231024
if (aqo_mode != AQO_MODE_DISABLED || force_collect_stat)
10241025
{
1025-
if (aqo_show_hash)
1026+
if (aqo_show_hash && compute_query_id != COMPUTE_QUERY_ID_REGRESS)
10261027
ExplainPropertyInteger("Query hash", NULL,
10271028
query_context.query_hash, es);
10281029
ExplainPropertyInteger("JOINS", NULL, njoins, es);
@@ -1046,7 +1047,7 @@ print_node_explain(ExplainState *es, PlanState *ps, Plan *plan)
10461047
if ((aqo_node = get_aqo_plan_node(plan, false)) == NULL)
10471048
return;
10481049

1049-
if (!aqo_show_details || !ps)
1050+
if (!aqo_show_details || !ps || compute_query_id == COMPUTE_QUERY_ID_REGRESS)
10501051
goto explain_end;
10511052

10521053
if (!ps->instrument)
@@ -1092,7 +1093,7 @@ print_node_explain(ExplainState *es, PlanState *ps, Plan *plan)
10921093

10931094
explain_end:
10941095
/* XXX: Do we really have situations when the plan is a NULL pointer? */
1095-
if (plan && aqo_show_hash)
1096+
if (plan && aqo_show_hash && compute_query_id != COMPUTE_QUERY_ID_REGRESS)
10961097
appendStringInfo(es->str, ", fss=%d", aqo_node->fss);
10971098
}
10981099

sql/aqo_CVE-2020-14350.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
SET client_min_messages = 'warning';
77
DROP ROLE IF EXISTS regress_hacker;
88
SET client_min_messages = 'notice';
9+
SET compute_query_id = on;
910

1011
CREATE ROLE regress_hacker LOGIN;
1112

sql/aqo_controlled.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CREATE EXTENSION IF NOT EXISTS aqo;
22
SELECT true AS success FROM aqo_reset();
3+
SET compute_query_id = on;
34

45
CREATE TABLE aqo_test0(a int, b int, c int, d int);
56
WITH RECURSIVE t(a, b, c, d)

sql/aqo_disabled.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-- previous pass (repeated installcheck as an example).
33
CREATE EXTENSION IF NOT EXISTS aqo;
44
SELECT true AS success FROM aqo_reset();
5+
SET compute_query_id = on;
56

67
CREATE TABLE aqo_test0(a int, b int, c int, d int);
78
WITH RECURSIVE t(a, b, c, d)

sql/aqo_fdw.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
CREATE EXTENSION IF NOT EXISTS aqo;
88
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
99
SELECT true AS success FROM aqo_reset();
10+
SET compute_query_id = on;
1011

1112
SET aqo.mode = 'learn';
1213
SET aqo.show_details = 'true'; -- show AQO info for each node and entire query.

0 commit comments

Comments
 (0)