Skip to content

Commit b1534ed

Browse files
committed
Clean up comments
Reformat some of the comments in MergeAttributes(). A lot of code has been added here over time, and the comments could use a bit of editing to make the code flow read better.
1 parent 2a71ad6 commit b1534ed

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

src/backend/commands/tablecmds.c

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,13 +2562,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
25622562
Oid defCollId;
25632563

25642564
/*
2565-
* Yes, try to merge the two column definitions. They must
2566-
* have the same type, typmod, and collation.
2565+
* Yes, try to merge the two column definitions.
25672566
*/
25682567
ereport(NOTICE,
25692568
(errmsg("merging multiple inherited definitions of column \"%s\"",
25702569
attributeName)));
25712570
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
2571+
2572+
/*
2573+
* Must have the same type and typmod
2574+
*/
25722575
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
25732576
if (defTypeId != attribute->atttypid ||
25742577
deftypmod != attribute->atttypmod)
@@ -2581,6 +2584,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
25812584
deftypmod),
25822585
format_type_with_typemod(attribute->atttypid,
25832586
attribute->atttypmod))));
2587+
2588+
/*
2589+
* Must have the same collation
2590+
*/
25842591
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
25852592
if (defCollId != attribute->attcollation)
25862593
ereport(ERROR,
@@ -2591,7 +2598,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
25912598
get_collation_name(defCollId),
25922599
get_collation_name(attribute->attcollation))));
25932600

2594-
/* Copy/check storage parameter */
2601+
/*
2602+
* Copy/check storage parameter
2603+
*/
25952604
if (def->storage == 0)
25962605
def->storage = attribute->attstorage;
25972606
else if (def->storage != attribute->attstorage)
@@ -2603,7 +2612,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
26032612
storage_name(def->storage),
26042613
storage_name(attribute->attstorage))));
26052614

2606-
/* Copy/check compression parameter */
2615+
/*
2616+
* Copy/check compression parameter
2617+
*/
26072618
if (CompressionMethodIsValid(attribute->attcompression))
26082619
{
26092620
const char *compression =
@@ -2619,18 +2630,27 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
26192630
errdetail("%s versus %s", def->compression, compression)));
26202631
}
26212632

2622-
def->inhcount++;
2623-
/* Merge of NOT NULL constraints = OR 'em together */
2633+
/*
2634+
* Merge of NOT NULL constraints = OR 'em together
2635+
*/
26242636
def->is_not_null |= attribute->attnotnull;
2625-
/* Default and other constraints are handled below */
2626-
newattmap->attnums[parent_attno - 1] = exist_attno;
26272637

2628-
/* Check for GENERATED conflicts */
2638+
/*
2639+
* Check for GENERATED conflicts
2640+
*/
26292641
if (def->generated != attribute->attgenerated)
26302642
ereport(ERROR,
26312643
(errcode(ERRCODE_DATATYPE_MISMATCH),
26322644
errmsg("inherited column \"%s\" has a generation conflict",
26332645
attributeName)));
2646+
2647+
/*
2648+
* Default and other constraints are handled below
2649+
*/
2650+
2651+
def->inhcount++;
2652+
2653+
newattmap->attnums[parent_attno - 1] = exist_attno;
26342654
}
26352655
else
26362656
{
@@ -2853,8 +2873,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
28532873
Assert(!is_partition);
28542874

28552875
/*
2856-
* Yes, try to merge the two column definitions. They must
2857-
* have the same type, typmod, and collation.
2876+
* Yes, try to merge the two column definitions.
28582877
*/
28592878
if (exist_attno == schema_attno)
28602879
ereport(NOTICE,
@@ -2865,6 +2884,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
28652884
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
28662885
errdetail("User-specified column moved to the position of the inherited column.")));
28672886
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
2887+
2888+
/*
2889+
* Must have the same type and typmod
2890+
*/
28682891
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
28692892
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
28702893
if (defTypeId != newTypeId || deftypmod != newtypmod)
@@ -2877,6 +2900,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
28772900
deftypmod),
28782901
format_type_with_typemod(newTypeId,
28792902
newtypmod))));
2903+
2904+
/*
2905+
* Must have the same collation
2906+
*/
28802907
defcollid = GetColumnDefCollation(NULL, def, defTypeId);
28812908
newcollid = GetColumnDefCollation(NULL, newdef, newTypeId);
28822909
if (defcollid != newcollid)
@@ -2894,7 +2921,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
28942921
*/
28952922
def->identity = newdef->identity;
28962923

2897-
/* Copy storage parameter */
2924+
/*
2925+
* Copy storage parameter
2926+
*/
28982927
if (def->storage == 0)
28992928
def->storage = newdef->storage;
29002929
else if (newdef->storage != 0 && def->storage != newdef->storage)
@@ -2906,7 +2935,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
29062935
storage_name(def->storage),
29072936
storage_name(newdef->storage))));
29082937

2909-
/* Copy compression parameter */
2938+
/*
2939+
* Copy compression parameter
2940+
*/
29102941
if (def->compression == NULL)
29112942
def->compression = newdef->compression;
29122943
else if (newdef->compression != NULL)
@@ -2919,9 +2950,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
29192950
errdetail("%s versus %s", def->compression, newdef->compression)));
29202951
}
29212952

2922-
/* Mark the column as locally defined */
2923-
def->is_local = true;
2924-
/* Merge of NOT NULL constraints = OR 'em together */
2953+
/*
2954+
* Merge of NOT NULL constraints = OR 'em together
2955+
*/
29252956
def->is_not_null |= newdef->is_not_null;
29262957

29272958
/*
@@ -2962,12 +2993,17 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
29622993
errhint("A child table column cannot be generated unless its parent column is.")));
29632994
}
29642995

2965-
/* If new def has a default, override previous default */
2996+
/*
2997+
* If new def has a default, override previous default
2998+
*/
29662999
if (newdef->raw_default != NULL)
29673000
{
29683001
def->raw_default = newdef->raw_default;
29693002
def->cooked_default = newdef->cooked_default;
29703003
}
3004+
3005+
/* Mark the column as locally defined */
3006+
def->is_local = true;
29713007
}
29723008
else
29733009
{

0 commit comments

Comments
 (0)