From 9aa3c782c939f29bd562a22030fb3a64e6f18365 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 12 May 2007 00:55:00 +0000 Subject: Fix the problem that creating a user-defined type named _foo, followed by one named foo, would work but the other ordering would not. If a user-specified type or table name collides with an existing auto-generated array name, just rename the array type out of the way by prepending more underscores. This should not create any backward-compatibility issues, since the cases in which this will happen would have failed outright in prior releases. Also fix an oversight in the arrays-of-composites patch: ALTER TABLE RENAME renamed the table's rowtype but not its array type. --- src/test/regress/expected/arrays.out | 23 +++++++++++++++++++++++ src/test/regress/sql/arrays.sql | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'src/test') diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index 643ae7f39b..936db41c4b 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -871,3 +871,26 @@ SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest; {4,2,6,7,8,1} | {} | {{white,yellow},{pink,orange}} | {{black,red},{green,orange}} | {2.1,3.3,1.8,1.7,1.6} | {1.6} (1 row) +-- A few simple tests for arrays of composite types +create type comptype as (f1 int, f2 text); +create table comptable (c1 comptype, c2 comptype[]); +-- XXX would like to not have to specify row() construct types here ... +insert into comptable + values (row(1,'foo'), array[row(2,'bar')::comptype, row(3,'baz')::comptype]); +-- check that implicitly named array type _comptype isn't a problem +create type _comptype as enum('fooey'); +select * from comptable; + c1 | c2 +---------+----------------------- + (1,foo) | {"(2,bar)","(3,baz)"} +(1 row) + +select c2[2].f2 from comptable; + f2 +----- + baz +(1 row) + +drop type _comptype; +drop table comptable; +drop type comptype; diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index 1f574a0184..a60bf560fa 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -318,3 +318,23 @@ SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest; INSERT INTO arraggtest (f1, f2, f3) VALUES ('{}','{{pink,white,blue,red,grey,orange}}','{2.1,1.87,1.4,2.2}'); SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest; + +-- A few simple tests for arrays of composite types + +create type comptype as (f1 int, f2 text); + +create table comptable (c1 comptype, c2 comptype[]); + +-- XXX would like to not have to specify row() construct types here ... +insert into comptable + values (row(1,'foo'), array[row(2,'bar')::comptype, row(3,'baz')::comptype]); + +-- check that implicitly named array type _comptype isn't a problem +create type _comptype as enum('fooey'); + +select * from comptable; +select c2[2].f2 from comptable; + +drop type _comptype; +drop table comptable; +drop type comptype; -- cgit v1.2.3