-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add error case for nested inter dialect proc call
Signed-off-by: Tanzeel Khan <[email protected]>
- Loading branch information
1 parent
4912577
commit 021f7e9
Showing
2 changed files
with
161 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,124 @@ | ||
DECLARE @a TABLE (a INT); | ||
INSERT INTO @a EXECUTE('SELECT * FROM t1; SELECT 3'); | ||
GO | ||
|
||
-- Test nested procedure calls with rollback and error case | ||
|
||
-- tsql | ||
|
||
CREATE TABLE babel_4360_t (id INT); | ||
GO | ||
|
||
-- psql currentSchema=master_dbo,public | ||
|
||
CREATE PROCEDURE psql_interop_proc1() | ||
AS | ||
$$ | ||
BEGIN | ||
ROLLBACK; | ||
INSERT INTO babel_4360_t VALUES (99); | ||
END | ||
$$ LANGUAGE PLPGSQL; | ||
GO | ||
|
||
CREATE PROCEDURE psql_interop_proc2() | ||
AS | ||
$$ | ||
BEGIN | ||
CALL psql_interop_proc1(); | ||
INSERT INTO babel_4360_t VALUES (98); | ||
END | ||
$$ LANGUAGE PLPGSQL; | ||
GO | ||
|
||
-- tsql | ||
|
||
CREATE PROCEDURE tsql_interop_proc1 | ||
AS | ||
EXEC psql_interop_proc2; | ||
INSERT INTO babel_4360_t VALUES (97); | ||
GO | ||
|
||
CREATE PROCEDURE tsql_interop_proc2 | ||
AS | ||
EXEC tsql_interop_proc1; | ||
INSERT INTO babel_4360_t VALUES (96); | ||
GO | ||
|
||
-- psql currentSchema=master_dbo,public | ||
|
||
CREATE PROCEDURE psql_interop_proc3() | ||
AS | ||
$$ | ||
BEGIN | ||
CALL tsql_interop_proc2(); | ||
INSERT INTO babel_4360_t VALUES (95); | ||
END | ||
$$ LANGUAGE PLPGSQL; | ||
GO | ||
|
||
CREATE PROCEDURE psql_interop_proc4() | ||
AS | ||
$$ | ||
BEGIN | ||
CALL psql_interop_proc3(); | ||
INSERT INTO babel_4360_t VALUES (94); | ||
END | ||
$$ LANGUAGE PLPGSQL; | ||
GO | ||
|
||
-- tsql | ||
|
||
CREATE PROCEDURE tsql_interop_proc3 | ||
AS | ||
EXEC psql_interop_proc4; | ||
INSERT INTO babel_4360_t VALUES (93); | ||
GO | ||
|
||
CREATE PROCEDURE tsql_interop_proc4 | ||
AS | ||
EXEC tsql_interop_proc3; | ||
INSERT INTO babel_4360_t VALUES (92); | ||
GO | ||
|
||
EXEC tsql_interop_proc4; | ||
GO | ||
|
||
SELECT * FROM babel_4360_t | ||
GO | ||
|
||
DELETE FROM babel_4360_t; | ||
GO | ||
|
||
-- alter procedure to throw error | ||
-- psql currentSchema=master_dbo,public | ||
CREATE OR REPLACE PROCEDURE psql_interop_proc1() | ||
AS | ||
$$ | ||
BEGIN | ||
INSERT INTO babel_4360_t VALUES (101); | ||
ROLLBACK; | ||
INSERT INTO babel_4360_t VALUES (100); | ||
COMMIT; | ||
INSERT INTO babel_4360_t VALUES (99); | ||
RAISE EXCEPTION 'Throw an exception to check error case'; | ||
END | ||
$$ LANGUAGE PLPGSQL; | ||
GO | ||
|
||
-- tsql | ||
EXEC tsql_interop_proc4; | ||
GO | ||
|
||
SELECT * FROM babel_4360_t | ||
GO | ||
|
||
DROP TABLE babel_4360_t | ||
GO | ||
|
||
DROP PROCEDURE IF EXISTS tsql_interop_proc4, tsql_interop_proc3, tsql_interop_proc2, tsql_interop_proc1; | ||
GO | ||
|
||
-- psql currentSchema=master_dbo,public | ||
DROP PROCEDURE IF EXISTS psql_interop_proc4, psql_interop_proc3, psql_interop_proc2, psql_interop_proc1; | ||
GO |