64
64
#include "utils/datum.h"
65
65
#include "utils/fmgroids.h"
66
66
#include "utils/guc.h"
67
+ #if PG_VERSION_NUM >= 170000
67
68
#include "utils/injection_point.h"
69
+ #endif
68
70
#include "utils/lsyscache.h"
69
71
#include "utils/memutils.h"
70
72
#include "utils/rel.h"
@@ -723,12 +725,13 @@ rewrite_worker_main(Datum main_arg)
723
725
relname_dst );
724
726
CommitTransactionCommand ();
725
727
728
+ #if PG_VERSION_NUM >= 170000
726
729
/*
727
730
* In regression tests, use this injection point to check that
728
731
* the changes are visible by other transactions.
729
732
*/
730
733
INJECTION_POINT ("pg_rewrite-after-commit" );
731
-
734
+ #endif
732
735
}
733
736
PG_CATCH ();
734
737
{
@@ -1018,11 +1021,13 @@ rewrite_table_impl(char *relschema_src, char *relname_src,
1018
1021
*/
1019
1022
CommandCounterIncrement ();
1020
1023
1024
+ #if PG_VERSION_NUM >= 170000
1021
1025
/*
1022
1026
* During testing, wait for another backend to perform concurrent data
1023
1027
* changes which we will process below.
1024
1028
*/
1025
1029
INJECTION_POINT ("pg_rewrite-before-lock" );
1030
+ #endif
1026
1031
1027
1032
/*
1028
1033
* Flush all WAL records inserted so far (possibly except for the last
@@ -2779,11 +2784,11 @@ pg_rewrite_get_task_list(PG_FUNCTION_ARGS)
2779
2784
isnull = (bool * ) palloc0 (TASK_LIST_RES_ATTRS * sizeof (bool ));
2780
2785
2781
2786
2782
- if (strlen (NameStr (task -> relschema_src )) > 0 )
2783
- values [0 ] = NameGetDatum (& task -> relschema_src );
2787
+ if (strlen (NameStr (task -> relschema )) > 0 )
2788
+ values [0 ] = NameGetDatum (& task -> relschema );
2784
2789
else
2785
2790
isnull [0 ] = true;
2786
- values [1 ] = NameGetDatum (& task -> relname_src );
2791
+ values [1 ] = NameGetDatum (& task -> relname );
2787
2792
if (strlen (NameStr (task -> relschema_dst )) > 0 )
2788
2793
values [2 ] = NameGetDatum (& task -> relschema_dst );
2789
2794
else
@@ -2972,7 +2977,9 @@ dump_fk_constraint(HeapTuple tup, Oid relid_dst, const char *relname_dst,
2972
2977
const char * pkrelname , * pknsp , * fkrelname , * fknsp ;
2973
2978
Form_pg_constraint con = (Form_pg_constraint ) GETSTRUCT (tup );
2974
2979
Datum val ;
2980
+ #if PG_VERSION_NUM >= 150000
2975
2981
bool isnull ;
2982
+ #endif
2976
2983
const char * string ;
2977
2984
2978
2985
Assert (con -> contype == CONSTRAINT_FOREIGN );
@@ -3026,8 +3033,18 @@ dump_fk_constraint(HeapTuple tup, Oid relid_dst, const char *relname_dst,
3026
3033
appendStringInfoString (buf , "FOREIGN KEY (" );
3027
3034
3028
3035
/* Fetch and build referencing-column list */
3036
+ #if PG_VERSION_NUM >= 160000
3029
3037
val = SysCacheGetAttrNotNull (CONSTROID , tup ,
3030
3038
Anum_pg_constraint_conkey );
3039
+ #else
3040
+ {
3041
+ bool isnull ;
3042
+
3043
+ val = SysCacheGetAttr (CONSTROID , tup , Anum_pg_constraint_conkey ,
3044
+ & isnull );
3045
+ Assert (!isnull );
3046
+ }
3047
+ #endif
3031
3048
3032
3049
decompile_column_index_array (val , con -> conrelid , buf );
3033
3050
@@ -3036,8 +3053,18 @@ dump_fk_constraint(HeapTuple tup, Oid relid_dst, const char *relname_dst,
3036
3053
quote_qualified_identifier (pknsp , pkrelname ));
3037
3054
3038
3055
/* Fetch and build referenced-column list */
3056
+ #if PG_VERSION_NUM >= 160000
3039
3057
val = SysCacheGetAttrNotNull (CONSTROID , tup ,
3040
3058
Anum_pg_constraint_confkey );
3059
+ #else
3060
+ {
3061
+ bool isnull ;
3062
+
3063
+ val = SysCacheGetAttr (CONSTROID , tup , Anum_pg_constraint_confkey ,
3064
+ & isnull );
3065
+ Assert (!isnull );
3066
+ }
3067
+ #endif
3041
3068
3042
3069
decompile_column_index_array (val , con -> confrelid , buf );
3043
3070
@@ -3116,6 +3143,7 @@ dump_fk_constraint(HeapTuple tup, Oid relid_dst, const char *relname_dst,
3116
3143
if (string )
3117
3144
appendStringInfo (buf , " ON DELETE %s" , string );
3118
3145
3146
+ #if PG_VERSION_NUM >= 150000
3119
3147
/*
3120
3148
* Add columns specified to SET NULL or SET DEFAULT if
3121
3149
* provided.
@@ -3128,6 +3156,7 @@ dump_fk_constraint(HeapTuple tup, Oid relid_dst, const char *relname_dst,
3128
3156
decompile_column_index_array (val , con -> conrelid , buf );
3129
3157
appendStringInfoChar (buf , ')' );
3130
3158
}
3159
+ #endif
3131
3160
}
3132
3161
3133
3162
/*
@@ -3151,8 +3180,18 @@ dump_check_constraint(Oid relid_dst, const char *relname_dst, HeapTuple tup,
3151
3180
dump_constraint_common (nsp , relname_dst , con , buf );
3152
3181
3153
3182
/* Fetch constraint expression in parsetree form */
3183
+ #if PG_VERSION_NUM >= 160000
3154
3184
val = SysCacheGetAttrNotNull (CONSTROID , tup ,
3155
3185
Anum_pg_constraint_conbin );
3186
+ #else
3187
+ {
3188
+ bool isnull ;
3189
+
3190
+ val = SysCacheGetAttr (CONSTROID , tup , Anum_pg_constraint_conbin ,
3191
+ & isnull );
3192
+ Assert (!isnull );
3193
+ }
3194
+ #endif
3156
3195
3157
3196
conbin = TextDatumGetCString (val );
3158
3197
expr = stringToNode (conbin );
@@ -3253,8 +3292,14 @@ decompile_column_index_array(Datum column_index_array, Oid relId,
3253
3292
int j ;
3254
3293
3255
3294
/* Extract data from array of int16 */
3295
+ #if PG_VERSION_NUM >= 160000
3256
3296
deconstruct_array_builtin (DatumGetArrayTypeP (column_index_array ), INT2OID ,
3257
3297
& keys , NULL , & nKeys );
3298
+ #else
3299
+ deconstruct_array (DatumGetArrayTypeP (column_index_array ), INT2OID ,
3300
+ sizeof (int16 ), true, TYPALIGN_SHORT ,
3301
+ & keys , NULL , & nKeys );
3302
+ #endif
3258
3303
3259
3304
for (j = 0 ; j < nKeys ; j ++ )
3260
3305
{
0 commit comments