From dbbf9580358c18d78a2a11492b166818e3c19eec Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 16 Jun 2023 12:10:23 +0200 Subject: [PATCH 14/17] Push attcompression and attstorage handling into BuildDescForRelation() This was previously handled by the callers but it can be moved into a common place. --- src/backend/commands/tablecmds.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2760b8b111..c1be6be826 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -926,10 +926,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, cookedDefaults = lappend(cookedDefaults, cooked); attr->atthasdef = true; } - - attr->attcompression = GetAttributeCompression(attr->atttypid, colDef->compression); - if (colDef->storage_name) - attr->attstorage = GetAttributeStorage(attr->atttypid, colDef->storage_name); } /* @@ -1321,8 +1317,6 @@ BuildDescForRelation(const List *columns) /* Override TupleDescInitEntry's settings as requested */ TupleDescInitEntryCollation(desc, attnum, attcollation); - if (entry->storage) - att->attstorage = entry->storage; /* Fill in additional stuff not handled by TupleDescInitEntry */ att->attnotnull = entry->is_not_null; @@ -1331,6 +1325,11 @@ BuildDescForRelation(const List *columns) att->attinhcount = entry->inhcount; att->attidentity = entry->identity; att->attgenerated = entry->generated; + att->attcompression = GetAttributeCompression(att->atttypid, entry->compression); + if (entry->storage) + att->attstorage = entry->storage; + else if (entry->storage_name) + att->attstorage = GetAttributeStorage(att->atttypid, entry->storage_name); } if (has_not_null) @@ -6995,14 +6994,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, /* Fix up attribute number */ attribute->attnum = newattnum; - /* - * Additional fields not handled by BuildDescForRelation() (mirrors - * DefineRelation()) - */ - attribute->attcompression = GetAttributeCompression(attribute->atttypid, colDef->compression); - if (colDef->storage_name) - attribute->attstorage = GetAttributeStorage(attribute->atttypid, colDef->storage_name); - /* make sure datatype is legal for a column */ CheckAttributeType(NameStr(attribute->attname), attribute->atttypid, attribute->attcollation, list_make1_oid(rel->rd_rel->reltype), -- 2.41.0