diff --git a/contrib/babelfishpg_tsql/src/iterative_exec.c b/contrib/babelfishpg_tsql/src/iterative_exec.c index c9ad63fcc8..e043a68d6b 100644 --- a/contrib/babelfishpg_tsql/src/iterative_exec.c +++ b/contrib/babelfishpg_tsql/src/iterative_exec.c @@ -2201,7 +2201,7 @@ set_search_path_for_pltsql_stmt(PLtsql_stmt *stmt) char *cur_dbname; char *new_search_path = NULL; - if (!IS_TDS_CONN()) + if (!IS_TDS_CONN() || IsInParallelMode()) return; cur_dbname = get_cur_db_name(); diff --git a/contrib/babelfishpg_tsql/src/procedures.c b/contrib/babelfishpg_tsql/src/procedures.c index 21a8e0435a..e6c8ef8abb 100644 --- a/contrib/babelfishpg_tsql/src/procedures.c +++ b/contrib/babelfishpg_tsql/src/procedures.c @@ -1855,9 +1855,10 @@ sp_execute_postgresql(PG_FUNCTION_ARGS) PlannedStmt *wrapper; const char *saved_dialect = GetConfigOption("babelfishpg_tsql.sql_dialect", true, true); Oid current_user_id = GetUserId(); - const char *saved_path = pstrdup(GetConfigOption("search_path", true, true)); const char *new_path = "public, \"$user\", sys, pg_catalog"; + int save_nestlevel; + save_nestlevel = NewGUCNestLevel(); PG_TRY(); { set_config_option("babelfishpg_tsql.sql_dialect", "postgres", @@ -1953,8 +1954,9 @@ sp_execute_postgresql(PG_FUNCTION_ARGS) } SetCurrentRoleId(GetSessionUserId(), false); - SetConfigOption("search_path", new_path, - PGC_SUSET, PGC_S_SESSION); + set_config_option("search_path", new_path, + PGC_USERSET, PGC_S_SESSION, + GUC_ACTION_SAVE, true, 0, false); foreach(lc, crstmt->options) { @@ -2065,11 +2067,10 @@ sp_execute_postgresql(PG_FUNCTION_ARGS) set_config_option("babelfishpg_tsql.sql_dialect", saved_dialect, GUC_CONTEXT_CONFIG, PGC_S_SESSION, GUC_ACTION_SAVE, true, 0, false); - SetConfigOption("search_path", saved_path, - PGC_SUSET, PGC_S_SESSION); SetCurrentRoleId(current_user_id, false); } + AtEOXact_GUC(false, save_nestlevel); PG_END_TRY(); PG_RETURN_VOID(); }