Skip to content

Commit

Permalink
Fix failing test cases in github, added to upadte schedule
Browse files Browse the repository at this point in the history
Task: BABEL-2170

Signed-off-by: Deepakshi Mittal <[email protected]>
  • Loading branch information
deepakshi-mittal committed Oct 9, 2023
1 parent 25bcbd8 commit 5981054
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 144 deletions.
70 changes: 70 additions & 0 deletions test/JDBC/expected/BABEL-2170-txn_test.out
Original file line number Diff line number Diff line change
@@ -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
33 changes: 1 addition & 32 deletions test/JDBC/expected/BABEL-2170-vu-cleanup.out
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 0 additions & 39 deletions test/JDBC/expected/BABEL-2170-vu-prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

92 changes: 88 additions & 4 deletions test/JDBC/expected/BABEL-2170-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions test/JDBC/input/triggers/BABEL-2170-txn_test.sql
Original file line number Diff line number Diff line change
@@ -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
33 changes: 1 addition & 32 deletions test/JDBC/input/triggers/BABEL-2170-vu-cleanup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 5981054

Please sign in to comment.