You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
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 SQLcommittee. It's a lot more reasonable to treat COLLATE as a syntacticallyseparate object, so that it can be added in only the productions where itactually belongs, rather than needing to reject it in a boatload of placeswhere it doesn't belong (something the original patch mostly failed to do).In addition this change lets us meet the spec's requirement to allowCOLLATE anywhere in the clauses of a ColumnDef, and it avoids unfriendlybehavior for constructs such as "foo::type COLLATE collation".To do this, pull collation information out of TypeName and put it inColumnDef instead, thus reverting most of the collation-related changes inparse_type.c's API. I made one additional structural change, which was touse a ColumnDef as an intermediate node in AT_AlterColumnType AlterTableCmdnodes. This provides enough room to get rid of the "transform" wart inAlterTableCmd too, since the ColumnDef can carry the USING expressioneasily 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 collationin ALTER TABLE ALTER COLUMN TYPE, ALTER TYPE ADD ATTRIBUTE, andALTER TYPE ALTER ATTRIBUTE TYPE; and correct some misstatements aboutwhat 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 dothat in a separate patch.
DROP [ COLUMN ] [ IF EXISTS ] <replaceable class="PARAMETER">column</replaceable> [ RESTRICT | CASCADE ]
37
-
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> [ SET DATA ] TYPE <replaceable class="PARAMETER">type</replaceable> [ USING <replaceable class="PARAMETER">expression</replaceable> ]
37
+
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> [ SET DATA ] TYPE <replaceable class="PARAMETER">data_type</replaceable> [ COLLATE <replaceable class="PARAMETER">collation</replaceable> ] [ USING <replaceable class="PARAMETER">expression</replaceable> ]
38
38
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET DEFAULT <replaceable class="PARAMETER">expression</replaceable>
39
39
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> DROP DEFAULT
40
40
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET | DROP } NOT NULL
@@ -115,7 +115,11 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
115
115
This form changes the type of a column of a table. Indexes and
116
116
simple table constraints involving the column will be automatically
117
117
converted to use the new column type by reparsing the originally
118
-
supplied expression. The optional <literal>USING</literal>
118
+
supplied expression.
119
+
The optional <literal>COLLATE</literal> clause specifies a collation
120
+
for the new column; if omitted, the collation is the default for the
121
+
new column type.
122
+
The optional <literal>USING</literal>
119
123
clause specifies how to compute the new column value from the old;
120
124
if omitted, the default conversion is the same as an assignment
121
125
cast from old data type to new. A <literal>USING</literal>
DROP ATTRIBUTE [ IF EXISTS ] <replaceable class="PARAMETER">attribute_name</replaceable> [ CASCADE | RESTRICT ]
37
-
ALTER ATTRIBUTE <replaceable class="PARAMETER">attribute_name</replaceable> [ SET DATA ] TYPE <replaceable class="PARAMETER">data_type</replaceable> [ CASCADE | RESTRICT ]
37
+
ALTER ATTRIBUTE <replaceable class="PARAMETER">attribute_name</replaceable> [ SET DATA ] TYPE <replaceable class="PARAMETER">data_type</replaceable> [COLLATE <replaceable class="PARAMETER">collation</replaceable> ] [CASCADE | RESTRICT ]