| 1 |
# Test that concurrent DROP and CREATE commands do not leave behind |
| 2 |
# references to non-existent objects. |
| 3 |
|
| 4 |
setup |
| 5 |
{ |
| 6 |
CREATE SCHEMA testschema; |
| 7 |
CREATE SCHEMA alterschema; |
| 8 |
CREATE TYPE public.foo as enum ('one', 'two'); |
| 9 |
CREATE TYPE public.footab as enum ('three', 'four'); |
| 10 |
CREATE DOMAIN id AS int; |
| 11 |
CREATE FUNCTION f() RETURNS int LANGUAGE SQL RETURN 1; |
| 12 |
CREATE FUNCTION public.falter() RETURNS int LANGUAGE SQL RETURN 1; |
| 13 |
CREATE FOREIGN DATA WRAPPER fdw_wrapper; |
| 14 |
CREATE ROLE regress_dependency; |
| 15 |
} |
| 16 |
|
| 17 |
teardown |
| 18 |
{ |
| 19 |
DROP FUNCTION IF EXISTS testschema.foo(); |
| 20 |
DROP FUNCTION IF EXISTS fooargtype(num foo); |
| 21 |
DROP FUNCTION IF EXISTS footrettype(); |
| 22 |
DROP FUNCTION IF EXISTS foofunc(); |
| 23 |
DROP FUNCTION IF EXISTS public.falter(); |
| 24 |
DROP FUNCTION IF EXISTS alterschema.falter(); |
| 25 |
DROP DOMAIN IF EXISTS idid; |
| 26 |
DROP SERVER IF EXISTS srv_fdw_wrapper; |
| 27 |
DROP TABLE IF EXISTS tabtype; |
| 28 |
DROP SCHEMA IF EXISTS testschema; |
| 29 |
DROP SCHEMA IF EXISTS alterschema; |
| 30 |
DROP TYPE IF EXISTS public.foo; |
| 31 |
DROP TYPE IF EXISTS public.footab; |
| 32 |
DROP DOMAIN IF EXISTS id; |
| 33 |
DROP FUNCTION IF EXISTS f(); |
| 34 |
DROP FOREIGN DATA WRAPPER IF EXISTS fdw_wrapper; |
| 35 |
DROP ROLE regress_dependency; |
| 36 |
} |
| 37 |
|
| 38 |
session "s1" |
| 39 |
|
| 40 |
step "s1_begin" { BEGIN; } |
| 41 |
step "s1_create_function_in_schema" { CREATE FUNCTION testschema.foo() RETURNS int AS 'select 1' LANGUAGE sql; } |
| 42 |
step "s1_create_function_with_argtype" { CREATE FUNCTION fooargtype(num foo) RETURNS int AS 'select 1' LANGUAGE sql; } |
| 43 |
step "s1_create_function_with_rettype" { CREATE FUNCTION footrettype() RETURNS id LANGUAGE sql RETURN 1; } |
| 44 |
step "s1_create_function_with_function" { CREATE FUNCTION foofunc() RETURNS int LANGUAGE SQL RETURN f() + 1; } |
| 45 |
step "s1_alter_function_owner" { ALTER FUNCTION public.falter() OWNER TO regress_dependency; } |
| 46 |
step "s1_alter_function_schema" { ALTER FUNCTION public.falter() SET SCHEMA alterschema; } |
| 47 |
step "s1_create_domain_with_domain" { CREATE DOMAIN idid as id; } |
| 48 |
step "s1_create_table_with_type" { CREATE TABLE tabtype(a footab); } |
| 49 |
step "s1_create_server_with_fdw_wrapper" { CREATE SERVER srv_fdw_wrapper FOREIGN DATA WRAPPER fdw_wrapper; } |
| 50 |
step "s1_commit" { COMMIT; } |
| 51 |
|
| 52 |
session "s2" |
| 53 |
|
| 54 |
step "s2_begin" { BEGIN; } |
| 55 |
step "s2_drop_schema" { DROP SCHEMA testschema; } |
| 56 |
step "s2_drop_alterschema" { DROP SCHEMA alterschema; } |
| 57 |
step "s2_drop_foo_type" { DROP TYPE public.foo; } |
| 58 |
step "s2_drop_foo_rettype" { DROP DOMAIN id; } |
| 59 |
step "s2_drop_footab_type" { DROP TYPE public.footab; } |
| 60 |
step "s2_drop_function_f" { DROP FUNCTION f(); } |
| 61 |
step "s2_drop_domain_id" { DROP DOMAIN id; } |
| 62 |
step "s2_drop_fdw_wrapper" { DROP FOREIGN DATA WRAPPER fdw_wrapper RESTRICT; } |
| 63 |
step "s2_drop_role" { DROP ROLE regress_dependency; } |
| 64 |
step "s2_commit" { COMMIT; } |
| 65 |
|
| 66 |
# create function - drop schema |
| 67 |
permutation "s1_begin" "s1_create_function_in_schema" "s2_drop_schema" "s1_commit" |
| 68 |
permutation "s2_begin" "s2_drop_schema" "s1_create_function_in_schema" "s2_commit" |
| 69 |
|
| 70 |
# alter function - drop schema |
| 71 |
permutation "s1_begin" "s1_alter_function_schema" "s2_drop_alterschema" "s1_commit" |
| 72 |
permutation "s2_begin" "s2_drop_alterschema" "s1_alter_function_schema" "s2_commit" |
| 73 |
|
| 74 |
# create function - drop argtype |
| 75 |
permutation "s1_begin" "s1_create_function_with_argtype" "s2_drop_foo_type" "s1_commit" |
| 76 |
permutation "s2_begin" "s2_drop_foo_type" "s1_create_function_with_argtype" "s2_commit" |
| 77 |
|
| 78 |
# create function - drop rettype |
| 79 |
permutation "s1_begin" "s1_create_function_with_rettype" "s2_drop_foo_rettype" "s1_commit" |
| 80 |
permutation "s2_begin" "s2_drop_foo_rettype" "s1_create_function_with_rettype" "s2_commit" |
| 81 |
|
| 82 |
# create function - drop function used in its body |
| 83 |
permutation "s1_begin" "s1_create_function_with_function" "s2_drop_function_f" "s1_commit" |
| 84 |
permutation "s2_begin" "s2_drop_function_f" "s1_create_function_with_function" "s2_commit" |
| 85 |
|
| 86 |
# create domain over domain - drop the base domain |
| 87 |
permutation "s1_begin" "s1_create_domain_with_domain" "s2_drop_domain_id" "s1_commit" |
| 88 |
permutation "s2_begin" "s2_drop_domain_id" "s1_create_domain_with_domain" "s2_commit" |
| 89 |
|
| 90 |
# create table - drop type used in column |
| 91 |
permutation "s1_begin" "s1_create_table_with_type" "s2_drop_footab_type" "s1_commit" |
| 92 |
permutation "s2_begin" "s2_drop_footab_type" "s1_create_table_with_type" "s2_commit" |
| 93 |
|
| 94 |
# create server - drop foreign data wrapper |
| 95 |
permutation "s1_begin" "s1_create_server_with_fdw_wrapper" "s2_drop_fdw_wrapper" "s1_commit" |
| 96 |
permutation "s2_begin" "s2_drop_fdw_wrapper" "s1_create_server_with_fdw_wrapper" "s2_commit" |
| 97 |
|
| 98 |
# create function - drop owner role |
| 99 |
permutation "s1_begin" "s1_alter_function_owner" "s2_drop_role" "s1_commit" |
| 100 |
|
| 101 |
# XXX: This permutation is disabled because the error message, "role |
| 102 |
# <OID> was concurrently dropped", contains an OID that is not stable. |
| 103 |
# |
| 104 |
# permutation "s2_begin" "s2_drop_role" "s1_alter_function_owner" "s2_commit" |