Skip to content

Commit

Permalink
sql/logictest: move DROP PROCEDURE tests to their own file
Browse files Browse the repository at this point in the history
This commit moves `DROP PROCEDURE` tests to their own file so that they
can be disabled for the mixed version configuration in a future commit.

Release note: None
  • Loading branch information
mgartner committed Oct 7, 2023
1 parent 8303a8c commit 9802c88
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 155 deletions.
7 changes: 7 additions & 0 deletions pkg/ccl/logictestccl/tests/3node-tenant/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

145 changes: 145 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/drop_procedure
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
statement ok
CREATE PROCEDURE p_test_drop() LANGUAGE SQL AS 'SELECT 1'

statement ok
CREATE PROCEDURE p_test_drop(int) LANGUAGE SQL AS 'SELECT 1'

statement ok
CREATE SCHEMA sc1

statement ok
CREATE PROCEDURE sc1.p_test_drop(int) LANGUAGE SQL AS 'SELECT 1'

statement ok
SET search_path = public,sc1

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop] ORDER BY 1
----
CREATE PROCEDURE public.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$
CREATE PROCEDURE public.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement error pgcode 42883 function p_test_drop\(\) does not exist
DROP FUNCTION p_test_drop

statement error pgcode 42725 pq: procedure name \"p_test_drop\" is not unique
DROP PROCEDURE p_test_drop

statement ok
DROP PROCEDURE IF EXISTS p_not_existing

statement error pgcode 42883 pq: unknown procedure: p_not_existing\(\)
DROP PROCEDURE p_not_existing

# Dropping a procedure twice should fail.
statement error pgcode 42883 pq: procedure p_test_drop\(\) does not exist
BEGIN;
DROP PROCEDURE p_test_drop();
DROP PROCEDURE p_test_drop();
COMMIT;

statement ok
ROLLBACK

statement ok
DROP PROCEDURE p_test_drop()

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]
----
CREATE PROCEDURE public.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

# Drop with two identical procedure signatures should be ok. And only first
# match in path should be drop.
statement ok
DROP PROCEDURE p_test_drop(INT), p_test_drop(INT)

statement error pgcode 42883 pq: unknown procedure: public.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement ok
DROP PROCEDURE p_test_drop(INT)

statement error pgcode 42883 pq: unknown procedure: sc1.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]

# If there are identical procedure signatures in different schemas, multiple
# drop statements should drop them all. This matches postgres behavior.
statement ok
CREATE PROCEDURE public.p_test_drop() LANGUAGE SQL AS $$ SELECT 1 $$;
CREATE PROCEDURE sc1.p_test_drop() LANGUAGE SQL AS $$ SELECT 1 $$;

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]
----
CREATE PROCEDURE public.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement ok
BEGIN;
DROP PROCEDURE p_test_drop();
DROP PROCEDURE p_test_drop();
COMMIT;

statement error pgcode 42883 pq: unknown procedure: public.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]

statement error pgcode 42883 pq: unknown procedure: sc1.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]

statement ok
SET search_path = public

statement ok
DROP SCHEMA sc1
155 changes: 0 additions & 155 deletions pkg/sql/logictest/testdata/logic_test/drop_routine
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
subtest drop_function

statement ok
CREATE FUNCTION f_test_drop() RETURNS INT LANGUAGE SQL AS $$ SELECT 1 $$;

Expand Down Expand Up @@ -177,156 +175,3 @@ SET search_path = public

statement ok
DROP SCHEMA sc1;

subtest end


subtest drop_procedure

statement ok
CREATE PROCEDURE p_test_drop() LANGUAGE SQL AS 'SELECT 1'

statement ok
CREATE PROCEDURE p_test_drop(int) LANGUAGE SQL AS 'SELECT 1'

statement ok
CREATE SCHEMA sc1

statement ok
CREATE PROCEDURE sc1.p_test_drop(int) LANGUAGE SQL AS 'SELECT 1'

statement ok
SET search_path = public,sc1

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop] ORDER BY 1
----
CREATE PROCEDURE public.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$
CREATE PROCEDURE public.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement error pgcode 42883 function p_test_drop\(\) does not exist
DROP FUNCTION p_test_drop

statement error pgcode 42725 pq: procedure name \"p_test_drop\" is not unique
DROP PROCEDURE p_test_drop

statement ok
DROP PROCEDURE IF EXISTS p_not_existing

statement error pgcode 42883 pq: unknown procedure: p_not_existing\(\)
DROP PROCEDURE p_not_existing

# Dropping a procedure twice should fail.
statement error pgcode 42883 pq: procedure p_test_drop\(\) does not exist
BEGIN;
DROP PROCEDURE p_test_drop();
DROP PROCEDURE p_test_drop();
COMMIT;

statement ok
ROLLBACK

statement ok
DROP PROCEDURE p_test_drop()

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]
----
CREATE PROCEDURE public.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

# Drop with two identical procedure signatures should be ok. And only first
# match in path should be drop.
statement ok
DROP PROCEDURE p_test_drop(INT), p_test_drop(INT)

statement error pgcode 42883 pq: unknown procedure: public.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop(IN INT8)
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement ok
DROP PROCEDURE p_test_drop(INT)

statement error pgcode 42883 pq: unknown procedure: sc1.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]

# If there are identical procedure signatures in different schemas, multiple
# drop statements should drop them all. This matches postgres behavior.
statement ok
CREATE PROCEDURE public.p_test_drop() LANGUAGE SQL AS $$ SELECT 1 $$;
CREATE PROCEDURE sc1.p_test_drop() LANGUAGE SQL AS $$ SELECT 1 $$;

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]
----
CREATE PROCEDURE public.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$

query T
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]
----
CREATE PROCEDURE sc1.p_test_drop()
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement ok
BEGIN;
DROP PROCEDURE p_test_drop();
DROP PROCEDURE p_test_drop();
COMMIT;

statement error pgcode 42883 pq: unknown procedure: public.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE public.p_test_drop]

statement error pgcode 42883 pq: unknown procedure: sc1.p_test_drop\(\)
SELECT create_statement FROM [SHOW CREATE PROCEDURE sc1.p_test_drop]

statement ok
SET search_path = public

statement ok
DROP SCHEMA sc1

subtest end
7 changes: 7 additions & 0 deletions pkg/sql/logictest/tests/fakedist-disk/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/sql/logictest/tests/fakedist-vec-off/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/sql/logictest/tests/fakedist/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9802c88

Please sign in to comment.