From 2a9ddf16843c38d340e81e0cb8f674183bfc59e3 Mon Sep 17 00:00:00 2001 From: Deepakshi Mittal <78574784+deepakshi-mittal@users.noreply.github.com> Date: Mon, 27 Nov 2023 11:10:01 -0800 Subject: [PATCH] Revert Instead of Trigger on View (#2068) Revert this feature from release due to issues Task: BABEL-2170 Signed-off-by: Deepakshi Mittal --- contrib/babelfishpg_tsql/src/hooks.c | 60 -- test/JDBC/expected/BABEL-2170-vu-cleanup.out | 39 -- test/JDBC/expected/BABEL-2170-vu-prepare.out | 105 --- test/JDBC/expected/BABEL-2170-vu-verify.out | 636 ------------------ .../input/triggers/BABEL-2170-vu-cleanup.sql | 39 -- .../input/triggers/BABEL-2170-vu-prepare.sql | 93 --- .../input/triggers/BABEL-2170-vu-verify.sql | 361 ---------- test/JDBC/upgrade/15_5/schedule | 486 +++++++++++++ test/JDBC/upgrade/latest/schedule | 1 - 9 files changed, 486 insertions(+), 1334 deletions(-) delete mode 100644 test/JDBC/expected/BABEL-2170-vu-cleanup.out delete mode 100644 test/JDBC/expected/BABEL-2170-vu-prepare.out delete mode 100644 test/JDBC/expected/BABEL-2170-vu-verify.out delete mode 100644 test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql delete mode 100644 test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql delete mode 100644 test/JDBC/input/triggers/BABEL-2170-vu-verify.sql create mode 100644 test/JDBC/upgrade/15_5/schedule diff --git a/contrib/babelfishpg_tsql/src/hooks.c b/contrib/babelfishpg_tsql/src/hooks.c index 04db48ce094..91901686b4b 100644 --- a/contrib/babelfishpg_tsql/src/hooks.c +++ b/contrib/babelfishpg_tsql/src/hooks.c @@ -159,7 +159,6 @@ static void pltsql_ExecutorStart(QueryDesc *queryDesc, int eflags); static void pltsql_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once); static void pltsql_ExecutorFinish(QueryDesc *queryDesc); static void pltsql_ExecutorEnd(QueryDesc *queryDesc); -static bool pltsql_bbfViewHasInsteadofTrigger(Relation view, CmdType event); static bool plsql_TriggerRecursiveCheck(ResultRelInfo *resultRelInfo); static bool bbf_check_rowcount_hook(int es_processed); @@ -211,7 +210,6 @@ static ExecutorFinish_hook_type prev_ExecutorFinish = NULL; static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; static GetNewObjectId_hook_type prev_GetNewObjectId_hook = NULL; static inherit_view_constraints_from_table_hook_type prev_inherit_view_constraints_from_table = NULL; -static bbfViewHasInsteadofTrigger_hook_type prev_bbfViewHasInsteadofTrigger_hook = NULL; static detect_numeric_overflow_hook_type prev_detect_numeric_overflow_hook = NULL; static match_pltsql_func_call_hook_type prev_match_pltsql_func_call_hook = NULL; static insert_pltsql_function_defaults_hook_type prev_insert_pltsql_function_defaults_hook = NULL; @@ -327,9 +325,6 @@ InstallExtendedHooks(void) inherit_view_constraints_from_table_hook = preserve_view_constraints_from_base_table; TriggerRecuresiveCheck_hook = plsql_TriggerRecursiveCheck; - prev_bbfViewHasInsteadofTrigger_hook = bbfViewHasInsteadofTrigger_hook; - bbfViewHasInsteadofTrigger_hook = pltsql_bbfViewHasInsteadofTrigger; - prev_detect_numeric_overflow_hook = detect_numeric_overflow_hook; detect_numeric_overflow_hook = pltsql_detect_numeric_overflow; @@ -439,7 +434,6 @@ UninstallExtendedHooks(void) ExecutorEnd_hook = prev_ExecutorEnd; GetNewObjectId_hook = prev_GetNewObjectId_hook; inherit_view_constraints_from_table_hook = prev_inherit_view_constraints_from_table; - bbfViewHasInsteadofTrigger_hook = prev_bbfViewHasInsteadofTrigger_hook; detect_numeric_overflow_hook = prev_detect_numeric_overflow_hook; match_pltsql_func_call_hook = prev_match_pltsql_func_call_hook; insert_pltsql_function_defaults_hook = prev_insert_pltsql_function_defaults_hook; @@ -719,60 +713,6 @@ plsql_TriggerRecursiveCheck(ResultRelInfo *resultRelInfo) return false; } -/** - * Hook function to skip rewriting VIEW with base table if the VIEW has an instead of trigger - * Checks if view have an INSTEAD OF trigger at statement level - * If it does, we don't want to treat it as auto-updatable. - * Reference - src/backend/rewrite/rewriteHandler.c view_has_instead_trigger -*/ -static bool -pltsql_bbfViewHasInsteadofTrigger(Relation view, CmdType event) -{ - TriggerDesc *trigDesc = view->trigdesc; - if (triggerOids) - { - int i; - for (i = 0; i < trigDesc->numtriggers; i++) - { - Trigger *trigger = &trigDesc->triggers[i]; - Oid current_tgoid = trigger->tgoid; - Oid prev_tgoid = InvalidOid; - prev_tgoid = lfirst_oid(list_tail(triggerOids)); - if (prev_tgoid == current_tgoid) - { - return false; /** Direct recursive trigger case*/ - } - else if (list_member_oid(triggerOids, current_tgoid)) - { - /** Indirect recursive trigger case*/ - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)"))); - } - } - } - - switch (event) - { - case CMD_INSERT: - if(trigDesc && trigDesc->trig_insert_instead_statement) - return true; - break; - case CMD_UPDATE: - if (trigDesc && trigDesc->trig_update_instead_statement) - return true; - break; - case CMD_DELETE: - if (trigDesc && trigDesc->trig_delete_instead_statement) - return true; - break; - default: - elog(ERROR, "unrecognized CmdType: %d", (int) event); - break; - } - return false; -} - /* * Wrapper function that calls the initilization function. * Calls the pre function call hook on the procname diff --git a/test/JDBC/expected/BABEL-2170-vu-cleanup.out b/test/JDBC/expected/BABEL-2170-vu-cleanup.out deleted file mode 100644 index 9fd916b30f1..00000000000 --- a/test/JDBC/expected/BABEL-2170-vu-cleanup.out +++ /dev/null @@ -1,39 +0,0 @@ --- clean all objects in first database -USE db1_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 TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_bulkinsert; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_bulkinsert; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_2; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_txn; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees_txn; -GO - -USE MASTER; -GO - -DROP DATABASE IF EXISTS db1_BABEL2170; -GO diff --git a/test/JDBC/expected/BABEL-2170-vu-prepare.out b/test/JDBC/expected/BABEL-2170-vu-prepare.out deleted file mode 100644 index dc6cd1a8ccc..00000000000 --- a/test/JDBC/expected/BABEL-2170-vu-prepare.out +++ /dev/null @@ -1,105 +0,0 @@ --- We will create two databases db1_BABEL2170, db2_BABEL2170 -CREATE DATABASE db1_BABEL2170; -GO - -USE db1_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'); -GO -~~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 VIEW babel_2170_vu_employees_view_bulkinsert AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'b%'; -GO - -CREATE VIEW babel_2170_vu_employees_view_2 AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - -CREATE SCHEMA schema_2170; -GO - -CREATE TABLE schema_2170.babel_2170_vu_employees -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO schema_2170.babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO schema_2170.babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); -GO -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - - -CREATE VIEW schema_2170.babel_2170_vu_employees_view AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM schema_2170.babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - -CREATE TABLE babel_2170_vu_employees_txn -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO babel_2170_vu_employees_txn VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO babel_2170_vu_employees_txn VALUES(2, 'angel', '1st Street', '2000'); -GO -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - - -CREATE VIEW babel_2170_vu_employees_view_txn AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees_txn -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 deleted file mode 100644 index 06f834bcb6a..00000000000 --- a/test/JDBC/expected/BABEL-2170-vu-verify.out +++ /dev/null @@ -1,636 +0,0 @@ -USE db1_BABEL2170; -GO - --- Instead of Insert Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_insert ON babel_2170_vu_employees_view -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked' -END -GO - -INSERT INTO babel_2170_vu_employees_view VALUES(3, 'adam', '1st Street', '3000'); -GO -~~START~~ -varchar -Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees; -GO -~~START~~ -int -2 -~~END~~ - - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees_view; -GO -~~START~~ -int -2 -~~END~~ - - --- Instead of Update Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked' -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID,EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees WHERE EmployeeID = 2; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -2#!#angel#!#1st Street#!#2000.00 -~~END~~ - - -BEGIN TRANSACTION - UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID IN (1, 2); -COMMIT TRANSACTION; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked -~~END~~ - -~~ROW COUNT: 2~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees WHERE EmployeeID IN (1, 2) ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2000.00 -~~END~~ - - --- Instead of Delete Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_delete ON babel_2170_vu_employees_view -INSTEAD OF DELETE -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_delete Invoked' -END -GO - -BEGIN TRANSACTION - DELETE FROM babel_2170_vu_employees_view WHERE EmployeeID IN (1, 2); -COMMIT TRANSACTION; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_delete Invoked -~~END~~ - -~~ROW COUNT: 2~~ - - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees_view; -GO -~~START~~ -int -2 -~~END~~ - - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees; -GO -~~START~~ -int -2 -~~END~~ - - -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 -~~END~~ - - ---- Tests multiple insert queries and check if inserted table can be accessed and trigger is working fine. -CREATE TRIGGER babel_2170_vu_employees_view_iot_bulkinsert ON babel_2170_vu_employees_view_bulkinsert -INSTEAD OF INSERT -AS - SELECT * FROM INSERTED; -GO - -BEGIN TRANSACTION -DECLARE @i int = 1 - WHILE @i <= 3 - BEGIN - INSERT INTO babel_2170_vu_employees_view_bulkinsert VALUES(@i, 'bob', '1st Street', '1000'); - SET @i = @i + 1 - END -COMMIT TRANSACTION -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#bob#!#1st Street#!#1000.00 -~~END~~ - -~~ROW COUNT: 1~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -2#!#bob#!#1st Street#!#1000.00 -~~END~~ - -~~ROW COUNT: 1~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -3#!#bob#!#1st Street#!#1000.00 -~~END~~ - -~~ROW COUNT: 1~~ - - --- Same trigger name on different View created on Same table in same schema -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view_2 -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view2_iot_update Invoked' -END -GO -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: trigger "babel_2170_vu_employees_view_iot_update" already exists in the database)~~ - - --- Same trigger name on a Table in same schema -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees__table_iot_update Invoked' -END -GO -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: trigger "babel_2170_vu_employees_view_iot_update" already exists in the database)~~ - - - --- Test Instead of Update trigger in same db but cross schema --- Cleanup default dbo schema IO Update trigger -DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; -GO - -CREATE TRIGGER [schema_2170].[babel_2170_vu_employees_view_iot_update] ON [schema_2170].[babel_2170_vu_employees_view] -INSTEAD OF UPDATE -AS - SELECT 'Trigger db1_BABEL2170.schema_2170.babel_2170_vu_employees_view_iot_update Invoked' -GO - -CREATE TRIGGER [babel_2170_vu_employees_view_iot_update] ON [babel_2170_vu_employees_view] -INSTEAD OF UPDATE -AS - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked' -GO - -UPDATE [schema_2170].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.schema_2170.babel_2170_vu_employees_view_iot_update Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM [schema_2170].[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 -~~END~~ - - -UPDATE [dbo].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM [dbo].[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 -~~END~~ - - --- drop dbo schema trigger and test that schema_2170.update trigger is not dropped -DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; -GO - -UPDATE [schema_2170].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~START~~ -varchar -Trigger db1_BABEL2170.schema_2170.babel_2170_vu_employees_view_iot_update Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - --- 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 Transaction Commit and Rollback inside Instead of triggers -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn -INSTEAD OF UPDATE -AS - BEGIN - BEGIN TRAN; - INSERT INTO babel_2170_vu_employees_view_txn VALUES(3, 'adam', '1st Street', '3000'); - COMMIT tran; - END -GO - -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2000.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn -INSTEAD OF UPDATE -AS - BEGIN - BEGIN TRAN; - INSERT INTO babel_2170_vu_employees_view_txn VALUES(3, 'adam', '1st Street', '3000'); - ROLLBACK tran; - END -GO - -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -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_txn ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2000.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_insert ON babel_2170_vu_employees_view_txn INSTEAD OF INSERT AS -BEGIN TRAN; -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -COMMIT; -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -SELECT * FROM inserted; -GO - -BEGIN TRAN; -GO -INSERT INTO babel_2170_vu_employees_view_txn VALUES(4, 'ana', '1st Street', '4000'); -GO -~~ROW COUNT: 1~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2001.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -4#!#ana#!#1st Street#!#4000.00 -~~END~~ - -~~ROW COUNT: 1~~ - -COMMIT; -GO - -BEGIN TRAN -GO -INSERT INTO babel_2170_vu_employees_view_txn VALUES(4, 'ana', '1st Street', '4000'); -GO -~~ROW COUNT: 1~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2002.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -4#!#ana#!#1st Street#!#4000.00 -~~END~~ - -~~ROW COUNT: 1~~ - -IF (@@trancount > 0) ROLLBACK; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2001.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_insert; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn INSTEAD OF UPDATE AS -SAVE TRAN sp1; -SAVE TRAN sp2; -DELETE FROM babel_2170_vu_employees_view_txn where EmployeeID =2; -ROLLBACK TRAN sp1; -GO - -BEGIN TRAN -GO -SELECT @@trancount; -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~START~~ -int -1 -~~END~~ - -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - -IF (@@trancount > 0) ROLLBACK; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2001.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_delete ON babel_2170_vu_employees_view_txn INSTEAD OF DELETE AS -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -INSERT INTO babel_2170_vu_employees_view_txn VALUES(5, 'ash', '1st Street', '5000'); -SELECT * FROM deleted; -GO - -DELETE FROM babel_2170_vu_employees_view_txn where EmployeeID =1; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2001.00 -3#!#adam#!#1st Street#!#3000.00 -~~END~~ - -~~ROW COUNT: 1~~ - -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -~~END~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -1#!#amber#!#1st Street#!#1000.00 -2#!#angel#!#1st Street#!#2001.00 -3#!#adam#!#1st Street#!#3000.00 -5#!#ash#!#1st Street#!#5000.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_delete; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -GO - --- Transition table join test -CREATE TRIGGER babel_2170_vu_employees_view_transition ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - UPDATE babel_2170_vu_employees_view set MonthSalary = i.MonthSalary + 15 FROM inserted as i - JOIN babel_2170_vu_employees_view AS v ON v.EmployeeID = i.EmployeeID -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = 5 WHERE EmployeeID = 2; -GO -~~ROW COUNT: 2~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view WHERE EmployeeID = 2; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -2#!#angel#!#1st Street#!#2015.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_transition; -GO - --- Recursive Trigger test Direct Recursion Trigger calling itself trigger 1 -> trigger 1 -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +100 WHERE EmployeeID = 2; -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -~~ROW COUNT: 1~~ - -~~ROW COUNT: 1~~ - - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view WHERE EmployeeID = 2; -GO -~~START~~ -int#!#varchar#!#varchar#!#numeric -2#!#angel#!#1st Street#!#2115.00 -~~END~~ - - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -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 - -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'); -GO -~~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 -BEGIN - SELECT 'Trigger db2_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked' -END -GO - --- should fire IOT trigger of second db -INSERT INTO babel_2170_vu_employees_view VALUES(3, 'adam', '1st Street db2_BABEL2170', '3000'); -GO -~~START~~ -varchar -Trigger db2_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked -~~END~~ - -~~ROW COUNT: 1~~ - - -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 -~~END~~ - - --- clean all objects in second database -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; -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-vu-cleanup.sql b/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql deleted file mode 100644 index 0f656cfde47..00000000000 --- a/test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql +++ /dev/null @@ -1,39 +0,0 @@ --- clean all objects in first database -USE db1_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 TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_bulkinsert; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_bulkinsert; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_2; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees; -GO - -DROP VIEW IF EXISTS babel_2170_vu_employees_view_txn; -GO - -DROP TABLE IF EXISTS babel_2170_vu_employees_txn; -GO - -USE MASTER; -GO - -DROP DATABASE IF EXISTS db1_BABEL2170; -GO \ No newline at end of file diff --git a/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql b/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql deleted file mode 100644 index cb31bf570b5..00000000000 --- a/test/JDBC/input/triggers/BABEL-2170-vu-prepare.sql +++ /dev/null @@ -1,93 +0,0 @@ --- We will create two databases db1_BABEL2170, db2_BABEL2170 -CREATE DATABASE db1_BABEL2170; -GO - -USE db1_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'); -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 VIEW babel_2170_vu_employees_view_bulkinsert AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'b%'; -GO - -CREATE VIEW babel_2170_vu_employees_view_2 AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - -CREATE SCHEMA schema_2170; -GO - -CREATE TABLE schema_2170.babel_2170_vu_employees -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO schema_2170.babel_2170_vu_employees VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO schema_2170.babel_2170_vu_employees VALUES(2, 'angel', '1st Street', '2000'); -GO - -CREATE VIEW schema_2170.babel_2170_vu_employees_view AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM schema_2170.babel_2170_vu_employees -WHERE EmployeeName LIKE 'a%'; -GO - -CREATE TABLE babel_2170_vu_employees_txn -( - EmployeeID int NOT NULL, - EmployeeName VARCHAR(50), - EmployeeAddress VARCHAR(50), - MonthSalary NUMERIC(10, 2) -) -GO - -INSERT INTO babel_2170_vu_employees_txn VALUES(1, 'amber', '1st Street', '1000'); -INSERT INTO babel_2170_vu_employees_txn VALUES(2, 'angel', '1st Street', '2000'); -GO - -CREATE VIEW babel_2170_vu_employees_view_txn AS -SELECT EmployeeID, - EmployeeName, - EmployeeAddress, - MonthSalary -FROM babel_2170_vu_employees_txn -WHERE EmployeeName LIKE 'a%'; -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 deleted file mode 100644 index 18b63fa2364..00000000000 --- a/test/JDBC/input/triggers/BABEL-2170-vu-verify.sql +++ /dev/null @@ -1,361 +0,0 @@ -USE db1_BABEL2170; -GO - --- Instead of Insert Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_insert ON babel_2170_vu_employees_view -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked' -END -GO - -INSERT INTO babel_2170_vu_employees_view VALUES(3, 'adam', '1st Street', '3000'); -GO - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees; -GO - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees_view; -GO - --- Instead of Update Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked' -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID,EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees WHERE EmployeeID = 2; -GO - -BEGIN TRANSACTION - UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID IN (1, 2); -COMMIT TRANSACTION; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees WHERE EmployeeID IN (1, 2) ORDER BY EmployeeID; -GO - --- Instead of Delete Trigger on View -CREATE TRIGGER babel_2170_vu_employees_view_iot_delete ON babel_2170_vu_employees_view -INSTEAD OF DELETE -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_delete Invoked' -END -GO - -BEGIN TRANSACTION - DELETE FROM babel_2170_vu_employees_view WHERE EmployeeID IN (1, 2); -COMMIT TRANSACTION; -GO - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees_view; -GO - -SELECT COUNT(EmployeeID) FROM babel_2170_vu_employees; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view ORDER BY EmployeeID; -GO - ---- Tests multiple insert queries and check if inserted table can be accessed and trigger is working fine. -CREATE TRIGGER babel_2170_vu_employees_view_iot_bulkinsert ON babel_2170_vu_employees_view_bulkinsert -INSTEAD OF INSERT -AS - SELECT * FROM INSERTED; -GO - -BEGIN TRANSACTION -DECLARE @i int = 1 - WHILE @i <= 3 - BEGIN - INSERT INTO babel_2170_vu_employees_view_bulkinsert VALUES(@i, 'bob', '1st Street', '1000'); - SET @i = @i + 1 - END -COMMIT TRANSACTION -GO - --- Same trigger name on different View created on Same table in same schema -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view_2 -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view2_iot_update Invoked' -END -GO - --- Same trigger name on a Table in same schema -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees -INSTEAD OF INSERT -AS -BEGIN - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees__table_iot_update Invoked' -END -GO - --- Test Instead of Update trigger in same db but cross schema - --- Cleanup default dbo schema IO Update trigger -DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; -GO - -CREATE TRIGGER [schema_2170].[babel_2170_vu_employees_view_iot_update] ON [schema_2170].[babel_2170_vu_employees_view] -INSTEAD OF UPDATE -AS - SELECT 'Trigger db1_BABEL2170.schema_2170.babel_2170_vu_employees_view_iot_update Invoked' -GO - -CREATE TRIGGER [babel_2170_vu_employees_view_iot_update] ON [babel_2170_vu_employees_view] -INSTEAD OF UPDATE -AS - SELECT 'Trigger db1_BABEL2170.dbo.babel_2170_vu_employees_view_iot_update Invoked' -GO - -UPDATE [schema_2170].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM [schema_2170].[babel_2170_vu_employees_view] ORDER BY EmployeeID; -GO - -UPDATE [dbo].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM [dbo].[babel_2170_vu_employees_view] ORDER BY EmployeeID; -GO - --- drop dbo schema trigger and test that schema_2170.update trigger is not dropped -DROP TRIGGER IF EXISTS [dbo].[babel_2170_vu_employees_view_iot_update]; -GO - -UPDATE [schema_2170].[babel_2170_vu_employees_view] SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -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 - -DROP SCHEMA IF EXISTS schema_2170; -GO - --- Test Transaction Commit and Rollback inside Instead of triggers -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn -INSTEAD OF UPDATE -AS - BEGIN - BEGIN TRAN; - INSERT INTO babel_2170_vu_employees_view_txn VALUES(3, 'adam', '1st Street', '3000'); - COMMIT tran; - END -GO - -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn -INSTEAD OF UPDATE -AS - BEGIN - BEGIN TRAN; - INSERT INTO babel_2170_vu_employees_view_txn VALUES(3, 'adam', '1st Street', '3000'); - ROLLBACK tran; - END -GO - -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_insert ON babel_2170_vu_employees_view_txn INSTEAD OF INSERT AS -BEGIN TRAN; -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -COMMIT; -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -SELECT * FROM inserted; -GO - -BEGIN TRAN; -GO -INSERT INTO babel_2170_vu_employees_view_txn VALUES(4, 'ana', '1st Street', '4000'); -GO -COMMIT; -GO - -BEGIN TRAN -GO -INSERT INTO babel_2170_vu_employees_view_txn VALUES(4, 'ana', '1st Street', '4000'); -GO -IF (@@trancount > 0) ROLLBACK; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_insert; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_update ON babel_2170_vu_employees_view_txn INSTEAD OF UPDATE AS -SAVE TRAN sp1; -SAVE TRAN sp2; -DELETE FROM babel_2170_vu_employees_view_txn where EmployeeID =2; -ROLLBACK TRAN sp1; -GO - -BEGIN TRAN -GO -SELECT @@trancount; -UPDATE babel_2170_vu_employees_view_txn SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO -IF (@@trancount > 0) ROLLBACK; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_update; -GO - -CREATE TRIGGER babel_2170_vu_employees_view_iot_txn_delete ON babel_2170_vu_employees_view_txn INSTEAD OF DELETE AS -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -INSERT INTO babel_2170_vu_employees_view_txn VALUES(5, 'ash', '1st Street', '5000'); -SELECT * FROM deleted; -GO - -DELETE FROM babel_2170_vu_employees_view_txn where EmployeeID =1; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view_txn ORDER BY EmployeeID; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_delete; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -GO - --- Transition table join test -CREATE TRIGGER babel_2170_vu_employees_view_transition ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - UPDATE babel_2170_vu_employees_view set MonthSalary = i.MonthSalary + 15 FROM inserted as i - JOIN babel_2170_vu_employees_view AS v ON v.EmployeeID = i.EmployeeID -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = 5 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view WHERE EmployeeID = 2; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_transition; -GO - --- Recursive Trigger test Direct Recursion Trigger calling itself trigger 1 -> trigger 1 -CREATE TRIGGER babel_2170_vu_employees_view_iot_update ON babel_2170_vu_employees_view -INSTEAD OF UPDATE -AS -BEGIN - UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +100 WHERE EmployeeID = 2; -END -GO - -UPDATE babel_2170_vu_employees_view SET MonthSalary = MonthSalary +1 WHERE EmployeeID = 2; -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view WHERE EmployeeID = 2; -GO - -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_update; -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 - -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'); -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 -BEGIN - SELECT 'Trigger db2_BABEL2170.dbo.babel_2170_vu_employees_view_iot_insert Invoked' -END -GO - --- should fire IOT trigger of second db -INSERT INTO babel_2170_vu_employees_view VALUES(3, 'adam', '1st Street db2_BABEL2170', '3000'); -GO - -SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu_employees_view ORDER BY EmployeeID; -GO - --- clean all objects in second database -DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_insert; -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/15_5/schedule b/test/JDBC/upgrade/15_5/schedule new file mode 100644 index 00000000000..9eca53fdc49 --- /dev/null +++ b/test/JDBC/upgrade/15_5/schedule @@ -0,0 +1,486 @@ +# Schedule File for JDBC Test Framework for local run +# 1. Lines starting with '#' will be treated as comments +# 2. To run a postgres command: cmd#!#postgresql#!# +# 3. To run a T-SQL command: cmd#!#sqlserver#!# +# 4. Keyword "all" is equivalent to running all test files in input folder +# 5. To add a test, add test name (without extension, , and . For example if test file name is TestBigInt.txt write TestBigInt) on a new line + +# This should be the first test to check there are no duplicated object_ids +BABEL-3613 + +app_name +atn2 +ATTIMEZONE-dep +AVG-Aggregate-common +AVG-Aggregate-Dep +BABEL-1062 +BABEL-1189 +BABEL-1206 +BABEL-1243 +BABEL-1249 +BABEL-1251 +BABEL-1291 +BABEL-1319 +BABEL-1438 +BABEL-1444 +BABEL-1465 +BABEL-1466 +BABEL-1475 +BABEL-1493 +BABEL-1510 +BABEL-1566 +BABEL-1625 +BABEL-1654 +BABEL-1683 +BABEL-1715 +BABEL-1953 +BABEL-1963 +BABEL-1994-CHAR +BABEL-1994-VARCHAR +BABEL-2086 +BABEL-2203 +BABEL-2208 +BABEL-2257 +BABEL-2449 +BABEL-2535 +BABEL-2688 +BABEL-2765 +BABEL-2787 +BABEL-2787-2 +BABEL-2795 +BABEL-2805 +BABEL-2819 +BABEL-2845 +BABEL-2877 +BABEL-2884 +BABEL-2917 +BABEL-2944 +BABEL-2955 +BABEL-3000 +BABEL-3000-dep +BABEL-3010 +BABEL-3116 +BABEL-3117 +BABEL-3118 +BABEL-3121 +BABEL-3144 +BABEL-3147 +BABEL-3166 +BABEL-3192 +BABEL-3204 +BABEL-3213 +BABEL-3215 +BABEL-3221 +BABEL-3234 +BABEL-3249 +BABEL-3268 +BABEL-328 +BABEL-3314 +BABEL-3326 +BABEL-3347 +BABEL-3358 +BABEL-3360 +BABEL-3369 +BABEL-3370 +BABEL-3380 +BABEL-3392 +BABEL-3402 +BABEL-3478 +BABEL-3486 +BABEL-3513 +BABEL-3556 +BABEL-3588 +BABEL-3614 +BABEL-3640 +BABEL-3646 +BABEL-3655 +BABEL-3657 +BABEL-3696 +BABEL-3697 +BABEL-3702 +BABEL-3725 +BABEL-3747 +BABEL-3748 +BABEL-3781 +BABEL-3801 +BABEL-3802 +BABEL-3818 +BABEL-3828 +BABEL-383 +BABEL-3844 +BABEL-3914 +BABEL-3938 +BABEL-3952 +BABEL-3953-datetrunc +BABEL-404 +BABEL-405 +BABEL-4078 +BABEL-4098 +BABEL-4214 +babel_417 +BABEL-493 +BABEL_539 +BABEL-621 +BABEL-728 +BABEL-733 +BABEL-741 +BABEL-745 +BABEL-775 +BABEL-889 +BABEL-937 +BABEL-APPLOCK +babel_char +BABEL-CHECK-CONSTRAINT +babel_context_info +BABEL-CROSS-DB +babel_datatype_sqlvariant +Babel_domain_mapping_test +BABEL-EXECUTE_AS_CALLER +BABEL-EXTENDEDPROPERTY +BABEL-EXTENDEDPROPERTY-v2 +babel_int4_varbinary_div +babelfish_authid_login_ext +babelfish_authid_user_ext +babelfish_cast_floor +babelfish_inconsistent_metadata +babelfish_integrity_checker +babelfish_migration_mode +babelfish_namespace_ext +babelfish_sysdatabases +babel_function_string +BABEL_GRANT_CONNECT +babel_isnumeric +BABEL_COL_NAME +BABEL-LOGIN +BABEL-LOGIN-USER-EXT +BABEL-NEXT-VALUE-FOR +BABEL_OBJECT_DEFINITION +BABEL_OBJECT_ID +BABEL_OBJECT_NAME +BABEL-PG-SYSTEM-FUNCTIONS +BABEL-PROCID +BABEL-RAND +BABEL-ROLE +BABEL-ROLE-MEMBER +BABEL_SCHEMATA +BABEL-SPCOLUMNS +BABEL-SPCOLUMNS-dep +BABEL-SP_COLUMNS_MANAGED-dep +BABEL-SP_DATATYPE_INFO +BABEL-SP_FKEYS +BABEL-SP_FKEYS-dep +BABEL-sp_helpdb +BABEL-SP_SPECIAL_COLUMNS +BABEL-SP_SPECIAL_COLUMNS_100-dep +BABEL-SP_SPECIAL_COLUMNS-dep +BABEL-SP_SPROC_COLUMNS +BABEL-SP_SPROC_COLUMNS_100-dep +BABEL-SP_SPROC_COLUMNS-dep +BABEL-SP_STORED_PROCEDURES +BABEL-SP_STORED_PROCEDURES-dep +BABEL-SP_TABLE_PRIVILIGES +BABEL-SP_TABLES +babel_sqlvariant_cast_compare +BABEL-SQUARE +BABEL-TABLEOPTIONS +babel_trigger +babel_try_parse +BABEL-USER +babel_varbinary_int4_div +bbf_view_def +binary-index +bitwise_not-operator +case_insensitive_collation +cast_numeric_types_to_datetime +cast_numeric_types_to_smalldatetime +col_length +collation_tests +collation_tests_arabic +collation_tests_greek +collation_tests_mongolian +collation_tests_polish +column_domain_usage +constraint_column_usage +dateadd_internal_df +datepart +datetime2fromparts-after-15-2 +forjson +forjson-datatypes +forjson-subquery +forjson-nesting +format +format-dep +forxml +forxml-subquery +fulltextserviceproperty +FULLTEXT_INDEX +fts-contains +get_tds_id +HAS_DBACCESS +identity_function +indexproperty +insteadof_nested_trigger_inside_proc +insteadof_nested_trigger_with_dml +insteadoftriggers_with_transaction +ISC-Columns +isc-schemata-dep +ISC-sequences +ISC-Table_Constraints +ISC-Tables +ISC-Views +is_srvrolemember +jira-BABEL-3504-upgrade +key_column_usage +linked_servers +msdb-dbo-fn_syspolicy_is_automation_enabled +msdb-dbo-syspolicy_configuration +msdb-dbo-syspolicy_system_health_state +nested_trigger_inside_proc +nested_trigger_with_dml +objectpropertyex +openjson +openquery_upgrd_before_15_4 +orderby +routines_definition +rowcount +schema_resolution_func +schema_resolution_proc +schema_resolution_trigger +select-strip-parens +sp_describe_first_result_set +sp_tablecollations +smalldatetimefromparts-dep +str +switchoffset-dep +sys-all_columns +sys-all_columns-dep +sys_all_objects +sys_all_objects-dep +sys-all_parameters +sys-all_parameters-dep +sys-all_sql_modules +sys-all_sql_modules-dep +sys-all_views +sys-assemblies +sys-assembly_modules +sys-assembly_types +sys_babelfish_configurations_view +sys-change_tracking_databases +sys-change_tracking_tables +sys-check_constraints +sys-check_constraints-dep +sys-column-property +sys-columns +sys-columns-dep +sys-computed_columns +sys-computed_columns-dep +sys-configurations +sys-database_files +sys-database_filestream_options +sys-database_mirroring +sys_database_principals_dep +sys_syslogins_dep +sys-database_recovery_status +sys-databases +sys-databases-dep +sys-data_spaces +sys-datefirst +sys-default_constraints +sys-default_constraints-dep +sys-dm_exec_connections +sys-dm_exec_connections-dep +sys-dm_exec_sessions +sys-dm_exec_sessions-dep +sys-dm_hadr_cluster +sys-dm_hadr_database_replica_states +sys-dm_os_host_info +sys-endpoints +sys-eomonth +sys-events +sys-extended_properties +sys-sql_expression_dependencies +sys-filegroups +sys-filetables +sys-filetable_system_defined_objects +sys-foreign_key_columns +sys-foreign_key_columns-dep +sys-foreign_keys +sys-foreign_keys-dep +sys-fulltext_catalogs +sys-fulltext_index_columns +sys-fulltext_indexes +sys-fulltext_languages +sys-fulltext_stoplists +sys-hash_indexes +sys-has_perms_by_name +sys-has_perms_by_name-dep +sys-host_name +sys-identity_columns +sys-identity_columns-dep +sys-index_columns +sys-index_columns-dep +sys-indexes +sys-indexes-dep +sys-key_constraints +sys-key_constraints-dep +sys-lock_timeout +sys-master_files +sys-max_connections +sys-nestlevel-dep +sys-numbered_procedures +sys-objects +sys-original_login +sys-parsename +sys-partitions +sys-partitions-dep +sys-plan_guides +sys-procedures +sys-proc_param_helper-dep +sys-registered_search_property_lists +sys-schema-name +sys-schemas +sys-schemas-dep +sys-selective_xml_index_paths +sys-server_principals +sys_server_role_members +sys_server_principals_dep +sys-sid_binary +sys-spatial_indexes +sys-spatial_index_tessellations +sys-sp_databases +sys-sp_databases-dep +sys-sp_pkeys +sys-sp_pkeys-dep +sys-sp_statistics +sys-sp_statistics-dep +sys-sp_tables_view +sys-sp_tables_view-dep +sys-sql_modules +sys-sql_modules-dep +sys-stats +sys-suser_sid +sys-suser_sname +sys-synonyms +sys-syscharsets +sys-syscolumns +sys-syscolumns-dep +sys-sysdatabases +sys-sysforeignkeys +sys-sysforeignkeys-dep +sys-sysindexes +sys-syslanguages +sys-sysobjects +sys-system_objects +sys-system_sql_modules +sys-system_sql_modules-dep +sys-systypes +sys_sysusers_dep +sys-tables +sys-tables-dep +sys-table_types +sys-table_types-dep +sys-table_types_internal +sys-table_types_internal-dep +SYSTEM_USER +sys-trigger_events +sys-trigger_nestlevel +sys-triggers +sys-triggers-dep +sys-types +sys-types-dep +sys-userid +sys-views +sys-views-dep +sys-xml_indexes +sys-xml_schema_collections +table-variable +tdscollation +temp-tables +TestBigInt +TestBinary +TestBIT +TestChar +Test-Computed-Columns +TestDate +TestDatetime +TestDatetime2 +TestDatetime-numeric-dateaddfunction +TestDatetime-numeric-representation +TestDecimal +TestFloat +Test-Identity +TestImage +TestInt +TestMoney +TestNotNull +TestNumeric +TestReal +TestRowVersion +TestSmallDatetime +TestSmallInt +TestSmallMoney +TestSpatialPoint +Test-sp_addrole +Test-sp_addrolemember +Test-sp_babelfish_volatility +Test-sp_droprole +Test-sp_droprolemember +Test-sp_execute_postgresql +Test-sp_helpdbfixedrole +Test-sp_helprole-dep +Test-sp_helprolemember-dep +Test-sp_helpsrvrolemember +Test-sp_helpuser +Test-sp_rename +Test-sp_rename-dep +Test-sp_set_session_context +Test-sp_set_session_context-dep +TestSQLVariant +TestTableType +TestText +TestTime +TestTinyInt +TestUDD +TestUniqueIdentifier +Test_user_from_win_login +TestVarChar +TestVariableDataLength +test_windows_alter_login +test_windows_alter_user +test_windows_login +test_windows_sp_helpuser +TestXML +timefromparts +todatetimeoffset-dep +triggers_with_transaction +typeid-typename +typeid-typename-dep +unquoted_string +doublequoted_string +alter_authorization_change_db_owner +sp_changedbowner +datetimeoffset-timezone +BABEL-4046 +host_id +linked_srv_4229 +BABEL-4175 +sp_who +BABEL_4330 +kill +BABEL-4217 +Test_ISNULL +BABEL-4270 +BABEL-4410 +BABEL-4231 +typeproperty-dep +sys_asymmetric_keys +sys_certificates +sys_database_permissions +BABEL-4279 +BABEL-4484 +pivot +#AUTO_ANALYZE #uncomment this test when preparing for new minor version +cast_eliminate +TestDatatypeAggSort +babel_index_nulls_order +BABEL-2999 diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 3be4297ef66..dd1cafb6d7a 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -38,7 +38,6 @@ BABEL-1963 BABEL-1994-CHAR BABEL-1994-VARCHAR BABEL-2086 -BABEL-2170 BABEL-2203 BABEL-2208 BABEL-2257