From b9cff97fdf486eca7e563a9696a7391048814d0f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 4 Mar 2011 23:39:44 +0200 Subject: 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 --- src/backend/commands/tablecmds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e76ce2ceb13..3be9a6f3481 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -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) { -- cgit v1.2.3