diff options
author | Tom Lane | 2011-03-10 03:38:52 +0000 |
---|---|---|
committer | Tom Lane | 2011-03-10 03:39:20 +0000 |
commit | a051ef699c3ed1f89088dd6bbc2574f13d0b20eb (patch) | |
tree | fe7f6e5d17f704eae2d85afece0abe19ddff5ee0 /src/test | |
parent | 01752f7bba627c0c38d594b27e50238015272828 (diff) |
Remove collation information from TypeName, where it does not belong.
The initial collations patch treated a COLLATE spec as part of a TypeName,
following what can only be described as brain fade on the part of the SQL
committee. It's a lot more reasonable to treat COLLATE as a syntactically
separate object, so that it can be added in only the productions where it
actually belongs, rather than needing to reject it in a boatload of places
where it doesn't belong (something the original patch mostly failed to do).
In addition this change lets us meet the spec's requirement to allow
COLLATE anywhere in the clauses of a ColumnDef, and it avoids unfriendly
behavior for constructs such as "foo::type COLLATE collation".
To do this, pull collation information out of TypeName and put it in
ColumnDef instead, thus reverting most of the collation-related changes in
parse_type.c's API. I made one additional structural change, which was to
use a ColumnDef as an intermediate node in AT_AlterColumnType AlterTableCmd
nodes. This provides enough room to get rid of the "transform" wart in
AlterTableCmd too, since the ColumnDef can carry the USING expression
easily enough.
Also fix some other minor bugs that have crept in in the same areas,
like failure to copy recently-added fields of ColumnDef in copyfuncs.c.
While at it, document the formerly secret ability to specify a collation
in ALTER TABLE ALTER COLUMN TYPE, ALTER TYPE ADD ATTRIBUTE, and
ALTER TYPE ALTER ATTRIBUTE TYPE; and correct some misstatements about
what the default collation selection will be when COLLATE is omitted.
BTW, the three-parameter form of format_type() should go away too,
since it just contributes to the confusion in this area; but I'll do
that in a separate patch.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/collate.linux.utf8.out | 12 | ||||
-rw-r--r-- | src/test/regress/expected/foreign_data.out | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out index caa65b2f37f..5ad5de2f00b 100644 --- a/src/test/regress/expected/collate.linux.utf8.out +++ b/src/test/regress/expected/collate.linux.utf8.out @@ -20,21 +20,21 @@ CREATE TABLE collate_test_fail ( ); ERROR: collation "ja_JP.eucjp" for current database encoding "UTF8" does not exist LINE 3: b text COLLATE "ja_JP.eucjp" - ^ + ^ CREATE TABLE collate_test_fail ( a int, b text COLLATE "foo" ); ERROR: collation "foo" for current database encoding "UTF8" does not exist LINE 3: b text COLLATE "foo" - ^ + ^ CREATE TABLE collate_test_fail ( a int COLLATE "en_US.utf8", b text ); ERROR: collations are not supported by type integer LINE 2: a int COLLATE "en_US.utf8", - ^ + ^ CREATE TABLE collate_test_like ( LIKE collate_test1 ); @@ -632,9 +632,9 @@ ERROR: no collation was derived for column "b" with collatable type text HINT: Use the COLLATE clause to set the collation explicitly. -- casting SELECT CAST('42' AS text COLLATE "C"); -ERROR: COLLATE clause not allowed in cast target +ERROR: syntax error at or near "COLLATE" LINE 1: SELECT CAST('42' AS text COLLATE "C"); - ^ + ^ SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2; a | b ---+----- @@ -727,6 +727,8 @@ CREATE INDEX collate_test1_idx4 ON collate_test1 (a COLLATE "C"); -- fail ERROR: collations are not supported by type integer CREATE INDEX collate_test1_idx5 ON collate_test1 ((a COLLATE "C")); -- fail ERROR: collations are not supported by type integer +LINE 1: ...ATE INDEX collate_test1_idx5 ON collate_test1 ((a COLLATE "C... + ^ SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%'; relname | pg_get_indexdef --------------------+---------------------------------------------------------------------------------------------- diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index 00730f25cb8..a7473349fdf 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -693,7 +693,7 @@ ERROR: "ft1" is not a table or view ALTER FOREIGN TABLE ft1 ALTER COLUMN c6 SET NOT NULL; ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 DROP NOT NULL; ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) using '0'; -- ERROR -ERROR: ALTER TYPE USING is not supported on foreign tables +ERROR: ALTER TYPE USING is only supported on plain tables ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE text; -- can't change the column type if it's used elsewhere |