-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently Postgres does not support Instead of Trigger On Views for DML queries. On running such a query on VIEW, query rewriting substitutes view with underlying base table. Added a hook for skipping the substitution for DML query on the VIEW. This change will add support for Instead of Triggers for DML queries when using Babelfish. Task: BABEL-2170/BABEL-4532/BABEL-4514 Signed-off-by: Deepakshi Mittal <[email protected]>
- Loading branch information
1 parent
dff6a8f
commit fc8ac98
Showing
8 changed files
with
1,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
-- 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 |
Oops, something went wrong.