1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +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:
Peter Eisentraut
2011-03-04 23:39:44 +02:00
parent 8d3b421f5f
commit b9cff97fdf
6 changed files with 28 additions and 8 deletions

View File

@@ -352,6 +352,8 @@ ConstructTupleDescriptor(Relation heapRelation,
to->atthasdef = false;
to->attislocal = true;
to->attinhcount = 0;
to->attcollation = collationObjectId[i];
}
else
{
@@ -388,6 +390,8 @@ ConstructTupleDescriptor(Relation heapRelation,
to->atttypmod = -1;
to->attislocal = true;
to->attcollation = collationObjectId[i];
ReleaseSysCache(tuple);
/*
@@ -399,11 +403,9 @@ ConstructTupleDescriptor(Relation heapRelation,
* whether a table column is of a safe type (which is why we
* needn't check for the non-expression case).
*/
CheckAttributeType(NameStr(to->attname), to->atttypid, false);
CheckAttributeType(NameStr(to->attname), to->atttypid, to->attcollation, false);
}
to->attcollation = collationObjectId[i];
/*
* We do not yet have the correct relation OID for the index, so just
* set it invalid for now. InitializeAttributeOids() will fix it