@@ -2562,13 +2562,16 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2562
2562
Oid defCollId;
2563
2563
2564
2564
/*
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.
2567
2566
*/
2568
2567
ereport(NOTICE,
2569
2568
(errmsg("merging multiple inherited definitions of column \"%s\"",
2570
2569
attributeName)));
2571
2570
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
2571
+
2572
+ /*
2573
+ * Must have the same type and typmod
2574
+ */
2572
2575
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
2573
2576
if (defTypeId != attribute->atttypid ||
2574
2577
deftypmod != attribute->atttypmod)
@@ -2581,6 +2584,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2581
2584
deftypmod),
2582
2585
format_type_with_typemod(attribute->atttypid,
2583
2586
attribute->atttypmod))));
2587
+
2588
+ /*
2589
+ * Must have the same collation
2590
+ */
2584
2591
defCollId = GetColumnDefCollation(NULL, def, defTypeId);
2585
2592
if (defCollId != attribute->attcollation)
2586
2593
ereport(ERROR,
@@ -2591,7 +2598,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2591
2598
get_collation_name(defCollId),
2592
2599
get_collation_name(attribute->attcollation))));
2593
2600
2594
- /* Copy/check storage parameter */
2601
+ /*
2602
+ * Copy/check storage parameter
2603
+ */
2595
2604
if (def->storage == 0)
2596
2605
def->storage = attribute->attstorage;
2597
2606
else if (def->storage != attribute->attstorage)
@@ -2603,7 +2612,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2603
2612
storage_name(def->storage),
2604
2613
storage_name(attribute->attstorage))));
2605
2614
2606
- /* Copy/check compression parameter */
2615
+ /*
2616
+ * Copy/check compression parameter
2617
+ */
2607
2618
if (CompressionMethodIsValid(attribute->attcompression))
2608
2619
{
2609
2620
const char *compression =
@@ -2619,18 +2630,27 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2619
2630
errdetail("%s versus %s", def->compression, compression)));
2620
2631
}
2621
2632
2622
- def->inhcount++;
2623
- /* Merge of NOT NULL constraints = OR 'em together */
2633
+ /*
2634
+ * Merge of NOT NULL constraints = OR 'em together
2635
+ */
2624
2636
def->is_not_null |= attribute->attnotnull;
2625
- /* Default and other constraints are handled below */
2626
- newattmap->attnums[parent_attno - 1] = exist_attno;
2627
2637
2628
- /* Check for GENERATED conflicts */
2638
+ /*
2639
+ * Check for GENERATED conflicts
2640
+ */
2629
2641
if (def->generated != attribute->attgenerated)
2630
2642
ereport(ERROR,
2631
2643
(errcode(ERRCODE_DATATYPE_MISMATCH),
2632
2644
errmsg("inherited column \"%s\" has a generation conflict",
2633
2645
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;
2634
2654
}
2635
2655
else
2636
2656
{
@@ -2853,8 +2873,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2853
2873
Assert(!is_partition);
2854
2874
2855
2875
/*
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.
2858
2877
*/
2859
2878
if (exist_attno == schema_attno)
2860
2879
ereport(NOTICE,
@@ -2865,6 +2884,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2865
2884
(errmsg("moving and merging column \"%s\" with inherited definition", attributeName),
2866
2885
errdetail("User-specified column moved to the position of the inherited column.")));
2867
2886
def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1);
2887
+
2888
+ /*
2889
+ * Must have the same type and typmod
2890
+ */
2868
2891
typenameTypeIdAndMod(NULL, def->typeName, &defTypeId, &deftypmod);
2869
2892
typenameTypeIdAndMod(NULL, newdef->typeName, &newTypeId, &newtypmod);
2870
2893
if (defTypeId != newTypeId || deftypmod != newtypmod)
@@ -2877,6 +2900,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2877
2900
deftypmod),
2878
2901
format_type_with_typemod(newTypeId,
2879
2902
newtypmod))));
2903
+
2904
+ /*
2905
+ * Must have the same collation
2906
+ */
2880
2907
defcollid = GetColumnDefCollation(NULL, def, defTypeId);
2881
2908
newcollid = GetColumnDefCollation(NULL, newdef, newTypeId);
2882
2909
if (defcollid != newcollid)
@@ -2894,7 +2921,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2894
2921
*/
2895
2922
def->identity = newdef->identity;
2896
2923
2897
- /* Copy storage parameter */
2924
+ /*
2925
+ * Copy storage parameter
2926
+ */
2898
2927
if (def->storage == 0)
2899
2928
def->storage = newdef->storage;
2900
2929
else if (newdef->storage != 0 && def->storage != newdef->storage)
@@ -2906,7 +2935,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2906
2935
storage_name(def->storage),
2907
2936
storage_name(newdef->storage))));
2908
2937
2909
- /* Copy compression parameter */
2938
+ /*
2939
+ * Copy compression parameter
2940
+ */
2910
2941
if (def->compression == NULL)
2911
2942
def->compression = newdef->compression;
2912
2943
else if (newdef->compression != NULL)
@@ -2919,9 +2950,9 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2919
2950
errdetail("%s versus %s", def->compression, newdef->compression)));
2920
2951
}
2921
2952
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
+ */
2925
2956
def->is_not_null |= newdef->is_not_null;
2926
2957
2927
2958
/*
@@ -2962,12 +2993,17 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
2962
2993
errhint("A child table column cannot be generated unless its parent column is.")));
2963
2994
}
2964
2995
2965
- /* If new def has a default, override previous default */
2996
+ /*
2997
+ * If new def has a default, override previous default
2998
+ */
2966
2999
if (newdef->raw_default != NULL)
2967
3000
{
2968
3001
def->raw_default = newdef->raw_default;
2969
3002
def->cooked_default = newdef->cooked_default;
2970
3003
}
3004
+
3005
+ /* Mark the column as locally defined */
3006
+ def->is_local = true;
2971
3007
}
2972
3008
else
2973
3009
{
0 commit comments