Skip to content

Commit

Permalink
Crash fix IO view trigger inserted is used with join
Browse files Browse the repository at this point in the history
This commit will solve crash script listed in BABEL-4514
When inserted table is used with join inside trigger body,
Instead of Trigger on View was causing server crash

Task: BABEL-2170

Signed-off-by: Deepakshi Mittal <[email protected]>
  • Loading branch information
deepakshi-mittal committed Nov 9, 2023
1 parent 671e23a commit acee19f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
32 changes: 30 additions & 2 deletions test/JDBC/expected/BABEL-2170-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,38 @@ int#!#varchar#!#varchar#!#numeric
DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_delete;
GO

-- Recursive Trigger test Direct Recursion Trigger calling itself trigger 1 -> trigger 1
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
Expand All @@ -506,7 +534,7 @@ SELECT EmployeeID, EmployeeName, EmployeeAddress, MonthSalary FROM babel_2170_vu
GO
~~START~~
int#!#varchar#!#varchar#!#numeric
2#!#angel#!#1st Street#!#2100.00
2#!#angel#!#1st Street#!#2115.00
~~END~~


Expand Down
21 changes: 20 additions & 1 deletion test/JDBC/input/triggers/BABEL-2170-vu-verify.sql
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,29 @@ GO
DROP TRIGGER IF EXISTS babel_2170_vu_employees_view_iot_txn_delete;
GO

-- Recursive Trigger test Direct Recursion Trigger calling itself trigger 1 -> trigger 1
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
Expand Down

0 comments on commit acee19f

Please sign in to comment.