diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-09 22:38:52 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-09 22:39:20 -0500 |
| commit | a051ef699c3ed1f89088dd6bbc2574f13d0b20eb (patch) | |
| tree | fe7f6e5d17f704eae2d85afece0abe19ddff5ee0 /src/include/parser | |
| 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/include/parser')
| -rw-r--r-- | src/include/parser/parse_type.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h index 8621ab678d0..92c9ecba4ac 100644 --- a/src/include/parser/parse_type.h +++ b/src/include/parser/parse_type.h @@ -20,21 +20,19 @@ typedef HeapTuple Type; extern Type LookupTypeName(ParseState *pstate, const TypeName *typeName, - int32 *typmod_p, Oid *collid_p); + int32 *typmod_p); extern Type typenameType(ParseState *pstate, const TypeName *typeName, - int32 *typmod_p, Oid *collid_p); - -extern Oid LookupCollation(ParseState *pstate, List *collnames, int location); - + int32 *typmod_p); extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName); extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, - Oid *typeid_p, int32 *typmod_p); -extern void typenameTypeIdModColl(ParseState *pstate, const TypeName *typeName, - Oid *typeid_p, int32 *typmod_p, Oid *collid_p); + Oid *typeid_p, int32 *typmod_p); extern char *TypeNameToString(const TypeName *typeName); extern char *TypeNameListToString(List *typenames); +extern Oid LookupCollation(ParseState *pstate, List *collnames, int location); +extern Oid GetColumnDefCollation(ParseState *pstate, ColumnDef *coldef, Oid typeOid); + extern Type typeidType(Oid id); extern Oid typeTypeId(Type tp); |
