Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT SQUASH MERGE] Fixes after community merge #3224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions test/JDBC/expected/TestInteropProcedures.out
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,132 @@ GO
-- psql currentSchema=master_dbo,public
DROP PROCEDURE psql_interop_proc
GO


-- psql currentSchema=master_dbo,public
CREATE FUNCTION pg_stable_func()
RETURNS INT
AS $$
BEGIN
RETURN (SELECT id FROM t); END;
$$ LANGUAGE plpgsql STABLE;
GO

CREATE PROCEDURE pg_proc_inner(i INT)
AS $$
BEGIN
INSERT INTO TEMP VALUES (i);
END;
$$ LANGUAGE plpgsql;
GO

CREATE OR REPLACE PROCEDURE pg_proc_outer()
AS $$
BEGIN
BEGIN
UPDATE t SET id = 2;
CALL pg_proc_inner(pg_stable_func());
EXCEPTION WHEN DIVISION_BY_ZERO THEN
RAISE NOTICE '%', SQLERRM;
END;
END;
$$ LANGUAGE plpgsql;
GO

-- tsql
CREATE TABLE t(id INT)
GO
CREATE TABLE temp(id INT)
GO
INSERT INTO t VALUES (1)
GO
~~ROW COUNT: 1~~


CREATE PROC ptsql_proc AS EXEC pg_proc_outer; UPDATE t SET id = 1;
GO


-- BEGIN TRAN -> tsql proc -> pg_proc_outer -> pg_proc_inner with a plpgsql stable function in argument
BEGIN TRAN
GO
EXEC ptsql_proc
GO
~~ROW COUNT: 1~~

COMMIT
GO

-- tsql proc -> pg_proc_outer -> pg_proc_inner with a plpgsql stable function in argument
-- same test as above but no explicit transaction block
EXEC ptsql_proc
GO
~~ROW COUNT: 1~~



-- psql currentSchema=master_dbo,public
CREATE FUNCTION pltsql_stable_func()
RETURNS INT
AS $$
BEGIN
RETURN (SELECT id FROM t);
END;
$$ LANGUAGE PLTSQL STABLE;
GO

CREATE OR REPLACE PROCEDURE pg_proc_outer()
AS $$
BEGIN
BEGIN
UPDATE t SET id = 2;
CALL pg_proc_inner(pltsql_stable_func());
EXCEPTION WHEN DIVISION_BY_ZERO THEN
RAISE NOTICE '%', SQLERRM;
END;
END;
$$ LANGUAGE plpgsql;
GO

-- tsql
-- BEGIN TRAN -> tsql proc -> pg_proc_outer -> pg_proc_inner with a pltsql stable function in argument
BEGIN TRAN
GO
EXEC ptsql_proc
GO
~~ROW COUNT: 1~~

COMMIT
GO

-- tsql proc -> pg_proc_outer -> pg_proc_inner with a pltsql stable function in argument
-- same test as above but no explicit transaction block
EXEC ptsql_proc
GO
~~ROW COUNT: 1~~


-- we should only see "2" since we always update value before inserting
SELECT * FROM temp
GO
~~START~~
int
2
2
2
2
~~END~~


DROP PROCEDURE ptsql_proc
GO

DROP TABLE t, temp
GO

-- psql currentSchema=master_dbo,public
DROP PROCEDURE IF EXISTS pg_proc_inner, pg_proc_outer;
GO

DROP FUNCTION IF EXISTS pg_stable_func, pltsql_stable_func;
GO
12 changes: 6 additions & 6 deletions test/JDBC/expected/parallel_query/BABEL-1444.out
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
master_dbo
~~END~~

SELECT current_setting('search_path');
Expand Down Expand Up @@ -98,7 +98,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
dbo
~~END~~

SELECT current_setting('search_path');
Expand Down Expand Up @@ -135,7 +135,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
dbo
~~END~~

SELECT current_setting('search_path');
Expand Down Expand Up @@ -168,7 +168,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
master_dbo
~~END~~

SELECT current_setting('search_path');
Expand Down Expand Up @@ -200,7 +200,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
master_dbo
~~END~~

SELECT current_setting('search_path');
Expand Down Expand Up @@ -233,7 +233,7 @@ SELECT current_setting('role');
GO
~~START~~
text
none
master_dbo
~~END~~

SELECT current_setting('search_path');
Expand Down
111 changes: 111 additions & 0 deletions test/JDBC/input/interoperability/TestInteropProcedures.mix
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,114 @@ GO
-- psql currentSchema=master_dbo,public
DROP PROCEDURE psql_interop_proc
GO


-- psql currentSchema=master_dbo,public
CREATE FUNCTION pg_stable_func()
RETURNS INT
AS $$
BEGIN
RETURN (SELECT id FROM t); END;
$$ LANGUAGE plpgsql STABLE;
GO

CREATE PROCEDURE pg_proc_inner(i INT)
AS $$
BEGIN
INSERT INTO TEMP VALUES (i);
END;
$$ LANGUAGE plpgsql;
GO

CREATE OR REPLACE PROCEDURE pg_proc_outer()
AS $$
BEGIN
BEGIN
UPDATE t SET id = 2;
CALL pg_proc_inner(pg_stable_func());
EXCEPTION WHEN DIVISION_BY_ZERO THEN
RAISE NOTICE '%', SQLERRM;
END;
END;
$$ LANGUAGE plpgsql;
GO

-- tsql
CREATE TABLE t(id INT)
GO
CREATE TABLE temp(id INT)
GO
INSERT INTO t VALUES (1)
GO

CREATE PROC ptsql_proc AS EXEC pg_proc_outer; UPDATE t SET id = 1;
GO


-- BEGIN TRAN -> tsql proc -> pg_proc_outer -> pg_proc_inner with a plpgsql stable function in argument
BEGIN TRAN
GO
EXEC ptsql_proc
GO
COMMIT
GO

-- same test as above but no explicit transaction block
-- tsql proc -> pg_proc_outer -> pg_proc_inner with a plpgsql stable function in argument
EXEC ptsql_proc
GO


-- psql currentSchema=master_dbo,public
CREATE FUNCTION pltsql_stable_func()
RETURNS INT
AS $$
BEGIN
RETURN (SELECT id FROM t);
END;
$$ LANGUAGE PLTSQL STABLE;
GO

CREATE OR REPLACE PROCEDURE pg_proc_outer()
AS $$
BEGIN
BEGIN
UPDATE t SET id = 2;
CALL pg_proc_inner(pltsql_stable_func());
EXCEPTION WHEN DIVISION_BY_ZERO THEN
RAISE NOTICE '%', SQLERRM;
END;
END;
$$ LANGUAGE plpgsql;
GO

-- tsql
-- BEGIN TRAN -> tsql proc -> pg_proc_outer -> pg_proc_inner with a pltsql stable function in argument
BEGIN TRAN
GO
EXEC ptsql_proc
GO
COMMIT
GO

-- same test as above but no explicit transaction block
-- tsql proc -> pg_proc_outer -> pg_proc_inner with a pltsql stable function in argument
EXEC ptsql_proc
GO

-- we should only see "2" since we always update value before inserting
SELECT * FROM temp
GO

DROP PROCEDURE ptsql_proc
GO

DROP TABLE t, temp
GO

-- psql currentSchema=master_dbo,public
DROP PROCEDURE IF EXISTS pg_proc_inner, pg_proc_outer;
GO

DROP FUNCTION IF EXISTS pg_stable_func, pltsql_stable_func;
GO
Loading