Skip site navigation (1) Skip section navigation (2)

pgsql: Remove collation information from TypeName,where it does not be

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Remove collation information from TypeName,where it does not be
Date: 2011-03-10 03:39:36
Message-ID: (view raw or whole thread)
Lists: pgsql-committers
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
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.



Modified Files
doc/src/sgml/ref/alter_table.sgml                |   10 +-
doc/src/sgml/ref/alter_type.sgml                 |    4 +-
doc/src/sgml/ref/create_domain.sgml              |    5 +-
doc/src/sgml/ref/create_table.sgml               |    6 +-
src/backend/access/common/tupdesc.c              |    3 +-
src/backend/commands/collationcmds.c             |    2 +-
src/backend/commands/functioncmds.c              |    4 +-
src/backend/commands/sequence.c                  |   23 ++--
src/backend/commands/tablecmds.c                 |   65 +++++---
src/backend/commands/typecmds.c                  |   27 +++-
src/backend/commands/view.c                      |   13 ++-
src/backend/nodes/copyfuncs.c                    |    7 +-
src/backend/nodes/equalfuncs.c                   |    7 +-
src/backend/nodes/makefuncs.c                    |    5 +-
src/backend/nodes/outfuncs.c                     |    5 +-
src/backend/parser/gram.y                        |  182 +++++++++++++++++-----
src/backend/parser/parse_expr.c                  |   17 +--
src/backend/parser/parse_func.c                  |    4 +-
src/backend/parser/parse_relation.c              |    3 +-
src/backend/parser/parse_type.c                  |  166 +++++++++-----------
src/backend/parser/parse_utilcmd.c               |   46 +++++-
src/backend/utils/adt/ruleutils.c                |    5 +-
src/include/nodes/makefuncs.h                    |    2 +-
src/include/nodes/parsenodes.h                   |   17 ++-
src/include/parser/parse_type.h                  |   14 +-
src/pl/plpgsql/src/pl_comp.c                     |    2 +-
src/test/regress/expected/collate.linux.utf8.out |   12 +-
src/test/regress/expected/foreign_data.out       |    2 +-
28 files changed, 412 insertions(+), 246 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2011-03-10 04:08:37
Subject: Re: pgsql: Added new version of ecpg's parser generator script. This one wa
Previous:From: Bruce MomjianDate: 2011-03-10 02:40:00
Subject: Re: pgsql: Added new version of ecpg's parser generator script. This one wa

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group