From d17cf0f2e6fbab988f2ac014f9f55b904c92ed6e Mon Sep 17 00:00:00 2001 From: "Kushaalshroff1234@gmail.com" Date: Mon, 28 Oct 2024 14:45:14 +0000 Subject: [PATCH] fix show_plan gucs --- contrib/babelfishpg_tsql/src/pl_exec-2.c | 11 +++++++++++ contrib/babelfishpg_tsql/src/session.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/contrib/babelfishpg_tsql/src/pl_exec-2.c b/contrib/babelfishpg_tsql/src/pl_exec-2.c index 7e3583dc9b..5498767a94 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec-2.c +++ b/contrib/babelfishpg_tsql/src/pl_exec-2.c @@ -725,6 +725,17 @@ exec_stmt_exec(PLtsql_execstate *estate, PLtsql_stmt_exec *stmt) else estate->schema_name = NULL; + /* + * We need to disable the explain gucs incase of sp_reset_connection + * execution otherwise we will get explain output for it which is + * not intended. + */ + if (strcmp(stmt->proc_name, "sp_reset_connection") == 0) + { + pltsql_explain_only = false; + pltsql_explain_analyze = false; + } + /* PG_TRY to ensure we clear the plan link, if needed, on failure */ PG_TRY(); { diff --git a/contrib/babelfishpg_tsql/src/session.c b/contrib/babelfishpg_tsql/src/session.c index e2c5335086..660138d3d4 100644 --- a/contrib/babelfishpg_tsql/src/session.c +++ b/contrib/babelfishpg_tsql/src/session.c @@ -14,6 +14,7 @@ #include "dbcmds.h" #include "multidb.h" #include "session.h" +#include "pl_explain.h" #include "pltsql.h" #include "guc.h" #include "storage/shm_toc.h" @@ -202,6 +203,8 @@ reset_session_properties(void) { reset_cached_batch(); reset_cached_cursor(); + pltsql_explain_only = false; + pltsql_explain_analyze = false; } void