diff options
author | Abbas | 2011-12-27 16:05:59 +0000 |
---|---|---|
committer | Abbas | 2011-12-27 16:05:59 +0000 |
commit | da2fe0454e8344d1cb5b4239c4e87b26364d5e60 (patch) | |
tree | 5ef08c93e0e3d1c63c1c076f666b9c474e08103c | |
parent | c06dfe06aa8d8d0ac1b6d2a445f0ae93cee9bac3 (diff) |
Some changes in test cases and expected output files related to composite types.
-rw-r--r-- | src/test/regress/expected/create_type_1.out | 122 | ||||
-rw-r--r-- | src/test/regress/expected/rowtypes_1.out | 6 | ||||
-rw-r--r-- | src/test/regress/expected/typed_table_1.out | 21 | ||||
-rw-r--r-- | src/test/regress/sql/rowtypes.sql | 3 | ||||
-rw-r--r-- | src/test/regress/sql/typed_table.sql | 13 |
5 files changed, 24 insertions, 141 deletions
diff --git a/src/test/regress/expected/create_type_1.out b/src/test/regress/expected/create_type_1.out deleted file mode 100644 index e22c9aa5fe..0000000000 --- a/src/test/regress/expected/create_type_1.out +++ /dev/null @@ -1,122 +0,0 @@ --- --- CREATE_TYPE --- --- --- Note: widget_in/out were created in create_function_1, without any --- prior shell-type creation. These commands therefore complete a test --- of the "old style" approach of making the functions first. --- -CREATE TYPE widget ( - internallength = 24, - input = widget_in, - output = widget_out, - typmod_in = numerictypmodin, - typmod_out = numerictypmodout, - alignment = double -); -CREATE TYPE city_budget ( - internallength = 16, - input = int44in, - output = int44out, - element = int4, - category = 'x', -- just to verify the system will take it - preferred = true -- ditto -); --- Test creation and destruction of shell types -CREATE TYPE shell; -CREATE TYPE shell; -- fail, type already present -ERROR: type "shell" already exists -DROP TYPE shell; -DROP TYPE shell; -- fail, type not exist -ERROR: type "shell" does not exist --- --- Test type-related default values (broken in releases before PG 7.2) --- --- This part of the test also exercises the "new style" approach of making --- a shell type and then filling it in. --- -CREATE TYPE int42; -CREATE TYPE text_w_default; --- Make dummy I/O routines using the existing internal support for int4, text -CREATE FUNCTION int42_in(cstring) - RETURNS int42 - AS 'int4in' - LANGUAGE internal STRICT; -NOTICE: return type int42 is only a shell -CREATE FUNCTION int42_out(int42) - RETURNS cstring - AS 'int4out' - LANGUAGE internal STRICT; -NOTICE: argument type int42 is only a shell -CREATE FUNCTION text_w_default_in(cstring) - RETURNS text_w_default - AS 'textin' - LANGUAGE internal STRICT; -NOTICE: return type text_w_default is only a shell -CREATE FUNCTION text_w_default_out(text_w_default) - RETURNS cstring - AS 'textout' - LANGUAGE internal STRICT; -NOTICE: argument type text_w_default is only a shell -CREATE TYPE int42 ( - internallength = 4, - input = int42_in, - output = int42_out, - alignment = int4, - default = 42, - passedbyvalue -); -CREATE TYPE text_w_default ( - internallength = variable, - input = text_w_default_in, - output = text_w_default_out, - alignment = int4, - default = 'zippo' -); -CREATE TABLE default_test (f1 text_w_default, f2 int42); -INSERT INTO default_test DEFAULT VALUES; -SELECT * FROM default_test; - f1 | f2 --------+---- - zippo | 42 -(1 row) - --- 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 ' - SELECT * FROM default_test; -' LANGUAGE SQL; -SELECT * FROM get_default_test(); - f1 | f2 --------+---- - zippo | 42 -(1 row) - --- Test comments -COMMENT ON TYPE bad IS 'bad comment'; -ERROR: type "bad" does not exist -COMMENT ON TYPE default_test_row IS 'good comment'; -COMMENT ON TYPE default_test_row IS NULL; -COMMENT ON COLUMN default_test_row.nope IS 'bad comment'; -ERROR: column "nope" of relation "default_test_row" does not exist -COMMENT ON COLUMN default_test_row.f1 IS 'good comment'; -COMMENT ON COLUMN default_test_row.f1 IS NULL; --- Check shell type create for existing types -CREATE TYPE text_w_default; -- should fail -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 usage of typmod with a user-defined type --- (we have borrowed numeric's typmod functions) -CREATE TEMP TABLE mytab (foo widget(42,13,7)); -- should fail -ERROR: invalid NUMERIC type modifier -LINE 1: CREATE TEMP TABLE mytab (foo widget(42,13,7)); - ^ -CREATE TEMP TABLE mytab (foo widget(42,13)); -ERROR: PG-XC does not yet support temporary tables -SELECT format_type(atttypid,atttypmod) FROM pg_attribute -WHERE attrelid = 'mytab'::regclass AND attnum > 0; -ERROR: relation "mytab" does not exist -LINE 2: WHERE attrelid = 'mytab'::regclass AND attnum > 0; - ^ diff --git a/src/test/regress/expected/rowtypes_1.out b/src/test/regress/expected/rowtypes_1.out index b345e04c8b..a566cc156f 100644 --- a/src/test/regress/expected/rowtypes_1.out +++ b/src/test/regress/expected/rowtypes_1.out @@ -101,14 +101,14 @@ select * from people; (Joe,Blow,Jr) | 01-10-1984 (1 row) --- PGXCTODO: This test case makes a server crash due to query deparsing in planner --- insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); +insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); select * from quadtable order by f1, q; f1 | q ----+--------------------------- 1 | ("(3.3,4.4)","(5.5,6.6)") 2 | ("(,4.4)","(5.5,6.6)") -(2 rows) + 44 | ("(55,)","(,66)") +(3 rows) -- The object here is to ensure that toasted references inside -- composite values don't cause problems. The large f1 value will diff --git a/src/test/regress/expected/typed_table_1.out b/src/test/regress/expected/typed_table_1.out index c365f13db7..5c7fc0c9e6 100644 --- a/src/test/regress/expected/typed_table_1.out +++ b/src/test/regress/expected/typed_table_1.out @@ -83,10 +83,17 @@ CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used ERROR: type stuff is not a composite type DROP TABLE stuff; -- implicit casting --- 2011/07/05 PGXCTODO: This test case crashes the server --- CREATE TYPE person_type AS (id int, name text); --- CREATE TABLE persons OF person_type; --- INSERT INTO persons VALUES (1, 'test'); --- CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$; --- SELECT id, namelen(persons) FROM persons; --- DROP TYPE person_type CASCADE; +CREATE TYPE person_type AS (id int, name text); +CREATE TABLE persons OF person_type; +INSERT INTO persons VALUES (1, 'test'); +CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$; +SELECT id, namelen(persons) FROM persons; + id | namelen +----+--------- + 1 | 4 +(1 row) + +DROP TYPE person_type CASCADE; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to table persons +drop cascades to function namelen(person_type) diff --git a/src/test/regress/sql/rowtypes.sql b/src/test/regress/sql/rowtypes.sql index 236096da74..a8b4d4dc39 100644 --- a/src/test/regress/sql/rowtypes.sql +++ b/src/test/regress/sql/rowtypes.sql @@ -58,8 +58,7 @@ update people set fn.suffix = 'Jr'; select * from people; --- PGXCTODO: This test case makes a server crash due to query deparsing in planner --- insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); +insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66); select * from quadtable order by f1, q; diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql index 07d2d1c49e..0ff58288fe 100644 --- a/src/test/regress/sql/typed_table.sql +++ b/src/test/regress/sql/typed_table.sql @@ -52,12 +52,11 @@ DROP TABLE stuff; -- implicit casting --- 2011/07/05 PGXCTODO: This test case crashes the server --- CREATE TYPE person_type AS (id int, name text); --- CREATE TABLE persons OF person_type; --- INSERT INTO persons VALUES (1, 'test'); +CREATE TYPE person_type AS (id int, name text); +CREATE TABLE persons OF person_type; +INSERT INTO persons VALUES (1, 'test'); --- CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$; --- SELECT id, namelen(persons) FROM persons; +CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$; +SELECT id, namelen(persons) FROM persons; --- DROP TYPE person_type CASCADE; +DROP TYPE person_type CASCADE; |