mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Don't allow CREATE TABLE AS to create a column with invalid collation
It is possible that an expression ends up with a collatable type but without a collation. CREATE TABLE AS could then create a table based on that. But such a column cannot be dumped with valid SQL syntax, so we disallow creating such a column. per test report from Noah Misch
This commit is contained in:
@ -4206,7 +4206,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
|
||||
typeOid = HeapTupleGetOid(typeTuple);
|
||||
|
||||
/* make sure datatype is legal for a column */
|
||||
CheckAttributeType(colDef->colname, typeOid, false);
|
||||
CheckAttributeType(colDef->colname, typeOid, collOid, false);
|
||||
|
||||
/* construct new attribute's pg_attribute entry */
|
||||
attribute.attrelid = myrelid;
|
||||
@ -6515,7 +6515,7 @@ ATPrepAlterColumnType(List **wqueue,
|
||||
typenameTypeIdModColl(NULL, typeName, &targettype, &targettypmod, &targetcollid);
|
||||
|
||||
/* make sure datatype is legal for a column */
|
||||
CheckAttributeType(colName, targettype, false);
|
||||
CheckAttributeType(colName, targettype, targetcollid, false);
|
||||
|
||||
if (tab->relkind == RELKIND_RELATION)
|
||||
{
|
||||
|
Reference in New Issue
Block a user