Skip to content

Commit

Permalink
Fix Current_user being NULL after reset connection (#2996)
Browse files Browse the repository at this point in the history
Before this commit, if the current session had triggered a Tds Reset Connection then the current_user of the session would be set to NULL instead of the databases' default user. This was happening since we were resetting session_authorization which was initially copied from PG's Discard All function. This is not needed since we have fixed the Database Context being reset in an earlier commit, removing this redundant line of code will maintain the user being set after the "USE DB" execution for DbContextReset.
With this commit we also enable pooling=true for the dotnet framework.

Signed-off-by: Kushaal Shroff <[email protected]>
  • Loading branch information
KushaalShroff authored Oct 1, 2024
1 parent 5c6df44 commit 1b0a48a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ TdsDiscardAll()

/* Closing portals might run user-defined code, so do that first. */
PortalHashTableDeleteAll();
SetPGVariable("session_authorization", NIL, false);
ResetAllOptions();
DropAllPreparedStatements();
Async_UnlistenAll();
Expand Down
3 changes: 3 additions & 0 deletions test/dotnet/ExpectedOutput/2_Successful_reset.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#Q#select db_name();
#D#nvarchar
master
#Q#select current_user;
#D#varchar
dbo
#Q#drop database db1;
1 change: 1 addition & 0 deletions test/dotnet/input/ResetConnection/2_Successful_reset.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
select db_name();
select current_user;
drop database db1;
5 changes: 0 additions & 5 deletions test/dotnet/utils/ConfigSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public static class ConfigSetup
/* Declaring variables required for a Test Run. */
static readonly Dictionary<string, string> Dictionary = LoadConfig();
public static readonly string BblConnectionString = Dictionary["bblConnectionString"];

public static readonly string BCPConnectionString = Dictionary["BCPConnectionString"];
public static readonly string QueryFolder = Dictionary["queryFolder"];
public static readonly string TestName = Dictionary["testName"];
public static readonly bool RunInParallel = bool.Parse(Dictionary["runInParallel"]);
Expand Down Expand Up @@ -47,9 +45,6 @@ public static Dictionary<string, string> LoadConfig()

/* Creating Server Connection String and Query. */
dictionary["bblConnectionString"] = BuildConnectionString(dictionary["babel_URL"], dictionary["babel_port"],
dictionary["babel_databaseName"],
dictionary["babel_user"], dictionary["babel_password"]) + "pooling=false;";
dictionary["BCPConnectionString"] = BuildConnectionString(dictionary["babel_URL"], dictionary["babel_port"],
dictionary["babel_databaseName"],
dictionary["babel_user"], dictionary["babel_password"]);
return dictionary;
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet/utils/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public bool insertBulkCopy(DbConnection bblCnn, DbCommand bblCmd, String sourceT
/* To Enforce Reset Connection. */
reader = bblCmd.ExecuteReader();
using (SqlConnection destinationConnection =
new SqlConnection(ConfigSetup.BCPConnectionString))
new SqlConnection(ConfigSetup.BblConnectionString))
{
destinationConnection.Open();

Expand Down

0 comments on commit 1b0a48a

Please sign in to comment.