mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
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.
This commit is contained in:
@ -2562,13 +2562,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
Oid defCollId;
|
Oid defCollId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Yes, try to merge the two column definitions. They must
|
* Yes, try to merge the two column definitions.
|
||||||
* have the same type, typmod, and collation.
|
|
||||||
*/
|
*/
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
(errmsg("merging multiple inherited definitions of column \"%s\"",
|
(errmsg("merging multiple inherited definitions of column \"%s\"",
|
||||||
attributeName)));
|
attributeName)));
|
||||||
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
|
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must have the same type and typmod
|
||||||
|
*/
|
||||||
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
|
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
|
||||||
if (defTypeId != attribute->atttypid ||
|
if (defTypeId != attribute->atttypid ||
|
||||||
deftypmod != attribute->atttypmod)
|
deftypmod != attribute->atttypmod)
|
||||||
@ -2581,6 +2584,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
deftypmod),
|
deftypmod),
|
||||||
format_type_with_typemod(attribute->atttypid,
|
format_type_with_typemod(attribute->atttypid,
|
||||||
attribute->atttypmod))));
|
attribute->atttypmod))));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must have the same collation
|
||||||
|
*/
|
||||||
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
|
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
|
||||||
if (defCollId != attribute->attcollation)
|
if (defCollId != attribute->attcollation)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2591,7 +2598,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
get_collation_name(defCollId),
|
get_collation_name(defCollId),
|
||||||
get_collation_name(attribute->attcollation))));
|
get_collation_name(attribute->attcollation))));
|
||||||
|
|
||||||
/* Copy/check storage parameter */
|
/*
|
||||||
|
* Copy/check storage parameter
|
||||||
|
*/
|
||||||
if (def->storage == 0)
|
if (def->storage == 0)
|
||||||
def->storage = attribute->attstorage;
|
def->storage = attribute->attstorage;
|
||||||
else if (def->storage != attribute->attstorage)
|
else if (def->storage != attribute->attstorage)
|
||||||
@ -2603,7 +2612,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
storage_name(def->storage),
|
storage_name(def->storage),
|
||||||
storage_name(attribute->attstorage))));
|
storage_name(attribute->attstorage))));
|
||||||
|
|
||||||
/* Copy/check compression parameter */
|
/*
|
||||||
|
* Copy/check compression parameter
|
||||||
|
*/
|
||||||
if (CompressionMethodIsValid(attribute->attcompression))
|
if (CompressionMethodIsValid(attribute->attcompression))
|
||||||
{
|
{
|
||||||
const char *compression =
|
const char *compression =
|
||||||
@ -2619,18 +2630,27 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
errdetail("%s versus %s", def->compression, compression)));
|
errdetail("%s versus %s", def->compression, compression)));
|
||||||
}
|
}
|
||||||
|
|
||||||
def->inhcount++;
|
/*
|
||||||
/* Merge of NOT NULL constraints = OR 'em together */
|
* Merge of NOT NULL constraints = OR 'em together
|
||||||
|
*/
|
||||||
def->is_not_null |= attribute->attnotnull;
|
def->is_not_null |= attribute->attnotnull;
|
||||||
/* Default and other constraints are handled below */
|
|
||||||
newattmap->attnums[parent_attno - 1] = exist_attno;
|
|
||||||
|
|
||||||
/* Check for GENERATED conflicts */
|
/*
|
||||||
|
* Check for GENERATED conflicts
|
||||||
|
*/
|
||||||
if (def->generated != attribute->attgenerated)
|
if (def->generated != attribute->attgenerated)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||||
errmsg("inherited column \"%s\" has a generation conflict",
|
errmsg("inherited column \"%s\" has a generation conflict",
|
||||||
attributeName)));
|
attributeName)));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default and other constraints are handled below
|
||||||
|
*/
|
||||||
|
|
||||||
|
def->inhcount++;
|
||||||
|
|
||||||
|
newattmap->attnums[parent_attno - 1] = exist_attno;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2853,8 +2873,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
Assert(!is_partition);
|
Assert(!is_partition);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Yes, try to merge the two column definitions. They must
|
* Yes, try to merge the two column definitions.
|
||||||
* have the same type, typmod, and collation.
|
|
||||||
*/
|
*/
|
||||||
if (exist_attno == schema_attno)
|
if (exist_attno == schema_attno)
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
@ -2865,6 +2884,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
|
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
|
||||||
errdetail("User-specified column moved to the position of the inherited column.")));
|
errdetail("User-specified column moved to the position of the inherited column.")));
|
||||||
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
|
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must have the same type and typmod
|
||||||
|
*/
|
||||||
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
|
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
|
||||||
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
|
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
|
||||||
if (defTypeId != newTypeId || deftypmod != newtypmod)
|
if (defTypeId != newTypeId || deftypmod != newtypmod)
|
||||||
@ -2877,6 +2900,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
deftypmod),
|
deftypmod),
|
||||||
format_type_with_typemod(newTypeId,
|
format_type_with_typemod(newTypeId,
|
||||||
newtypmod))));
|
newtypmod))));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must have the same collation
|
||||||
|
*/
|
||||||
defcollid = GetColumnDefCollation(NULL, def, defTypeId);
|
defcollid = GetColumnDefCollation(NULL, def, defTypeId);
|
||||||
newcollid = GetColumnDefCollation(NULL, newdef, newTypeId);
|
newcollid = GetColumnDefCollation(NULL, newdef, newTypeId);
|
||||||
if (defcollid != newcollid)
|
if (defcollid != newcollid)
|
||||||
@ -2894,7 +2921,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
*/
|
*/
|
||||||
def->identity = newdef->identity;
|
def->identity = newdef->identity;
|
||||||
|
|
||||||
/* Copy storage parameter */
|
/*
|
||||||
|
* Copy storage parameter
|
||||||
|
*/
|
||||||
if (def->storage == 0)
|
if (def->storage == 0)
|
||||||
def->storage = newdef->storage;
|
def->storage = newdef->storage;
|
||||||
else if (newdef->storage != 0 && def->storage != newdef->storage)
|
else if (newdef->storage != 0 && def->storage != newdef->storage)
|
||||||
@ -2906,7 +2935,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
storage_name(def->storage),
|
storage_name(def->storage),
|
||||||
storage_name(newdef->storage))));
|
storage_name(newdef->storage))));
|
||||||
|
|
||||||
/* Copy compression parameter */
|
/*
|
||||||
|
* Copy compression parameter
|
||||||
|
*/
|
||||||
if (def->compression == NULL)
|
if (def->compression == NULL)
|
||||||
def->compression = newdef->compression;
|
def->compression = newdef->compression;
|
||||||
else if (newdef->compression != NULL)
|
else if (newdef->compression != NULL)
|
||||||
@ -2919,9 +2950,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
errdetail("%s versus %s", def->compression, newdef->compression)));
|
errdetail("%s versus %s", def->compression, newdef->compression)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark the column as locally defined */
|
/*
|
||||||
def->is_local = true;
|
* Merge of NOT NULL constraints = OR 'em together
|
||||||
/* Merge of NOT NULL constraints = OR 'em together */
|
*/
|
||||||
def->is_not_null |= newdef->is_not_null;
|
def->is_not_null |= newdef->is_not_null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2962,12 +2993,17 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
|||||||
errhint("A child table column cannot be generated unless its parent column is.")));
|
errhint("A child table column cannot be generated unless its parent column is.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If new def has a default, override previous default */
|
/*
|
||||||
|
* If new def has a default, override previous default
|
||||||
|
*/
|
||||||
if (newdef->raw_default != NULL)
|
if (newdef->raw_default != NULL)
|
||||||
{
|
{
|
||||||
def->raw_default = newdef->raw_default;
|
def->raw_default = newdef->raw_default;
|
||||||
def->cooked_default = newdef->cooked_default;
|
def->cooked_default = newdef->cooked_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mark the column as locally defined */
|
||||||
|
def->is_local = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user