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
talha_pg14_support
Sait Talha Nisanci 2021-08-21 23:03:54 +03:00
parent b1cbfa6610
commit 9f8568c585
1 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,8 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "distributed/pg_version_constants.h"
#include "access/htup_details.h" #include "access/htup_details.h"
#include "access/xact.h" #include "access/xact.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
@ -63,6 +65,9 @@
#include "utils/json.h" #include "utils/json.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/snapmgr.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 */ /* Config variables that enable printing distributed query plans */
@ -1251,10 +1256,17 @@ CitusExplainOneQuery(Query *query, int cursorOptions, IntoClause *into,
/* plan the query */ /* plan the query */
PlannedStmt *plan = pg_plan_query_compat(query, NULL, cursorOptions, params); 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_SET_CURRENT(planduration);
INSTR_TIME_SUBTRACT(planduration, planstart); INSTR_TIME_SUBTRACT(planduration, planstart);
#if PG_VERSION_NUM >= PG_VERSION_13 #if PG_VERSION_NUM >= PG_VERSION_13
/* calc differences of buffer counters. */ /* calc differences of buffer counters. */