Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49a642a

Browse files
committed
Add check for matching column collations in ALTER TABLE ... INHERIT.
The other DDL operations that create an inheritance relationship werechecking for collation match already, but this one got missed.Also fix comments that failed to mention collation checks.
1 parentc947325 commit49a642a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
14341434

14351435
/*
14361436
* Yes, try to merge the two column definitions. They must
1437-
* have the same typeandtypmod.
1437+
* have the same type, typmod,andcollation.
14381438
*/
14391439
ereport(NOTICE,
14401440
(errmsg("merging multiple inherited definitions of column \"%s\"",
@@ -1620,7 +1620,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
16201620

16211621
/*
16221622
* Yes, try to merge the two column definitions. They must
1623-
* have the same typeandtypmod.
1623+
* have the same type, typmod,andcollation.
16241624
*/
16251625
ereport(NOTICE,
16261626
(errmsg("merging column \"%s\" with inherited definition",
@@ -4121,7 +4121,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
41214121
int32ctypmod;
41224122
Oidccollid;
41234123

4124-
/* Child column must matchby type */
4124+
/* Child column must matchon type, typmod, and collation */
41254125
typenameTypeIdAndMod(NULL,colDef->typeName,&ctypeId,&ctypmod);
41264126
if (ctypeId!=childatt->atttypid||
41274127
ctypmod!=childatt->atttypmod)
@@ -8178,7 +8178,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
81788178
attributeName);
81798179
if (HeapTupleIsValid(tuple))
81808180
{
8181-
/* Check they are same typeandtypmod */
8181+
/* Check they are same type, typmod,andcollation */
81828182
Form_pg_attributechildatt= (Form_pg_attribute)GETSTRUCT(tuple);
81838183

81848184
if (attribute->atttypid!=childatt->atttypid||
@@ -8189,6 +8189,17 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
81898189
RelationGetRelationName(child_rel),
81908190
attributeName)));
81918191

8192+
if (attribute->attcollation!=childatt->attcollation)
8193+
ereport(ERROR,
8194+
(errcode(ERRCODE_COLLATION_MISMATCH),
8195+
errmsg("child table \"%s\" has different collation for column \"%s\"",
8196+
RelationGetRelationName(child_rel),
8197+
attributeName)));
8198+
8199+
/*
8200+
* Check child doesn't discard NOT NULL property. (Other
8201+
* constraints are checked elsewhere.)
8202+
*/
81928203
if (attribute->attnotnull&& !childatt->attnotnull)
81938204
ereport(ERROR,
81948205
(errcode(ERRCODE_DATATYPE_MISMATCH),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp