Skip to content

Commit

Permalink
add error case for nested inter dialect proc call
Browse files Browse the repository at this point in the history
Signed-off-by: Tanzeel Khan <[email protected]>
  • Loading branch information
tanscorpio7 committed Dec 27, 2023
1 parent 4912577 commit 021f7e9
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/JDBC/expected/BABEL_4360.out
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,43 @@ int
~~END~~


DELETE FROM babel_4360_t;
GO
~~ROW COUNT: 8~~


-- psql currentSchema=master_dbo,public
-- alter procedure to throw error
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
~~ERROR (Code: 33557097)~~

~~ERROR (Message: Throw an exception to check error case)~~


SELECT * FROM babel_4360_t
GO
~~START~~
int
100
~~END~~


DROP TABLE babel_4360_t
GO

Expand Down
124 changes: 124 additions & 0 deletions test/JDBC/input/BABEL_4360.mix
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

0 comments on commit 021f7e9

Please sign in to comment.