diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/create_type.out | 43 | ||||
-rw-r--r-- | src/test/regress/expected/opr_sanity.out | 2 | ||||
-rw-r--r-- | src/test/regress/sql/create_type.sql | 34 | ||||
-rw-r--r-- | src/test/regress/sql/opr_sanity.sql | 2 |
4 files changed, 53 insertions, 28 deletions
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out index 8309756030..eb55e255d6 100644 --- a/src/test/regress/expected/create_type.out +++ b/src/test/regress/expected/create_type.out @@ -83,8 +83,10 @@ SELECT * FROM default_test; zippo | 42 (1 row) +-- We need a shell type to test some CREATE TYPE failure cases with +CREATE TYPE bogus_type; -- invalid: non-lowercase quoted identifiers -CREATE TYPE case_int42 ( +CREATE TYPE bogus_type ( "Internallength" = 4, "Input" = int42_in, "Output" = int42_out, @@ -111,6 +113,20 @@ WARNING: type attribute "Passedbyvalue" not recognized LINE 7: "Passedbyvalue" ^ ERROR: type input function must be specified +-- invalid: input/output function incompatibility +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32); +ERROR: type input function array_in must return type bogus_type +DROP TYPE bogus_type; +-- It no longer is possible to issue CREATE TYPE without making a shell first +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32); +ERROR: type "bogus_type" does not exist +HINT: Create the type as a shell type, then create its I/O functions, then do a full CREATE TYPE. -- Test stand-alone composite type CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42); CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS ' @@ -137,28 +153,25 @@ ERROR: type "text_w_default" already exists DROP TYPE default_test_row CASCADE; NOTICE: drop cascades to function get_default_test() DROP TABLE default_test; --- Check type create with input/output incompatibility -CREATE TYPE not_existing_type (INPUT = array_in, - OUTPUT = array_out, - ELEMENT = int, - INTERNALLENGTH = 32); -ERROR: function array_out(not_existing_type) does not exist --- Check dependency transfer of opaque functions when creating a new type -CREATE FUNCTION base_fn_in(cstring) RETURNS opaque AS 'boolin' +-- Check dependencies are established when creating a new type +CREATE TYPE base_type; +CREATE FUNCTION base_fn_in(cstring) RETURNS base_type AS 'boolin' LANGUAGE internal IMMUTABLE STRICT; -CREATE FUNCTION base_fn_out(opaque) RETURNS opaque AS 'boolout' +NOTICE: return type base_type is only a shell +CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS 'boolout' LANGUAGE internal IMMUTABLE STRICT; +NOTICE: argument type base_type is only a shell CREATE TYPE base_type(INPUT = base_fn_in, OUTPUT = base_fn_out); -WARNING: changing argument type of function base_fn_out from "opaque" to base_type -WARNING: changing return type of function base_fn_in from opaque to base_type -WARNING: changing return type of function base_fn_out from opaque to cstring DROP FUNCTION base_fn_in(cstring); -- error ERROR: cannot drop function base_fn_in(cstring) because other objects depend on it DETAIL: type base_type depends on function base_fn_in(cstring) function base_fn_out(base_type) depends on type base_type HINT: Use DROP ... CASCADE to drop the dependent objects too. -DROP FUNCTION base_fn_out(opaque); -- error -ERROR: function base_fn_out(opaque) does not exist +DROP FUNCTION base_fn_out(base_type); -- error +ERROR: cannot drop function base_fn_out(base_type) because other objects depend on it +DETAIL: type base_type depends on function base_fn_out(base_type) +function base_fn_in(cstring) depends on type base_type +HINT: Use DROP ... CASCADE to drop the dependent objects too. DROP TYPE base_type; -- error ERROR: cannot drop type base_type because other objects depend on it DETAIL: function base_fn_in(cstring) depends on type base_type diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index fb6c029e3d..40468e8f49 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -384,7 +384,7 @@ FROM pg_proc as p1 WHERE p1.prorettype = 'cstring'::regtype AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typoutput = p1.oid) AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typmodout = p1.oid) - AND p1.oid != 'shell_out(opaque)'::regprocedure + AND p1.oid != 'shell_out(void)'::regprocedure ORDER BY 1; oid | proname ------+-------------- diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql index 3d1deba97c..68b04fd4fe 100644 --- a/src/test/regress/sql/create_type.sql +++ b/src/test/regress/sql/create_type.sql @@ -84,8 +84,11 @@ INSERT INTO default_test DEFAULT VALUES; SELECT * FROM default_test; +-- We need a shell type to test some CREATE TYPE failure cases with +CREATE TYPE bogus_type; + -- invalid: non-lowercase quoted identifiers -CREATE TYPE case_int42 ( +CREATE TYPE bogus_type ( "Internallength" = 4, "Input" = int42_in, "Output" = int42_out, @@ -94,6 +97,20 @@ CREATE TYPE case_int42 ( "Passedbyvalue" ); +-- invalid: input/output function incompatibility +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32); + +DROP TYPE bogus_type; + +-- It no longer is possible to issue CREATE TYPE without making a shell first +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32); + -- Test stand-alone composite type CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42); @@ -119,20 +136,15 @@ DROP TYPE default_test_row CASCADE; DROP TABLE default_test; --- Check type create with input/output incompatibility -CREATE TYPE not_existing_type (INPUT = array_in, - OUTPUT = array_out, - ELEMENT = int, - INTERNALLENGTH = 32); - --- Check dependency transfer of opaque functions when creating a new type -CREATE FUNCTION base_fn_in(cstring) RETURNS opaque AS 'boolin' +-- Check dependencies are established when creating a new type +CREATE TYPE base_type; +CREATE FUNCTION base_fn_in(cstring) RETURNS base_type AS 'boolin' LANGUAGE internal IMMUTABLE STRICT; -CREATE FUNCTION base_fn_out(opaque) RETURNS opaque AS 'boolout' +CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS 'boolout' LANGUAGE internal IMMUTABLE STRICT; CREATE TYPE base_type(INPUT = base_fn_in, OUTPUT = base_fn_out); DROP FUNCTION base_fn_in(cstring); -- error -DROP FUNCTION base_fn_out(opaque); -- error +DROP FUNCTION base_fn_out(base_type); -- error DROP TYPE base_type; -- error DROP TYPE base_type CASCADE; diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql index 8351b6469a..f06f245db3 100644 --- a/src/test/regress/sql/opr_sanity.sql +++ b/src/test/regress/sql/opr_sanity.sql @@ -309,7 +309,7 @@ FROM pg_proc as p1 WHERE p1.prorettype = 'cstring'::regtype AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typoutput = p1.oid) AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typmodout = p1.oid) - AND p1.oid != 'shell_out(opaque)'::regprocedure + AND p1.oid != 'shell_out(void)'::regprocedure ORDER BY 1; -- Check for length inconsistencies between the various argument-info arrays. |