From 9f8568c58586e6cf30d4623d4ed2ebe75c478cc9 Mon Sep 17 00:00:00 2001 From: Sait Talha Nisanci Date: Sat, 21 Aug 2021 23:03:54 +0300 Subject: [PATCH] Reset queryId to 0 for Explain queries When queryId is not 0 and verbose is true, the query identifier is emitted to the explain output. This is breaking Postgres outputs. There might be a reason we process postgres tables for explain but ideally if the explain doesn't contain any citus table, we should just let Postgres handle it. Commit on PG that introduced the query identifier in the explain output: 4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b --- src/backend/distributed/planner/multi_explain.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/distributed/planner/multi_explain.c b/src/backend/distributed/planner/multi_explain.c index 0443523e0..326887c02 100644 --- a/src/backend/distributed/planner/multi_explain.c +++ b/src/backend/distributed/planner/multi_explain.c @@ -11,6 +11,8 @@ #include "libpq-fe.h" #include "miscadmin.h" +#include "distributed/pg_version_constants.h" + #include "access/htup_details.h" #include "access/xact.h" #include "catalog/namespace.h" @@ -63,6 +65,9 @@ #include "utils/json.h" #include "utils/lsyscache.h" #include "utils/snapmgr.h" +#if PG_VERSION_NUM >= PG_VERSION_14 +#include "utils/queryjumble.h" +#endif /* Config variables that enable printing distributed query plans */ @@ -1251,10 +1256,17 @@ CitusExplainOneQuery(Query *query, int cursorOptions, IntoClause *into, /* plan the query */ PlannedStmt *plan = pg_plan_query_compat(query, NULL, cursorOptions, params); - +#if PG_VERSION_NUM >= PG_VERSION_14 + if (compute_query_id != COMPUTE_QUERY_ID_ON) { + /* + * We don't want to emit the query identifier in explain output. + * By default queryId is already 0. + */ + plan->queryId = 0; + } +#endif INSTR_TIME_SET_CURRENT(planduration); INSTR_TIME_SUBTRACT(planduration, planstart); - #if PG_VERSION_NUM >= PG_VERSION_13 /* calc differences of buffer counters. */