diff --git a/contrib/babelfishpg_tds/src/backend/tds/tds.c b/contrib/babelfishpg_tds/src/backend/tds/tds.c index b64746594a..4f00969208 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tds.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tds.c @@ -441,19 +441,17 @@ tds_status_shmem_startup(void) static void tds_stats_shmem_shutdown(int code, Datum arg) { - /* Don't try to save the outlines during a crash. */ - if (code) - return; + volatile TdsStatus *myTdsStatusEntry = MyTdsStatusEntry; /* Safety check ... shouldn't get here unless shmem is set up. */ if (TdsStatusArray == NULL || MyTdsStatusEntry == NULL) return; - PGSTAT_BEGIN_WRITE_ACTIVITY(MyTdsStatusEntry); + PGSTAT_BEGIN_WRITE_ACTIVITY(myTdsStatusEntry); - MyTdsStatusEntry->st_procpid = 0; /* mark invalid */ + myTdsStatusEntry->st_procpid = 0; /* mark invalid */ - PGSTAT_END_WRITE_ACTIVITY(MyTdsStatusEntry); + PGSTAT_END_WRITE_ACTIVITY(myTdsStatusEntry); MyTdsStatusEntry = NULL; diff --git a/test/JDBC/expected/kill-vu-verify.out b/test/JDBC/expected/kill-vu-verify.out index ec919836f7..15fa3ad64a 100644 --- a/test/JDBC/expected/kill-vu-verify.out +++ b/test/JDBC/expected/kill-vu-verify.out @@ -3,6 +3,8 @@ create table tab_kill_spid(spid int) go create login victim_user_tds with password = '12345678'; go +select count(*) as count into #kill_temp_table from sys.dm_exec_sessions +go -- tsql user=victim_user_tds password=12345678 select 1 @@ -763,3 +765,14 @@ int 0 ~~END~~ + +IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table)) + SELECT 'SUCESS'; +ELSE + SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b; +GO +~~START~~ +varchar +SUCESS +~~END~~ + diff --git a/test/JDBC/expected/single_db/kill-vu-verify.out b/test/JDBC/expected/single_db/kill-vu-verify.out index f88e73fb6a..799bd24059 100644 --- a/test/JDBC/expected/single_db/kill-vu-verify.out +++ b/test/JDBC/expected/single_db/kill-vu-verify.out @@ -3,6 +3,8 @@ create table tab_kill_spid(spid int) go create login victim_user_tds with password = '12345678'; go +select count(*) as count into #kill_temp_table from sys.dm_exec_sessions +go -- tsql user=victim_user_tds password=12345678 select 1 @@ -863,3 +865,14 @@ int 0 ~~END~~ + +IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table)) + SELECT 'SUCESS'; +ELSE + SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b; +GO +~~START~~ +varchar +SUCESS +~~END~~ + diff --git a/test/JDBC/input/kill-vu-verify.mix b/test/JDBC/input/kill-vu-verify.mix index 784f86c86f..9db55855e9 100644 --- a/test/JDBC/input/kill-vu-verify.mix +++ b/test/JDBC/input/kill-vu-verify.mix @@ -4,6 +4,8 @@ create table tab_kill_spid(spid int) go create login victim_user_tds with password = '12345678'; go +select count(*) as count into #kill_temp_table from sys.dm_exec_sessions +go -- tsql user=victim_user_tds password=12345678 select 1 @@ -403,4 +405,10 @@ SELECT count(*) from sys.dm_exec_sessions where login_name = 'test_kill' GO SELECT COUNT(*) from pg_stat_activity where usename = 'test_kill' -GO \ No newline at end of file +GO + +IF ((SELECT COUNT(*) FROM sys.dm_exec_sessions) = (SELECT count FROM #kill_temp_table)) + SELECT 'SUCESS'; +ELSE + SELECT 'FAILURE expected count ==> ', (SELECT count FROM #kill_temp_table), ' actual count ==> ', count(*) from sys.dm_exec_sessions b; +GO