v2-0008-Push-attcompression-and-attstorage-handling-into-.patch

text/plain

Filename: v2-0008-Push-attcompression-and-attstorage-handling-into-.patch
Type: text/plain
Part: 7
Message: Re: tablecmds.c/MergeAttributes() cleanup

Patch

Format: format-patch
Series: patch v2-0008
Subject: Push attcompression and attstorage handling into BuildDescForRelation()
File+
src/backend/commands/tablecmds.c 5 6
From 25a061ebb79c1ff21076976f55ecbb4f14ba28ce Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 12 Jul 2023 16:12:35 +0200
Subject: [PATCH v2 08/10] 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 | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 0577e29230..cd6c46e866 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -941,10 +941,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);
 	}
 
 	/*
@@ -1347,8 +1343,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;
@@ -1357,6 +1351,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)
-- 
2.41.0