@@ -59,6 +59,12 @@ PG_MODULE_MAGIC;
59
59
#error VOPS requires 64-bit version of Postgres
60
60
#endif
61
61
62
+ #if PG_VERSION_NUM >=150000
63
+ #define FUNC_CALL_CTX COERCE_EXPLICIT_CALL, -1
64
+ #else
65
+ #define FUNC_CALL_CTX -1
66
+ #endif
67
+
62
68
/* pg module functions */
63
69
void _PG_init (void );
64
70
void _PG_fini (void );
@@ -1151,13 +1157,24 @@ UserTableUpdateOpenIndexes()
1151
1157
if (HeapTupleIsHeapOnly (tuple ))
1152
1158
return ;
1153
1159
1160
+ #if PG_VERSION_NUM >=150000
1161
+ if (estate -> es_result_relations [0 ]-> ri_NumIndices > 0 )
1162
+ {
1163
+ recheckIndexes = ExecInsertIndexTuples (estate -> es_result_relations [0 ],
1164
+ #else
1154
1165
if (estate -> es_result_relation_info -> ri_NumIndices > 0 )
1155
1166
{
1156
- recheckIndexes = ExecInsertIndexTuples (slot ,
1167
+ recheckIndexes = ExecInsertIndexTuples (
1168
+ #endif
1169
+ slot ,
1157
1170
#if PG_VERSION_NUM < 120000
1158
1171
& tuple -> t_self ,
1159
1172
#endif
1160
- estate , false, NULL , NIL );
1173
+ estate ,
1174
+ #if PG_VERSION_NUM >=150000
1175
+ true ,
1176
+ #endif
1177
+ false, NULL , NIL );
1161
1178
if (recheckIndexes != NIL )
1162
1179
ereport (ERROR ,
1163
1180
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
@@ -1181,10 +1198,15 @@ static void begin_batch_insert(Oid oid)
1181
1198
resultRelInfo -> ri_RelationDesc = rel ;
1182
1199
resultRelInfo -> ri_TrigInstrument = NULL ;
1183
1200
1201
+ #if PG_VERSION_NUM >=150000
1202
+ estate -> es_result_relations = (ResultRelInfo * * )palloc (sizeof (ResultRelInfo * ));
1203
+ estate -> es_result_relations [0 ] = resultRelInfo ;
1204
+ #else
1184
1205
estate -> es_result_relations = resultRelInfo ;
1185
1206
estate -> es_num_result_relations = 1 ;
1186
1207
estate -> es_result_relation_info = resultRelInfo ;
1187
- ExecOpenIndices (estate -> es_result_relation_info , false);
1208
+ #endif
1209
+ ExecOpenIndices (resultRelInfo , false);
1188
1210
#if PG_VERSION_NUM >=120000
1189
1211
slot = ExecInitExtraTupleSlot (estate , RelationGetDescr (rel ), & TTSOpsHeapTuple );
1190
1212
#elif PG_VERSION_NUM >=110000
@@ -1210,7 +1232,11 @@ static void insert_tuple(Datum* values, bool* nulls)
1210
1232
1211
1233
static void end_batch_insert ()
1212
1234
{
1235
+ #if PG_VERSION_NUM >=150000
1236
+ ExecCloseIndices (estate -> es_result_relations [0 ]);
1237
+ #else
1213
1238
ExecCloseIndices (estate -> es_result_relation_info );
1239
+ #endif
1214
1240
if (ActiveSnapshotSet ()) {
1215
1241
PopActiveSnapshot ();
1216
1242
}
@@ -4149,7 +4175,7 @@ vops_add_index_cond(Node* clause, List* conjuncts, char const* keyName)
4149
4175
if (* op == '<' || * op == '>' ) {
4150
4176
A_Expr * bound = makeNode (A_Expr );
4151
4177
FuncCall * call = makeFuncCall (list_make1 (makeString (* op == '<' ? "first" : "last" )),
4152
- list_make1 (expr -> lexpr ), -1 );
4178
+ list_make1 (expr -> lexpr ), FUNC_CALL_CTX );
4153
4179
bound -> kind = expr -> kind ;
4154
4180
bound -> name = expr -> name ;
4155
4181
bound -> lexpr = (Node * )call ;
@@ -4159,7 +4185,7 @@ vops_add_index_cond(Node* clause, List* conjuncts, char const* keyName)
4159
4185
} else if (expr -> kind == AEXPR_BETWEEN ) {
4160
4186
A_Expr * bound = makeNode (A_Expr );
4161
4187
FuncCall * call = makeFuncCall (list_make1 (makeString ("last" )),
4162
- list_make1 (expr -> lexpr ), -1 );
4188
+ list_make1 (expr -> lexpr ), FUNC_CALL_CTX );
4163
4189
bound -> kind = AEXPR_OP ;
4164
4190
bound -> name = list_make1 (makeString (">=" ));
4165
4191
bound -> lexpr = (Node * )call ;
@@ -4169,7 +4195,7 @@ vops_add_index_cond(Node* clause, List* conjuncts, char const* keyName)
4169
4195
4170
4196
bound = makeNode (A_Expr );
4171
4197
call = makeFuncCall (list_make1 (makeString ("first" )),
4172
- list_make1 (expr -> lexpr ), -1 );
4198
+ list_make1 (expr -> lexpr ), FUNC_CALL_CTX );
4173
4199
bound -> kind = AEXPR_OP ;
4174
4200
bound -> name = list_make1 (makeString ("<=" ));
4175
4201
bound -> lexpr = (Node * )call ;
@@ -4179,7 +4205,7 @@ vops_add_index_cond(Node* clause, List* conjuncts, char const* keyName)
4179
4205
} else if (* op == '=' ) {
4180
4206
A_Expr * bound = makeNode (A_Expr );
4181
4207
FuncCall * call = makeFuncCall (list_make1 (makeString ("last" )),
4182
- list_make1 (expr -> lexpr ), -1 );
4208
+ list_make1 (expr -> lexpr ), FUNC_CALL_CTX );
4183
4209
bound -> kind = expr -> kind ;
4184
4210
bound -> name = list_make1 (makeString (">=" ));
4185
4211
bound -> lexpr = (Node * )call ;
@@ -4189,7 +4215,7 @@ vops_add_index_cond(Node* clause, List* conjuncts, char const* keyName)
4189
4215
4190
4216
bound = makeNode (A_Expr );
4191
4217
call = makeFuncCall (list_make1 (makeString ("first" )),
4192
- list_make1 (expr -> lexpr ), -1 );
4218
+ list_make1 (expr -> lexpr ), FUNC_CALL_CTX );
4193
4219
bound -> kind = expr -> kind ;
4194
4220
bound -> name = list_make1 (makeString ("<=" ));
4195
4221
bound -> lexpr = (Node * )call ;
@@ -4554,13 +4580,21 @@ vops_resolve_functions(void)
4554
4580
}
4555
4581
}
4556
4582
4583
+ #if PG_VERSION_NUM >=150000
4584
+ static void vops_post_parse_analysis_hook (ParseState * pstate , Query * query , JumbleState * jstate )
4585
+ #else
4557
4586
static void vops_post_parse_analysis_hook (ParseState * pstate , Query * query )
4587
+ #endif
4558
4588
{
4559
4589
vops_var var ;
4560
4590
/* Invoke original hook if needed */
4561
4591
if (post_parse_analyze_hook_next )
4562
4592
{
4593
+ #if PG_VERSION_NUM >=150000
4594
+ post_parse_analyze_hook_next (pstate , query , jstate );
4595
+ #else
4563
4596
post_parse_analyze_hook_next (pstate , query );
4597
+ #endif
4564
4598
}
4565
4599
vops_resolve_functions ();
4566
4600
0 commit comments