Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Tanzeel Khan <[email protected]>
  • Loading branch information
tanscorpio7 committed Jan 13, 2025
1 parent 276406a commit a5a34b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/iterative_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 6 additions & 5 deletions contrib/babelfishpg_tsql/src/procedures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit a5a34b2

Please sign in to comment.