diff --git a/test/JDBC/expected/BABEL-2170-txn_test.out b/test/JDBC/expected/BABEL-2170-txn_test.out new file mode 100644 index 0000000000..a5510edb25 --- /dev/null +++ b/test/JDBC/expected/BABEL-2170-txn_test.out @@ -0,0 +1,70 @@ +CREATE TABLE babel_2170_vu_employees +( + EmployeeID int NOT NULL, + EmployeeName VARCHAR(50), + EmployeeAddress VARCHAR(50), + MonthSalary NUMERIC(10, 2) +) +GO + +INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); +INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); +INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); +INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); +GO +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +CREATE VIEW babel_2170_vu_employees_view AS +SELECT EmployeeID, + EmployeeName, + EmployeeAddress, + MonthSalary +FROM babel_2170_vu_employees +WHERE EmployeeName LIKE 'a%'; +GO + +CREATE TRIGGER babel_2170_vu_employees_view_iot_tx_update ON babel_2170_vu_employees_view +INSTEAD OF UPDATE +AS + BEGIN + BEGIN TRAN; + INSERT INTO babel_2170_vu_employees_view VALUES(5, 'alex', '1st Street', '5000'); + ROLLBACK tran; + END +GO + +UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 3; +GO +~~ROW COUNT: 1~~ + +~~ERROR (Code: 3609)~~ + +~~ERROR (Message: The transaction ended in the trigger. The batch has been aborted.)~~ + + +SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view ORDER BY EmployeeID; +GO +~~START~~ +int#!#varchar#!#varchar#!#numeric +1#!#amber#!#1st Street#!#1000.00 +2#!#angel#!#1st Street#!#2000.00 +3#!#ana#!#1st Street#!#3000.00 +4#!#adam#!#1st Street#!#4000.00 +~~END~~ + + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_tx_update; +GO + +DROP VIEW IF EXISTS babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS babel_2170_vu_employees; +GO diff --git a/test/JDBC/expected/BABEL-2170-vu-cleanup.out b/test/JDBC/expected/BABEL-2170-vu-cleanup.out index 9779eb896a..de35881652 100644 --- a/test/JDBC/expected/BABEL-2170-vu-cleanup.out +++ b/test/JDBC/expected/BABEL-2170-vu-cleanup.out @@ -23,41 +23,10 @@ GO DROP TABLE IF EXISTS babel_2170_vu_employees; GO --- schema_2170 object cleanup -DROP TRIGGER IF EXISTS schema_2170.babel_2170_vu_employees_view_iot_update; -GO - -DROP VIEW IF EXISTS schema_2170.babel_2170_vu_employees_view; -GO - -DROP TABLE IF EXISTS schema_2170.babel_2170_vu_employees; -GO --- clean all objects in second database -USE db2_BABEL2170; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_delete; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees; -GO - USE MASTER; GO -DROP DATABASE db1_BABEL2170; -GO - -DROP DATABASE db2_BABEL2170; +DROP DATABASE IF EXISTS db1_BABEL2170; GO SELECT name FROM sys.sysobjects WHERE name LIKE 'babel_2170%' ORDER BY name; diff --git a/test/JDBC/expected/BABEL-2170-vu-prepare.out b/test/JDBC/expected/BABEL-2170-vu-prepare.out index e37935d1bd..8cddde3d16 100644 --- a/test/JDBC/expected/BABEL-2170-vu-prepare.out +++ b/test/JDBC/expected/BABEL-2170-vu-prepare.out @@ -80,42 +80,3 @@ SELECT EmployeeID, FROM schema_2170.babel_2170_vu_employees WHERE EmployeeName LIKE 'a%'; GO - -CREATE DATABASE db2_BABEL2170; -GO - -USE db2_BABEL2170; -GO - -CREATE TABLE babel_2170_vu_employees -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); -INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); -INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); -GO -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - - -CREATE VIEW babel_2170_vu_employees_view AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - diff --git a/test/JDBC/expected/BABEL-2170-vu-verify.out b/test/JDBC/expected/BABEL-2170-vu-verify.out index b9d9e9a474..8f31c9e26c 100644 --- a/test/JDBC/expected/BABEL-2170-vu-verify.out +++ b/test/JDBC/expected/BABEL-2170-vu-verify.out @@ -172,7 +172,7 @@ int#!#varchar#!#varchar#!#numeric -- Test Instead of Update trigger in same db but cross schema --- cleanup default dbo schema IO upadte trigger +-- Cleanup default dbo schema IO Update trigger DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; GO @@ -208,16 +208,78 @@ Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked ~~ROW COUNT: 1~~ -DROP TRIGGER IF EXISTS [schema_2170].[babel_2170_vu_employees_view_iot_update]; +DROP TRIGGER IF EXISTS[dbo].[babel_2170_vu_employees_view_iot_update]; GO -DROP TRIGGER IF EXISTS[dbo].[babel_2170_vu_employees_view_iot_update]; +-- schema_2170 object cleanup +DROP TRIGGER IF EXISTS [schema_2170].babel_2170_vu_employees_view_iot_update; +GO + +DROP VIEW IF EXISTS [schema_2170].babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS [schema_2170].babel_2170_vu_employees; +GO + +DROP SCHEMA IF EXISTS schema_2170; +GO + +-- test multi-db mode +SELECT set_config('role', 'jdbc_user', false); +GO +~~START~~ +text +jdbc_user +~~END~~ + + +SELECT set_config('babelfishpg_tsql.migration_mode', 'multi-db', false); +GO +~~START~~ +text +multi-db +~~END~~ + + +CREATE DATABASE db2_BABEL2170; GO --- create same name Instead of Insert trigger in second db to test Cross db behavior USE db2_BABEL2170; GO +CREATE TABLE babel_2170_vu_employees +( + EmployeeID int NOT NULL, + EmployeeName VARCHAR(50), + EmployeeAddress VARCHAR(50), + MonthSalary NUMERIC(10, 2) +) +GO + +INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); +INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); +INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); +INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); +GO +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +CREATE VIEW babel_2170_vu_employees_view AS +SELECT EmployeeID, + EmployeeName, + EmployeeAddress, + MonthSalary +FROM babel_2170_vu_employees +WHERE EmployeeName LIKE 'a%'; +GO + +-- create same name Instead of Insert trigger in second db to test Cross db behavior CREATE TRIGGER babel_2170_vu_employees_view_iot_insert ON babel_2170_vu_employees_view INSTEAD OF INSERT AS @@ -251,3 +313,25 @@ GO int#!#varchar#!#varchar#!#numeric ~~END~~ + +-- clean all objects in second database +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; +GO + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; +GO + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_delete; +GO + +DROP VIEW IF EXISTS babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS babel_2170_vu_employees; +GO + +USE MASTER; +GO + +DROP DATABASE IF EXISTS db2_BABEL2170; +GO diff --git a/test/JDBC/input/triggers/BABEL-2170-txn_test.sql b/test/JDBC/input/triggers/BABEL-2170-txn_test.sql new file mode 100644 index 0000000000..591f045783 --- /dev/null +++ b/test/JDBC/input/triggers/BABEL-2170-txn_test.sql @@ -0,0 +1,48 @@ +CREATE TABLE babel_2170_vu_employees +( + EmployeeID int NOT NULL, + EmployeeName VARCHAR(50), + EmployeeAddress VARCHAR(50), + MonthSalary NUMERIC(10, 2) +) +GO + +INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); +INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); +INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); +INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); +GO + +CREATE VIEW babel_2170_vu_employees_view AS +SELECT EmployeeID, + EmployeeName, + EmployeeAddress, + MonthSalary +FROM babel_2170_vu_employees +WHERE EmployeeName LIKE 'a%'; +GO + +CREATE TRIGGER babel_2170_vu_employees_view_iot_tx_update ON babel_2170_vu_employees_view +INSTEAD OF UPDATE +AS + BEGIN + BEGIN TRAN; + INSERT INTO babel_2170_vu_employees_view VALUES(5, 'alex', '1st Street', '5000'); + ROLLBACK tran; + END +GO + +UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 3; +GO + +SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view ORDER BY EmployeeID; +GO + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_tx_update; +GO + +DROP VIEW IF EXISTS babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS babel_2170_vu_employees; +GO \ No newline at end of file diff --git a/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql b/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql index a071cd6754..4c7c0e7acd 100644 --- a/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql +++ b/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql @@ -23,41 +23,10 @@ GO DROP TABLE IF EXISTS babel_2170_vu_employees; GO --- schema_2170 object cleanup -DROP TRIGGER IF EXISTS schema_2170.babel_2170_vu_employees_view_iot_update; -GO - -DROP VIEW IF EXISTS schema_2170.babel_2170_vu_employees_view; -GO - -DROP TABLE IF EXISTS schema_2170.babel_2170_vu_employees; -GO --- clean all objects in second database -USE db2_BABEL2170; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_delete; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees; -GO - USE MASTER; GO -DROP DATABASE db1_BABEL2170; -GO - -DROP DATABASE db2_BABEL2170; +DROP DATABASE IF EXISTS db1_BABEL2170; GO SELECT name FROM sys.sysobjects WHERE name LIKE 'babel_2170%' ORDER BY name; diff --git a/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql b/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql index 7ff032b53c..2ede2104a9 100644 --- a/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql +++ b/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql @@ -63,36 +63,4 @@ SELECT EmployeeID, MonthSalary FROM schema_2170.babel_2170_vu_employees WHERE EmployeeName LIKE 'a%'; -GO - -CREATE DATABASE db2_BABEL2170; -GO - -USE db2_BABEL2170; -GO - -CREATE TABLE babel_2170_vu_employees -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); -INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); -INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); -GO - -CREATE VIEW babel_2170_vu_employees_view AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - --- Test rollback and Commit Txn behavior for IO UPDATE trigger \ No newline at end of file +GO \ No newline at end of file diff --git a/test/JDBC/input/triggers/BABEL-2170-vu-verify.sql b/test/JDBC/input/triggers/BABEL-2170-vu-verify.sql index 1703a6b716..0a0791f6d1 100644 --- a/test/JDBC/input/triggers/BABEL-2170-vu-verify.sql +++ b/test/JDBC/input/triggers/BABEL-2170-vu-verify.sql @@ -84,7 +84,7 @@ GO -- Test Instead of Update trigger in same db but cross schema --- cleanup default dbo schema IO upadte trigger +-- Cleanup default dbo schema IO Update trigger DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; GO @@ -106,16 +106,60 @@ GO UPDATE [dbo].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 3; GO -DROP TRIGGER IF EXISTS [schema_2170].[babel_2170_vu_employees_view_iot_update]; +DROP TRIGGER IF EXISTS[dbo].[babel_2170_vu_employees_view_iot_update]; GO -DROP TRIGGER IF EXISTS[dbo].[babel_2170_vu_employees_view_iot_update]; +-- schema_2170 object cleanup +DROP TRIGGER IF EXISTS [schema_2170].babel_2170_vu_employees_view_iot_update; +GO + +DROP VIEW IF EXISTS [schema_2170].babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS [schema_2170].babel_2170_vu_employees; +GO + +DROP SCHEMA IF EXISTS schema_2170; +GO + +-- test multi-db mode +SELECT set_config('role', 'jdbc_user', false); +GO + +SELECT set_config('babelfishpg_tsql.migration_mode', 'multi-db', false); +GO + +CREATE DATABASE db2_BABEL2170; GO --- create same name Instead of Insert trigger in second db to test Cross db behavior USE db2_BABEL2170; GO +CREATE TABLE babel_2170_vu_employees +( + EmployeeID int NOT NULL, + EmployeeName VARCHAR(50), + EmployeeAddress VARCHAR(50), + MonthSalary NUMERIC(10, 2) +) +GO + +INSERT INTO babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); +INSERT INTO babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); +INSERT INTO babel_2170_vu_employees VALUES(3, 'ana', '1st Street', '3000'); +INSERT INTO babel_2170_vu_employees VALUES(4, 'adam', '1st Street', '4000'); +GO + +CREATE VIEW babel_2170_vu_employees_view AS +SELECT EmployeeID, + EmployeeName, + EmployeeAddress, + MonthSalary +FROM babel_2170_vu_employees +WHERE EmployeeName LIKE 'a%'; +GO + +-- create same name Instead of Insert trigger in second db to test Cross db behavior CREATE TRIGGER babel_2170_vu_employees_view_iot_insert ON babel_2170_vu_employees_view INSTEAD OF INSERT AS @@ -132,4 +176,26 @@ SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu GO SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view WHERE EmployeeID =5; +GO + +-- clean all objects in second database +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; +GO + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; +GO + +DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_delete; +GO + +DROP VIEW IF EXISTS babel_2170_vu_employees_view; +GO + +DROP TABLE IF EXISTS babel_2170_vu_employees; +GO + +USE MASTER; +GO + +DROP DATABASE IF EXISTS db2_BABEL2170; GO \ No newline at end of file diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 8158b2fe86..9df45042df 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -38,6 +38,7 @@ BABEL-1963 BABEL-1994-CHAR BABEL-1994-VARCHAR BABEL-2086 +BABEL-2170 BABEL-2203 BABEL-2208 BABEL-2257