Oid defCollId;
/*
- * Yes, try to merge the two column definitions. They must
- * have the same type, typmod, and collation.
+ * Yes, try to merge the two column definitions.
*/
ereport(NOTICE,
(errmsg("merging multiple inherited definitions of column \"%s\"",
attributeName)));
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
+
+ /*
+ * Must have the same type and typmod
+ */
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
if (defTypeId != attribute->atttypid ||
deftypmod != attribute->atttypmod)
deftypmod),
format_type_with_typemod(attribute->atttypid,
attribute->atttypmod))));
+
+ /*
+ * Must have the same collation
+ */
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
if (defCollId != attribute->attcollation)
ereport(ERROR,
get_collation_name(defCollId),
get_collation_name(attribute->attcollation))));
- /* Copy/check storage parameter */
+ /*
+ * Copy/check storage parameter
+ */
if (def->storage == 0)
def->storage = attribute->attstorage;
else if (def->storage != attribute->attstorage)
storage_name(def->storage),
storage_name(attribute->attstorage))));
- /* Copy/check compression parameter */
+ /*
+ * Copy/check compression parameter
+ */
if (CompressionMethodIsValid(attribute->attcompression))
{
const char *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;
- /* 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)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("inherited column \"%s\" has a generation conflict",
attributeName)));
+
+ /*
+ * Default and other constraints are handled below
+ */
+
+ def->inhcount++;
+
+ newattmap->attnums[parent_attno - 1] = exist_attno;
}
else
{
Assert(!is_partition);
/*
- * Yes, try to merge the two column definitions. They must
- * have the same type, typmod, and collation.
+ * Yes, try to merge the two column definitions.
*/
if (exist_attno == schema_attno)
ereport(NOTICE,
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
errdetail("User-specified column moved to the position of the inherited column.")));
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
+
+ /*
+ * Must have the same type and typmod
+ */
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
if (defTypeId != newTypeId || deftypmod != newtypmod)
deftypmod),
format_type_with_typemod(newTypeId,
newtypmod))));
+
+ /*
+ * Must have the same collation
+ */
defcollid = GetColumnDefCollation(NULL, def, defTypeId);
newcollid = GetColumnDefCollation(NULL, newdef, newTypeId);
if (defcollid != newcollid)
*/
def->identity = newdef->identity;
- /* Copy storage parameter */
+ /*
+ * Copy storage parameter
+ */
if (def->storage == 0)
def->storage = newdef->storage;
else if (newdef->storage != 0 && def->storage != newdef->storage)
storage_name(def->storage),
storage_name(newdef->storage))));
- /* Copy compression parameter */
+ /*
+ * Copy compression parameter
+ */
if (def->compression == NULL)
def->compression = newdef->compression;
else if (newdef->compression != NULL)
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;
/*
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)
{
def->raw_default = newdef->raw_default;
def->cooked_default = newdef->cooked_default;
}
+
+ /* Mark the column as locally defined */
+ def->is_local = true;
}
else
{