Push attcompression and attstorage handling into BuildDescForRelation()
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 5 Oct 2023 14:17:16 +0000 (16:17 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 5 Oct 2023 14:20:46 +0000 (16:20 +0200)
This was previously handled by the callers but it can be moved into a
common place.

Discussion: https://www.postgresql.org/message-id/flat/52a125e4-ff9a-95f5-9f61-b87cf447e4da@eisentraut.org

src/backend/commands/tablecmds.c

index 7bd73eb3794db4c886ed9f263fe402ad6b9c4c8d..8820738d91889f2f19856c3900936e58a0210ad5 100644 (file)
@@ -940,10 +940,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);
    }
 
    /*
@@ -1346,8 +1342,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;
@@ -1356,6 +1350,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)