@@ -2663,7 +2663,10 @@ build_attrmap_by_name_ext(Relation rel_src, Relation rel_dst)
2663
2663
{
2664
2664
Form_pg_attribute outatt = TupleDescAttr (outdesc , i );
2665
2665
char * attname ;
2666
- Oid atttypid , attcol ;
2666
+ Oid atttypid ;
2667
+ #if PG_VERSION_NUM >= 180000
2668
+ Oid attcol ;
2669
+ #endif
2667
2670
int32 atttypmod ;
2668
2671
int j ;
2669
2672
@@ -2675,7 +2678,9 @@ build_attrmap_by_name_ext(Relation rel_src, Relation rel_dst)
2675
2678
attname = NameStr (outatt -> attname );
2676
2679
atttypid = outatt -> atttypid ;
2677
2680
atttypmod = outatt -> atttypmod ;
2681
+ #if PG_VERSION_NUM >= 180000
2678
2682
attcol = outatt -> attcollation ;
2683
+ #endif
2679
2684
2680
2685
/*
2681
2686
* Now search for an attribute with the same name in the indesc. It
@@ -2710,11 +2715,7 @@ build_attrmap_by_name_ext(Relation rel_src, Relation rel_dst)
2710
2715
* Found it. Insert NULL into generated virtual columns, the
2711
2716
* actual value will be computed during query execution.
2712
2717
*/
2713
- if (outatt -> attgenerated == ATTRIBUTE_GENERATED_VIRTUAL )
2714
- attrMap -> exprsOut [i ] = (Node * ) makeNullConst (atttypid ,
2715
- atttypmod ,
2716
- attcol );
2717
- else if (outatt -> attgenerated == ATTRIBUTE_GENERATED_STORED )
2718
+ if (outatt -> attgenerated == ATTRIBUTE_GENERATED_STORED )
2718
2719
{
2719
2720
/*
2720
2721
* Initialize the expression to compute the stored value
@@ -2744,14 +2745,23 @@ build_attrmap_by_name_ext(Relation rel_src, Relation rel_dst)
2744
2745
assign_expr_collations (pstate , expr );
2745
2746
attrMap -> exprsOut [i ] = expr ;
2746
2747
}
2748
+ #if PG_VERSION_NUM >= 180000
2749
+ else if (outatt -> attgenerated == ATTRIBUTE_GENERATED_VIRTUAL )
2750
+ attrMap -> exprsOut [i ] = (Node * ) makeNullConst (atttypid ,
2751
+ atttypmod ,
2752
+ attcol );
2753
+ #endif
2747
2754
2748
2755
/*
2749
2756
* Check type. Also make sure that we have the expression to
2750
2757
* generate the value of a virtual generated column.
2751
2758
*/
2752
2759
if (atttypid != inatt -> atttypid ||
2753
- atttypmod != inatt -> atttypmod ||
2754
- inatt -> attgenerated == ATTRIBUTE_GENERATED_VIRTUAL )
2760
+ atttypmod != inatt -> atttypmod
2761
+ #if PG_VERSION_NUM >= 180000
2762
+ || inatt -> attgenerated == ATTRIBUTE_GENERATED_VIRTUAL
2763
+ #endif
2764
+ )
2755
2765
{
2756
2766
/*
2757
2767
* Can the input attribute be coerced to the output one?
@@ -2772,9 +2782,11 @@ build_attrmap_by_name_ext(Relation rel_src, Relation rel_dst)
2772
2782
COERCION_ASSIGNMENT ,
2773
2783
COERCE_IMPLICIT_CAST ,
2774
2784
-1 );
2785
+ #if PG_VERSION_NUM >= 180000
2775
2786
/* Here we take the column expression into account. */
2776
2787
if (inatt -> attgenerated == ATTRIBUTE_GENERATED_VIRTUAL )
2777
2788
expr = expand_generated_columns_in_expr (expr , rel_src , 1 );
2789
+ #endif
2778
2790
/*
2779
2791
* XXX Do we need to call expression_planner() like
2780
2792
* ATPrepAlterColumnType() in PG core does?
0 commit comments