@@ -59,7 +59,7 @@ PG_MODULE_MAGIC;
5959#error VOPS requires 64-bit version of Postgres
6060#endif
6161
62- #if PG_VERSION_NUM >=150000
62+ #if PG_VERSION_NUM >=140000
6363#define FUNC_CALL_CTX COERCE_EXPLICIT_CALL, -1
6464#else
6565#define FUNC_CALL_CTX -1
@@ -1157,7 +1157,7 @@ UserTableUpdateOpenIndexes()
11571157if (HeapTupleIsHeapOnly (tuple ))
11581158return ;
11591159
1160- #if PG_VERSION_NUM >=150000
1160+ #if PG_VERSION_NUM >=140000
11611161if (estate -> es_result_relations [0 ]-> ri_NumIndices > 0 )
11621162{
11631163recheckIndexes = ExecInsertIndexTuples (estate -> es_result_relations [0 ],
@@ -1171,7 +1171,7 @@ UserTableUpdateOpenIndexes()
11711171& tuple -> t_self ,
11721172#endif
11731173estate ,
1174- #if PG_VERSION_NUM >=150000
1174+ #if PG_VERSION_NUM >=140000
11751175true ,
11761176#endif
11771177 false,NULL ,NIL );
@@ -1198,7 +1198,7 @@ static void begin_batch_insert(Oid oid)
11981198resultRelInfo -> ri_RelationDesc = rel ;
11991199resultRelInfo -> ri_TrigInstrument = NULL ;
12001200
1201- #if PG_VERSION_NUM >=150000
1201+ #if PG_VERSION_NUM >=140000
12021202estate -> es_result_relations = (ResultRelInfo * * )palloc (sizeof (ResultRelInfo * ));
12031203estate -> es_result_relations [0 ]= resultRelInfo ;
12041204#else
@@ -1232,7 +1232,7 @@ static void insert_tuple(Datum* values, bool* nulls)
12321232
12331233static void end_batch_insert ()
12341234{
1235- #if PG_VERSION_NUM >=150000
1235+ #if PG_VERSION_NUM >=140000
12361236ExecCloseIndices (estate -> es_result_relations [0 ]);
12371237#else
12381238ExecCloseIndices (estate -> es_result_relation_info );
@@ -3857,8 +3857,10 @@ vops_expression_tree_mutator(Node *node, void *context)
38573857}
38583858/* depth first traversal */
38593859node = expression_tree_mutator (node ,vops_expression_tree_mutator ,context
3860+ #if PG_VERSION_NUM < 140000
38603861#ifdef QTW_DONT_COPY_DEFAULT
38613862 ,0
3863+ #endif
38623864#endif
38633865);
38643866
@@ -4267,7 +4269,11 @@ vops_add_literal_type_casts(Node* node, Const** consts)
42674269else if (IsA (node ,A_Const ))
42684270{
42694271A_Const * ac = (A_Const * )node ;
4272+ #if PG_VERSION_NUM >=150000
4273+ if (ac -> val .sval .type == T_String && ac -> location >=0 )
4274+ #else
42704275if (ac -> val .type == T_String && ac -> location >=0 )
4276+ #endif
42714277{
42724278Const * c = consts [ac -> location ];
42734279if (c != NULL && c -> consttype != TEXTOID ) {
@@ -4447,7 +4453,15 @@ vops_substitute_tables_with_projections(char const* queryString, Query *query)
44474453}
44484454#if PG_VERSION_NUM >=100000
44494455parsetree = linitial_node (RawStmt ,parsetree_list );
4450- select = (SelectStmt * )parsetree -> stmt ;
4456+ #if PG_VERSION_NUM >=140000
4457+ if (parsetree -> stmt -> type == T_ExplainStmt )
4458+ {
4459+ ExplainStmt * explain = (ExplainStmt * )parsetree -> stmt ;
4460+ select = (SelectStmt * )explain -> query ;
4461+ }
4462+ else
4463+ #endif
4464+ select = (SelectStmt * )parsetree -> stmt ;
44514465#else
44524466parsetree = (Node * )linitial (parsetree_list );
44534467select = (SelectStmt * )parsetree ;
@@ -4580,17 +4594,18 @@ vops_resolve_functions(void)
45804594}
45814595}
45824596
4583- #if PG_VERSION_NUM >=150000
4597+ #if PG_VERSION_NUM >=140000
45844598static void vops_post_parse_analysis_hook (ParseState * pstate ,Query * query ,JumbleState * jstate )
45854599#else
45864600static void vops_post_parse_analysis_hook (ParseState * pstate ,Query * query )
45874601#endif
45884602{
45894603vops_var var ;
4604+
45904605/* Invoke original hook if needed */
45914606if (post_parse_analyze_hook_next )
45924607{
4593- #if PG_VERSION_NUM >=150000
4608+ #if PG_VERSION_NUM >=140000
45944609post_parse_analyze_hook_next (pstate ,query ,jstate );
45954610#else
45964611post_parse_analyze_hook_next (pstate ,query );