forked from babelfish-for-postgresql/babelfish_extensions
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfb3122
commit 82181e7
Showing
2 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
test/JDBC/input/storedProcedures/Test-sp_reset_connection.mix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
-- tsql | ||
-- 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 | ||
|
||
-- 6. Test Database Context being reset | ||
-- Tests include negative cases where db is dropped or renamed | ||
Create database reset_con_db1; | ||
GO | ||
Create database reset_con_db2; | ||
GO | ||
|
||
-- tsql database=reset_con_db1 | ||
select db_name(); | ||
GO | ||
exec sys.sp_reset_connection | ||
GO | ||
use master | ||
GO | ||
select db_name(); | ||
GO | ||
exec sys.sp_reset_connection | ||
GO | ||
select db_name(); | ||
GO | ||
-- test db being dropped before resetting to same db | ||
use master; | ||
drop database reset_con_db1; | ||
GO | ||
exec sys.sp_reset_connection | ||
GO | ||
-- tsql database=reset_con_db2 | ||
select db_name(); | ||
GO | ||
use master | ||
GO | ||
select db_name(); | ||
GO | ||
ALTER DATABASE reset_con_db2 MODIFY NAME=reset_con_db3 | ||
GO | ||
exec sys.sp_reset_connection | ||
GO | ||
|
||
-- tsql | ||
DROP DATABASE reset_con_db3 | ||
GO |