From c5611795d7461ccc6d9a5ff14dd9b1fc10a55f94 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Wed, 14 Aug 2024 10:21:14 +0000 Subject: [PATCH 01/15] Add support for sys.sp_reset_connection stored procedure --- .../babelfishpg_tds/src/backend/tds/tds_srv.c | 1 + .../src/backend/tds/tdsprotocol.c | 12 ++++++++- .../src/include/tds_protocol.h | 1 + .../babelfishpg_tsql/sql/sys_procedures.sql | 4 +++ contrib/babelfishpg_tsql/src/pltsql.h | 3 ++- contrib/babelfishpg_tsql/src/procedures.c | 12 +++++++++ .../expected/Test-sp_reset_connection.out | 25 +++++++++++++++++++ .../Test-sp_reset_connection.sql | 12 +++++++++ .../ExpectedOutput/TestStoredProcedure.out | 10 ++++++++ .../input/Storedproc/TestStoredProcedure.txt | 10 +++++++- 10 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 test/JDBC/expected/Test-sp_reset_connection.out create mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql diff --git a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c index 63ce388c47..9bf5137aff 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tds_srv.c @@ -202,6 +202,7 @@ pe_tds_init(void) pltsql_plugin_handler_ptr->set_context_info = &set_tds_context_info; pltsql_plugin_handler_ptr->get_datum_from_byte_ptr = &TdsBytePtrToDatum; pltsql_plugin_handler_ptr->get_datum_from_date_time_struct = &TdsDateTimeTypeToDatum; + pltsql_plugin_handler_ptr->set_reset_tds_connection_flag = &SetResetTDSConnectionFlag; invalidate_stat_table_hook = invalidate_stat_table; guc_newval_hook = TdsSetGucStatVariable; diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 038c244dda..5d1fd66ce6 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -73,6 +73,7 @@ typedef ResetConnectionData *ResetConnection; TdsRequestCtrlData *TdsRequestCtrl = NULL; ResetConnection resetCon = NULL; +static bool resetTdsConnectionFlag = false; /* Local functions */ static void ResetTDSConnection(void); @@ -162,6 +163,14 @@ ResetTDSConnection(void) TdsSendEnvChange(TDS_ENVID_RESETCON, NULL, NULL); } +/* + * SetResetTDSConnectionFlag - Sets reset tds connection flag + */ +void SetResetTDSConnectionFlag() +{ + resetTdsConnectionFlag = true; +} + /* * GetTDSRequest - Fetch and parse a TDS packet and generate a TDS request that * can be processed later. @@ -261,7 +270,7 @@ GetTDSRequest(bool *resetProtocol) * memory context before exit so that we can process the request * later. */ - if (status & TDS_PACKET_HEADER_STATUS_RESETCON) + if ((status & TDS_PACKET_HEADER_STATUS_RESETCON) || resetTdsConnectionFlag == true) { MemoryContextSwitchTo(TopMemoryContext); @@ -276,6 +285,7 @@ GetTDSRequest(bool *resetProtocol) ResetTDSConnection(); TdsErrorContext->err_text = "Fetching TDS Request"; *resetProtocol = true; + resetTdsConnectionFlag = false; return NULL; } diff --git a/contrib/babelfishpg_tds/src/include/tds_protocol.h b/contrib/babelfishpg_tds/src/include/tds_protocol.h index a661cc181f..4018a65382 100644 --- a/contrib/babelfishpg_tds/src/include/tds_protocol.h +++ b/contrib/babelfishpg_tds/src/include/tds_protocol.h @@ -77,5 +77,6 @@ typedef struct } TdsRequestCtrlData; extern TdsRequestCtrlData *TdsRequestCtrl; +extern void SetResetTDSConnectionFlag(void); #endif /* TDS_PROTOCOL_H */ diff --git a/contrib/babelfishpg_tsql/sql/sys_procedures.sql b/contrib/babelfishpg_tsql/sql/sys_procedures.sql index 51b03784df..4bdbbf4bb5 100644 --- a/contrib/babelfishpg_tsql/sql/sys_procedures.sql +++ b/contrib/babelfishpg_tsql/sql/sys_procedures.sql @@ -329,3 +329,7 @@ GRANT EXECUTE ON PROCEDURE sys.sp_dropextendedproperty TO PUBLIC; CREATE OR REPLACE PROCEDURE sys.sp_enum_oledb_providers() AS 'babelfishpg_tsql', 'sp_enum_oledb_providers_internal' LANGUAGE C; GRANT EXECUTE on PROCEDURE sys.sp_enum_oledb_providers() TO PUBLIC; + +CREATE OR REPLACE PROCEDURE sys.sp_reset_connection() +AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C; +GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC; diff --git a/contrib/babelfishpg_tsql/src/pltsql.h b/contrib/babelfishpg_tsql/src/pltsql.h index 57b90ab097..42f5b4b53d 100644 --- a/contrib/babelfishpg_tsql/src/pltsql.h +++ b/contrib/babelfishpg_tsql/src/pltsql.h @@ -1792,6 +1792,8 @@ typedef struct PLtsql_protocol_plugin char *(*get_physical_schema_name) (char *db_name, const char *schema_name); + void (*set_reset_tds_connection_flag) (); + /* Session level GUCs */ bool quoted_identifier; bool arithabort; @@ -1805,7 +1807,6 @@ typedef struct PLtsql_protocol_plugin int datefirst; int lock_timeout; const char *language; - } PLtsql_protocol_plugin; /* diff --git a/contrib/babelfishpg_tsql/src/procedures.c b/contrib/babelfishpg_tsql/src/procedures.c index b4908115e8..eedbc854a2 100644 --- a/contrib/babelfishpg_tsql/src/procedures.c +++ b/contrib/babelfishpg_tsql/src/procedures.c @@ -78,6 +78,7 @@ PG_FUNCTION_INFO_V1(sp_babelfish_volatility); PG_FUNCTION_INFO_V1(sp_rename_internal); PG_FUNCTION_INFO_V1(sp_execute_postgresql); PG_FUNCTION_INFO_V1(sp_enum_oledb_providers_internal); +PG_FUNCTION_INFO_V1(sp_reset_connection_internal); PG_FUNCTION_INFO_V1(sp_renamedb_internal); extern void delete_cached_batch(int handle); @@ -4198,3 +4199,14 @@ sp_enum_oledb_providers_internal(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } + +Datum +sp_reset_connection_internal(PG_FUNCTION_ARGS) +{ + if (*pltsql_protocol_plugin_ptr) + { + (*pltsql_protocol_plugin_ptr)->set_reset_tds_connection_flag(); + } + + PG_RETURN_VOID(); +} diff --git a/test/JDBC/expected/Test-sp_reset_connection.out b/test/JDBC/expected/Test-sp_reset_connection.out new file mode 100644 index 0000000000..b0914bac68 --- /dev/null +++ b/test/JDBC/expected/Test-sp_reset_connection.out @@ -0,0 +1,25 @@ +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +GO +~~ROW COUNT: 3~~ + + +SELECT * from #babel_temp_table +GO +~~START~~ +int#!#int +1#!#100 +2#!#200 +3#!#300 +~~END~~ + + +EXEC sys.sp_reset_connection +GO + +SELECT * from #babel_temp_table +Go +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: relation "#babel_temp_table" does not exist)~~ + diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql new file mode 100644 index 0000000000..0775618675 --- /dev/null +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql @@ -0,0 +1,12 @@ +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +GO + +SELECT * from #babel_temp_table +GO + +EXEC sys.sp_reset_connection +GO + +SELECT * from #babel_temp_table +Go diff --git a/test/dotnet/ExpectedOutput/TestStoredProcedure.out b/test/dotnet/ExpectedOutput/TestStoredProcedure.out index dc9aaeb219..a068498ca7 100644 --- a/test/dotnet/ExpectedOutput/TestStoredProcedure.out +++ b/test/dotnet/ExpectedOutput/TestStoredProcedure.out @@ -582,3 +582,13 @@ Int32 #Q#DROP PROCEDURE sp_test25 +#Q#CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +#Q#INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +#Q#SELECT * from #babel_temp_table +#D#int#!#int +1#!#100 +2#!#200 +3#!#300 +#Q#sys.sp_reset_connection +#Q#SELECT * from #babel_temp_table +#E#relation "#babel_temp_table" does not exist diff --git a/test/dotnet/input/Storedproc/TestStoredProcedure.txt b/test/dotnet/input/Storedproc/TestStoredProcedure.txt index 89565031db..759dff251b 100644 --- a/test/dotnet/input/Storedproc/TestStoredProcedure.txt +++ b/test/dotnet/input/Storedproc/TestStoredProcedure.txt @@ -271,4 +271,12 @@ storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|output#!#i storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|inputoutput#!#int|-|c|-|10|-|input#!#int|-|d|-|10|-|output DROP PROCEDURE sp_test25 -# Test (24): End \ No newline at end of file +# Test (24): End + +# Test (25): Test sys.sp_reset_connection stored procedure +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +SELECT * from #babel_temp_table +storedproc#!#prep#!#sys.sp_reset_connection#!# +SELECT * from #babel_temp_table +# Test (25): End \ No newline at end of file From 7b7a8ea68a77e0666dd2037da4fb0d7d933547f5 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Tue, 20 Aug 2024 09:58:41 +0000 Subject: [PATCH 02/15] Update upgrade path sql to incorporate sys.sp_reset_connection stored procedure --- .../sql/upgrades/babelfishpg_tsql--4.3.0--4.4.0.sql | 4 ++++ test/JDBC/upgrade/15_9/schedule | 1 + 2 files changed, 5 insertions(+) diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.3.0--4.4.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.3.0--4.4.0.sql index 1f6442ae19..3824c823c5 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.3.0--4.4.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.3.0--4.4.0.sql @@ -12,6 +12,10 @@ SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false) */ +CREATE OR REPLACE PROCEDURE sys.sp_reset_connection() +AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C; +GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC; + -- After upgrade, always run analyze for all babelfish catalogs. CALL sys.analyze_babelfish_catalogs(); diff --git a/test/JDBC/upgrade/15_9/schedule b/test/JDBC/upgrade/15_9/schedule index 602263ca06..5114b291d8 100644 --- a/test/JDBC/upgrade/15_9/schedule +++ b/test/JDBC/upgrade/15_9/schedule @@ -443,6 +443,7 @@ Test-sp_helpsrvrolemember Test-sp_helpuser Test-sp_rename Test-sp_rename-dep +Test-sp_reset_connection Test-sp_set_session_context Test-sp_set_session_context-dep TestSQLVariant From 4ea70d81d4fbf7568763e868998eb34f59e578f5 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Tue, 20 Aug 2024 13:41:16 +0000 Subject: [PATCH 03/15] Add Test-sp_reset_connection to upgrade tests --- test/JDBC/upgrade/15_9/schedule | 1 - 1 file changed, 1 deletion(-) diff --git a/test/JDBC/upgrade/15_9/schedule b/test/JDBC/upgrade/15_9/schedule index 5114b291d8..602263ca06 100644 --- a/test/JDBC/upgrade/15_9/schedule +++ b/test/JDBC/upgrade/15_9/schedule @@ -443,7 +443,6 @@ Test-sp_helpsrvrolemember Test-sp_helpuser Test-sp_rename Test-sp_rename-dep -Test-sp_reset_connection Test-sp_set_session_context Test-sp_set_session_context-dep TestSQLVariant From b68575c2a45a295b228549902ff082f70b6042aa Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Wed, 21 Aug 2024 07:32:14 +0000 Subject: [PATCH 04/15] Add upgrade test for sp_reset_connection --- .../storedProcedures/Test-sp_reset_connection-vu-cleanup.sql | 2 ++ .../storedProcedures/Test-sp_reset_connection-vu-prepare.sql | 3 +++ ...t_connection.sql => Test-sp_reset_connection-vu-verify.sql} | 0 3 files changed, 5 insertions(+) create mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql create mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql rename test/JDBC/input/storedProcedures/{Test-sp_reset_connection.sql => Test-sp_reset_connection-vu-verify.sql} (100%) diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql new file mode 100644 index 0000000000..8a243b5722 --- /dev/null +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql @@ -0,0 +1,2 @@ +DROP PROC sys.sp_reset_connection +GO \ No newline at end of file diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql new file mode 100644 index 0000000000..5505671d8b --- /dev/null +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql @@ -0,0 +1,3 @@ +CREATE OR REPLACE PROCEDURE sys.sp_reset_connection() +AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C; +GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC; \ No newline at end of file diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql similarity index 100% rename from test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql rename to test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql From 1d4a9fb6602b2eb9d778c317c4411bcb2c26c9df Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Wed, 21 Aug 2024 08:26:16 +0000 Subject: [PATCH 05/15] Added upgrade test for sp_reset_connection --- .../expected/Test-sp_reset_connection-vu-cleanup.out | 2 ++ .../expected/Test-sp_reset_connection-vu-prepare.out | 6 ++++++ ...ection.out => Test-sp_reset_connection-vu-verify.out} | 0 .../Test-sp_reset_connection-vu-cleanup.sql | 4 ++-- .../Test-sp_reset_connection-vu-prepare.sql | 9 ++++++--- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out create mode 100644 test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out rename test/JDBC/expected/{Test-sp_reset_connection.out => Test-sp_reset_connection-vu-verify.out} (100%) diff --git a/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out b/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out new file mode 100644 index 0000000000..0b0ff37786 --- /dev/null +++ b/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out @@ -0,0 +1,2 @@ +DROP PROC test_sp_reset_connection_proc +GO diff --git a/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out b/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out new file mode 100644 index 0000000000..c011a69cfd --- /dev/null +++ b/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out @@ -0,0 +1,6 @@ +CREATE PROCEDURE test_sp_reset_connection_proc +AS +BEGIN + EXEC sys.sp_reset_connection +END +GO diff --git a/test/JDBC/expected/Test-sp_reset_connection.out b/test/JDBC/expected/Test-sp_reset_connection-vu-verify.out similarity index 100% rename from test/JDBC/expected/Test-sp_reset_connection.out rename to test/JDBC/expected/Test-sp_reset_connection-vu-verify.out diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql index 8a243b5722..0b0ff37786 100644 --- a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql @@ -1,2 +1,2 @@ -DROP PROC sys.sp_reset_connection -GO \ No newline at end of file +DROP PROC test_sp_reset_connection_proc +GO diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql index 5505671d8b..c011a69cfd 100644 --- a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql @@ -1,3 +1,6 @@ -CREATE OR REPLACE PROCEDURE sys.sp_reset_connection() -AS 'babelfishpg_tsql', 'sp_reset_connection_internal' LANGUAGE C; -GRANT EXECUTE ON PROCEDURE sys.sp_reset_connection() TO PUBLIC; \ No newline at end of file +CREATE PROCEDURE test_sp_reset_connection_proc +AS +BEGIN + EXEC sys.sp_reset_connection +END +GO From d92fcd8df653cdefa8fa725dbd978a2acd580a21 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Wed, 21 Aug 2024 09:32:23 +0000 Subject: [PATCH 06/15] Add upgrade test for sp_reset_connection --- test/JDBC/upgrade/latest/schedule | 1 + 1 file changed, 1 insertion(+) diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index d8656e5aca..1cb6b34875 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -450,6 +450,7 @@ Test-sp_helpsrvrolemember Test-sp_helpuser Test-sp_rename Test-sp_rename-dep +Test-sp_reset_connection Test-sp_set_session_context Test-sp_set_session_context-dep TestSQLVariant From 3acb08d1f92876eafeef1745792cbd38f0ae008a Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Thu, 19 Sep 2024 04:24:16 +0000 Subject: [PATCH 07/15] Add sp_reset_connection tests --- .../src/backend/tds/tdsprotocol.c | 15 +++++++++---- .../ExpectedOutput/TestSpResetConnection.out | 21 +++++++++++++++++++ .../ExpectedOutput/TestStoredProcedure.out | 10 --------- .../Storedproc/TestSpResetConnection.txt | 19 +++++++++++++++++ .../input/Storedproc/TestStoredProcedure.txt | 11 +--------- 5 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 test/dotnet/ExpectedOutput/TestSpResetConnection.out create mode 100644 test/dotnet/input/Storedproc/TestSpResetConnection.txt diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 5d1fd66ce6..44e280d3d4 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -154,13 +154,20 @@ ResetTDSConnection(void) TdsProtocolInit(); TdsResetCache(); TdsResponseReset(); - SetConfigOption("default_transaction_isolation", isolationOld, - PGC_BACKEND, PGC_S_CLIENT); + /* Retore previous isolation level when not called by sys.sp_reset_connection */ + if (!resetTdsConnectionFlag) + { + SetConfigOption("default_transaction_isolation", isolationOld, + PGC_BACKEND, PGC_S_CLIENT); + } tvp_lookup_list = NIL; - /* send an environement change token */ - TdsSendEnvChange(TDS_ENVID_RESETCON, NULL, NULL); + /* send an environement change token is its not called via sys.sp_reset_connection procedure */ + if (!resetTdsConnectionFlag) + { + TdsSendEnvChange(TDS_ENVID_RESETCON, NULL, NULL); + } } /* diff --git a/test/dotnet/ExpectedOutput/TestSpResetConnection.out b/test/dotnet/ExpectedOutput/TestSpResetConnection.out new file mode 100644 index 0000000000..8b1fea3c11 --- /dev/null +++ b/test/dotnet/ExpectedOutput/TestSpResetConnection.out @@ -0,0 +1,21 @@ +#Q#CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +#Q#INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +#Q#SELECT * from #babel_temp_table +#D#int#!#int +1#!#100 +2#!#200 +3#!#300 +#Q#sys.sp_reset_connection +#Q#SELECT * from #babel_temp_table +#E#relation "#babel_temp_table" does not exist +#Q#DROP TABLE IF EXISTS babel_test_sp_reset_table; +#Q#CREATE TABLE babel_test_sp_reset_table (ID INT identity(1,1), Data INT); +#Q#INSERT INTO babel_test_sp_reset_table (Data) VALUES (100); +#Q#INSERT INTO babel_test_sp_reset_table (Data) VALUES (200); +#Q#sys.sp_reset_connection +#Q#SELECT * FROM babel_test_sp_reset_table; +#D#int#!#int +1#!#100 +#Q#SELECT * FROM babel_test_sp_reset_table; +#D#int#!#int +1#!#100 diff --git a/test/dotnet/ExpectedOutput/TestStoredProcedure.out b/test/dotnet/ExpectedOutput/TestStoredProcedure.out index a068498ca7..dc9aaeb219 100644 --- a/test/dotnet/ExpectedOutput/TestStoredProcedure.out +++ b/test/dotnet/ExpectedOutput/TestStoredProcedure.out @@ -582,13 +582,3 @@ Int32 #Q#DROP PROCEDURE sp_test25 -#Q#CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) -#Q#INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) -#Q#SELECT * from #babel_temp_table -#D#int#!#int -1#!#100 -2#!#200 -3#!#300 -#Q#sys.sp_reset_connection -#Q#SELECT * from #babel_temp_table -#E#relation "#babel_temp_table" does not exist diff --git a/test/dotnet/input/Storedproc/TestSpResetConnection.txt b/test/dotnet/input/Storedproc/TestSpResetConnection.txt new file mode 100644 index 0000000000..8dc26536c1 --- /dev/null +++ b/test/dotnet/input/Storedproc/TestSpResetConnection.txt @@ -0,0 +1,19 @@ +# Test (1): Test sys.sp_reset_connection stored procedure +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +SELECT * from #babel_temp_table +storedproc#!#prep#!#sys.sp_reset_connection#!# +SELECT * from #babel_temp_table +# Test (1): End + +# Test (2): +DROP TABLE IF EXISTS babel_test_sp_reset_table; +CREATE TABLE babel_test_sp_reset_table (ID INT identity(1,1), Data INT); +INSERT INTO babel_test_sp_reset_table (Data) VALUES (100); +txn#!#BEGIN +INSERT INTO babel_test_sp_reset_table (Data) VALUES (200); +storedproc#!#prep#!#sys.sp_reset_connection#!# +SELECT * FROM babel_test_sp_reset_table; +#txn#!#COMMIT +SELECT * FROM babel_test_sp_reset_table; +# Test (2): End \ No newline at end of file diff --git a/test/dotnet/input/Storedproc/TestStoredProcedure.txt b/test/dotnet/input/Storedproc/TestStoredProcedure.txt index 759dff251b..299da0d394 100644 --- a/test/dotnet/input/Storedproc/TestStoredProcedure.txt +++ b/test/dotnet/input/Storedproc/TestStoredProcedure.txt @@ -270,13 +270,4 @@ storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|output#!#i storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|output#!#int|-|c|-|10|-|input#!#int|-|d|-|10|-|inputoutput storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|inputoutput#!#int|-|c|-|10|-|input#!#int|-|d|-|10|-|output -DROP PROCEDURE sp_test25 -# Test (24): End - -# Test (25): Test sys.sp_reset_connection stored procedure -CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) -INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) -SELECT * from #babel_temp_table -storedproc#!#prep#!#sys.sp_reset_connection#!# -SELECT * from #babel_temp_table -# Test (25): End \ No newline at end of file +DROP PROCEDURE sp_test25 \ No newline at end of file From f8a0f7988511a001919e7380ecd8d4ecd6741054 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Thu, 19 Sep 2024 08:29:33 +0000 Subject: [PATCH 08/15] Fix tds protocol.c --- contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 44e280d3d4..5afc642afa 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -277,7 +277,7 @@ GetTDSRequest(bool *resetProtocol) * memory context before exit so that we can process the request * later. */ - if ((status & TDS_PACKET_HEADER_STATUS_RESETCON) || resetTdsConnectionFlag == true) + if ((status & TDS_PACKET_HEADER_STATUS_RESETCON)) { MemoryContextSwitchTo(TopMemoryContext); @@ -292,7 +292,6 @@ GetTDSRequest(bool *resetProtocol) ResetTDSConnection(); TdsErrorContext->err_text = "Fetching TDS Request"; *resetProtocol = true; - resetTdsConnectionFlag = false; return NULL; } @@ -690,6 +689,12 @@ TdsSocketBackend(void) /* Ready to fetch the next request */ TdsRequestCtrl->phase = TDS_REQUEST_PHASE_FETCH; + if (resetTdsConnectionFlag) + { + ResetTDSConnection(); + resetTdsConnectionFlag = false; + } + break; } case TDS_REQUEST_PHASE_ERROR: From 0690b948daa5b3521a05cb8c52193c97ebde2e2c Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Thu, 19 Sep 2024 08:49:29 +0000 Subject: [PATCH 09/15] move sp_reset_connection test to separate file --- contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c | 2 +- test/dotnet/input/Storedproc/TestStoredProcedure.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 5afc642afa..dbd68538e6 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -277,7 +277,7 @@ GetTDSRequest(bool *resetProtocol) * memory context before exit so that we can process the request * later. */ - if ((status & TDS_PACKET_HEADER_STATUS_RESETCON)) + if (status & TDS_PACKET_HEADER_STATUS_RESETCON) { MemoryContextSwitchTo(TopMemoryContext); diff --git a/test/dotnet/input/Storedproc/TestStoredProcedure.txt b/test/dotnet/input/Storedproc/TestStoredProcedure.txt index 299da0d394..89565031db 100644 --- a/test/dotnet/input/Storedproc/TestStoredProcedure.txt +++ b/test/dotnet/input/Storedproc/TestStoredProcedure.txt @@ -270,4 +270,5 @@ storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|output#!#i storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|output#!#int|-|c|-|10|-|input#!#int|-|d|-|10|-|inputoutput storedproc#!#prep#!#sp_test25#!#int|-|a|-|20|-|input#!#int|-|b|-|10|-|inputoutput#!#int|-|c|-|10|-|input#!#int|-|d|-|10|-|output -DROP PROCEDURE sp_test25 \ No newline at end of file +DROP PROCEDURE sp_test25 +# Test (24): End \ No newline at end of file From 0f3c8eabe46e1270a1dc7c86bda5a8760e90a726 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Thu, 19 Sep 2024 14:36:12 +0000 Subject: [PATCH 10/15] Add test cases --- .../src/backend/tds/tdsprotocol.c | 7 +- .../Test-sp_reset_connection-vu-cleanup.out | 2 - .../Test-sp_reset_connection-vu-prepare.out | 6 - .../Test-sp_reset_connection-vu-verify.out | 25 ---- .../expected/Test-sp_reset_connection.out | 109 ++++++++++++++++++ .../Test-sp_reset_connection-vu-cleanup.sql | 2 - .../Test-sp_reset_connection-vu-prepare.sql | 6 - .../Test-sp_reset_connection-vu-verify.sql | 12 -- .../Test-sp_reset_connection.sql | 56 +++++++++ .../ExpectedOutput/TestSpResetConnection.out | 31 +++-- .../Storedproc/TestSpResetConnection.txt | 40 +++++-- 11 files changed, 217 insertions(+), 79 deletions(-) delete mode 100644 test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out delete mode 100644 test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out delete mode 100644 test/JDBC/expected/Test-sp_reset_connection-vu-verify.out create mode 100644 test/JDBC/expected/Test-sp_reset_connection.out delete mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql delete mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql delete mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql create mode 100644 test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 9e1cd9a4d0..9764896688 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -154,18 +154,13 @@ ResetTDSConnection(void) TdsProtocolInit(); TdsResetCache(); TdsResponseReset(); -<<<<<<< HEAD /* Retore previous isolation level when not called by sys.sp_reset_connection */ if (!resetTdsConnectionFlag) { + TdsResetBcpOffset(); SetConfigOption("default_transaction_isolation", isolationOld, PGC_BACKEND, PGC_S_CLIENT); } -======= - TdsResetBcpOffset(); - SetConfigOption("default_transaction_isolation", isolationOld, - PGC_BACKEND, PGC_S_CLIENT); ->>>>>>> BABEL_4_X_DEV tvp_lookup_list = NIL; diff --git a/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out b/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out deleted file mode 100644 index 0b0ff37786..0000000000 --- a/test/JDBC/expected/Test-sp_reset_connection-vu-cleanup.out +++ /dev/null @@ -1,2 +0,0 @@ -DROP PROC test_sp_reset_connection_proc -GO diff --git a/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out b/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out deleted file mode 100644 index c011a69cfd..0000000000 --- a/test/JDBC/expected/Test-sp_reset_connection-vu-prepare.out +++ /dev/null @@ -1,6 +0,0 @@ -CREATE PROCEDURE test_sp_reset_connection_proc -AS -BEGIN - EXEC sys.sp_reset_connection -END -GO diff --git a/test/JDBC/expected/Test-sp_reset_connection-vu-verify.out b/test/JDBC/expected/Test-sp_reset_connection-vu-verify.out deleted file mode 100644 index b0914bac68..0000000000 --- a/test/JDBC/expected/Test-sp_reset_connection-vu-verify.out +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) -INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) -GO -~~ROW COUNT: 3~~ - - -SELECT * from #babel_temp_table -GO -~~START~~ -int#!#int -1#!#100 -2#!#200 -3#!#300 -~~END~~ - - -EXEC sys.sp_reset_connection -GO - -SELECT * from #babel_temp_table -Go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: relation "#babel_temp_table" does not exist)~~ - diff --git a/test/JDBC/expected/Test-sp_reset_connection.out b/test/JDBC/expected/Test-sp_reset_connection.out new file mode 100644 index 0000000000..0e3a80846c --- /dev/null +++ b/test/JDBC/expected/Test-sp_reset_connection.out @@ -0,0 +1,109 @@ +-- 1. Test resets GUC variables +SET lock_timeout 0; +GO +SELECT @@lock_timeout; +GO +~~START~~ +int +0 +~~END~~ + +EXEC sys.sp_reset_connection +-- TODO: GUC is not resetting +SELECT @@lock_timeout; +GO +~~START~~ +int +0 +~~END~~ + + +-- 2. Test open transactions are aborted on reset +DROP TABLE IF EXISTS sp_reset_connection_test_table; +CREATE TABLE sp_reset_connection_test_table(id int); +BEGIN TRANSACTION +INSERT INTO sp_reset_connection_test_table VALUES(1) +GO +~~ROW COUNT: 1~~ + +EXEC sys.sp_reset_connection +GO +COMMIT TRANSACTION +GO +~~ERROR (Code: 3902)~~ + +~~ERROR (Message: COMMIT can only be used in transaction blocks)~~ + +SELECT * FROM sp_reset_connection_test_table +GO +~~START~~ +int +~~END~~ + + +-- 3. Test temp tables are deleted on reset +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +GO +~~ROW COUNT: 3~~ + +SELECT * from #babel_temp_table +GO +~~START~~ +int#!#int +1#!#100 +2#!#200 +3#!#300 +~~END~~ + +EXEC sys.sp_reset_connection +GO +SELECT * from #babel_temp_table +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: relation "#babel_temp_table" does not exist)~~ + + +-- 4. Test isolation level is reset +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +~~START~~ +smallint +1 +~~END~~ + +EXEC sys.sp_reset_connection +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +~~START~~ +smallint +2 +~~END~~ + + +-- 5. Test sp_reset_connection called with sp_prepexec +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +~~START~~ +smallint +1 +~~END~~ + +DECLARE @handle int; +EXEC SP_PREPARE @handle output, NULL, N'exec sys.sp_reset_connection' +EXEC SP_EXECUTE @handle +GO +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +~~START~~ +smallint +2 +~~END~~ + diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql deleted file mode 100644 index 0b0ff37786..0000000000 --- a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-cleanup.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP PROC test_sp_reset_connection_proc -GO diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql deleted file mode 100644 index c011a69cfd..0000000000 --- a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-prepare.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE PROCEDURE test_sp_reset_connection_proc -AS -BEGIN - EXEC sys.sp_reset_connection -END -GO diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql deleted file mode 100644 index 0775618675..0000000000 --- a/test/JDBC/input/storedProcedures/Test-sp_reset_connection-vu-verify.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) -INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) -GO - -SELECT * from #babel_temp_table -GO - -EXEC sys.sp_reset_connection -GO - -SELECT * from #babel_temp_table -Go diff --git a/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql b/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql new file mode 100644 index 0000000000..d331eb9b49 --- /dev/null +++ b/test/JDBC/input/storedProcedures/Test-sp_reset_connection.sql @@ -0,0 +1,56 @@ +-- 1. Test resets GUC variables +SET lock_timeout 0; +GO +SELECT @@lock_timeout; +GO +EXEC sys.sp_reset_connection +-- TODO: GUC is not resetting +SELECT @@lock_timeout; +GO + +-- 2. Test open transactions are aborted on reset +DROP TABLE IF EXISTS sp_reset_connection_test_table; +CREATE TABLE sp_reset_connection_test_table(id int); +BEGIN TRANSACTION +INSERT INTO sp_reset_connection_test_table VALUES(1) +GO +EXEC sys.sp_reset_connection +GO +COMMIT TRANSACTION +GO +SELECT * FROM sp_reset_connection_test_table +GO + +-- 3. Test temp tables are deleted on reset +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +GO +SELECT * from #babel_temp_table +GO +EXEC sys.sp_reset_connection +GO +SELECT * from #babel_temp_table +GO + +-- 4. Test isolation level is reset +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +EXEC sys.sp_reset_connection +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO + +-- 5. Test sp_reset_connection called with sp_prepexec +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO +DECLARE @handle int; +EXEC SP_PREPARE @handle output, NULL, N'exec sys.sp_reset_connection' +EXEC SP_EXECUTE @handle +GO +GO +select transaction_isolation_level from sys.dm_exec_sessions where session_id=@@SPID +GO diff --git a/test/dotnet/ExpectedOutput/TestSpResetConnection.out b/test/dotnet/ExpectedOutput/TestSpResetConnection.out index 8b1fea3c11..15f672c521 100644 --- a/test/dotnet/ExpectedOutput/TestSpResetConnection.out +++ b/test/dotnet/ExpectedOutput/TestSpResetConnection.out @@ -1,3 +1,11 @@ +#Q#DROP TABLE IF EXISTS sp_reset_connection_test_table; +#Q#CREATE TABLE sp_reset_connection_test_table(id int); +#Q#INSERT INTO sp_reset_connection_test_table VALUES(1) +#Q#INSERT INTO sp_reset_connection_test_table VALUES(2) +#Q#sys.sp_reset_connection +#Q#SELECT * FROM sp_reset_connection_test_table +#D#int +1 #Q#CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) #Q#INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) #Q#SELECT * from #babel_temp_table @@ -8,14 +16,21 @@ #Q#sys.sp_reset_connection #Q#SELECT * from #babel_temp_table #E#relation "#babel_temp_table" does not exist -#Q#DROP TABLE IF EXISTS babel_test_sp_reset_table; -#Q#CREATE TABLE babel_test_sp_reset_table (ID INT identity(1,1), Data INT); -#Q#INSERT INTO babel_test_sp_reset_table (Data) VALUES (100); -#Q#INSERT INTO babel_test_sp_reset_table (Data) VALUES (200); +#Q#select current_setting('transaction_isolation') +#D#text +repeatable read #Q#sys.sp_reset_connection -#Q#SELECT * FROM babel_test_sp_reset_table; -#D#int#!#int -1#!#100 -#Q#SELECT * FROM babel_test_sp_reset_table; +#Q#select current_setting('transaction_isolation') +#D#text +read committed +#Q#CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +#Q#INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +#Q#SELECT * from #babel_temp_table #D#int#!#int 1#!#100 +2#!#200 +3#!#300 +#Q#sys.sp_reset_connection +#Q#sys.sp_reset_connection +#Q#SELECT * from #babel_temp_table +#E#relation "#babel_temp_table" does not exist diff --git a/test/dotnet/input/Storedproc/TestSpResetConnection.txt b/test/dotnet/input/Storedproc/TestSpResetConnection.txt index 8dc26536c1..1649e3f805 100644 --- a/test/dotnet/input/Storedproc/TestSpResetConnection.txt +++ b/test/dotnet/input/Storedproc/TestSpResetConnection.txt @@ -1,19 +1,35 @@ -# Test (1): Test sys.sp_reset_connection stored procedure +# Test (1): Test abort open transaction +DROP TABLE IF EXISTS sp_reset_connection_test_table; +CREATE TABLE sp_reset_connection_test_table(id int); +INSERT INTO sp_reset_connection_test_table VALUES(1) +txn#!#begin +INSERT INTO sp_reset_connection_test_table VALUES(2) +storedproc#!#prep#!#sys.sp_reset_connection#!# +txn#!#commit +SELECT * FROM sp_reset_connection_test_table +# Test (1): End + +# Test (2): Test temp table deletion CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) SELECT * from #babel_temp_table storedproc#!#prep#!#sys.sp_reset_connection#!# SELECT * from #babel_temp_table -# Test (1): End +# Test (2): End -# Test (2): -DROP TABLE IF EXISTS babel_test_sp_reset_table; -CREATE TABLE babel_test_sp_reset_table (ID INT identity(1,1), Data INT); -INSERT INTO babel_test_sp_reset_table (Data) VALUES (100); -txn#!#BEGIN -INSERT INTO babel_test_sp_reset_table (Data) VALUES (200); +# Test (3): Test reset of isolation level +txn#!#begin#!#isolation#!#ss +select current_setting('transaction_isolation') storedproc#!#prep#!#sys.sp_reset_connection#!# -SELECT * FROM babel_test_sp_reset_table; -#txn#!#COMMIT -SELECT * FROM babel_test_sp_reset_table; -# Test (2): End \ No newline at end of file +select current_setting('transaction_isolation') +txn#!#commit +# Test (3): End + +# Test (4): Test prepexec sp_reset_connection +CREATE TABLE #babel_temp_table (ID INT identity(1,1), Data INT) +INSERT INTO #babel_temp_table (Data) VALUES (100), (200), (300) +SELECT * from #babel_temp_table +prepst#!#sys.sp_reset_connection#!# +prepst#!#exec#!# +SELECT * from #babel_temp_table +# Test (4): End \ No newline at end of file From dec89b0bba4dd8524f4286c9de8118dfc4384ed4 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Fri, 20 Sep 2024 08:32:35 +0000 Subject: [PATCH 11/15] Ignore upgrade tests for sp_reset_connection --- .../python/expected/sql_validation_framework/expected_create.out | 1 + 1 file changed, 1 insertion(+) diff --git a/test/python/expected/sql_validation_framework/expected_create.out b/test/python/expected/sql_validation_framework/expected_create.out index 88557a42fe..2220c616b5 100644 --- a/test/python/expected/sql_validation_framework/expected_create.out +++ b/test/python/expected/sql_validation_framework/expected_create.out @@ -191,6 +191,7 @@ Could not find upgrade tests for procedure sys.sp_cursor_list Could not find upgrade tests for procedure sys.sp_describe_cursor Could not find upgrade tests for procedure sys.sp_oledb_ro_usrname Could not find upgrade tests for procedure sys.sp_prepare +Could not find upgrade tests for procedure sys.sp_reset_connection Could not find upgrade tests for procedure sys.sp_unprepare Could not find upgrade tests for procedure sys.sp_updatestats Could not find upgrade tests for table sys.babelfish_configurations From f41dec15f9becf27bf6da4ab434c93f7408429a4 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Fri, 20 Sep 2024 12:21:41 +0000 Subject: [PATCH 12/15] Ignore upgrade tests for sp_reset_connection --- test/JDBC/jdbc_schedule | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index 455bc5ced3..aeb3f95bd5 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -387,3 +387,5 @@ ignore#!#string_agg_within-16_4-vu-prepare ignore#!#string_agg_within-16_4-vu-verify ignore#!#string_agg_within-16_4-vu-cleanup +ignore#!#Test-sp_reset_connection-vu-prepare +ignore#!#Test-sp_reset_connection-vu-verify From 711a19723240f7a78f5d90dc45f8e2afe619b28a Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Sun, 22 Sep 2024 18:56:55 +0000 Subject: [PATCH 13/15] Remove sp_reset_connection from upgrade test --- test/JDBC/upgrade/latest/schedule | 1 - 1 file changed, 1 deletion(-) diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 6b036c0471..376ebda483 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -451,7 +451,6 @@ Test-sp_helpsrvrolemember Test-sp_helpuser Test-sp_rename Test-sp_rename-dep -Test-sp_reset_connection Test-sp_set_session_context Test-sp_set_session_context-dep TestSQLVariant From 5bd9f96850c90381a2396fbf05b9ab2fa7cb2a34 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Mon, 23 Sep 2024 03:10:57 +0000 Subject: [PATCH 14/15] Remove sp_reset_connection from upgrade test --- test/JDBC/jdbc_schedule | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index aeb3f95bd5..0152772158 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -386,6 +386,3 @@ ignore#!#string_agg-before-14_5-vu-cleanup ignore#!#string_agg_within-16_4-vu-prepare ignore#!#string_agg_within-16_4-vu-verify ignore#!#string_agg_within-16_4-vu-cleanup - -ignore#!#Test-sp_reset_connection-vu-prepare -ignore#!#Test-sp_reset_connection-vu-verify From 19fe3213884cc347bea6f4e6ff8cdac10a1acba4 Mon Sep 17 00:00:00 2001 From: Sharath BP Date: Mon, 23 Sep 2024 08:28:44 +0000 Subject: [PATCH 15/15] Merge with origin --- contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c index 9764896688..22b6c17c68 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsprotocol.c @@ -154,10 +154,10 @@ ResetTDSConnection(void) TdsProtocolInit(); TdsResetCache(); TdsResponseReset(); + TdsResetBcpOffset(); /* Retore previous isolation level when not called by sys.sp_reset_connection */ if (!resetTdsConnectionFlag) { - TdsResetBcpOffset(); SetConfigOption("default_transaction_isolation", isolationOld, PGC_BACKEND, PGC_S_CLIENT); }