Skip to content

Commit cf82121

Browse files
committed
Added support for PG14 and PG15
1 parent c5fc2fa commit cf82121

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

Diff for: deparse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ vops_deparse_type_name(Oid type_oid, int32 typemod)
405405
#if PG_VERSION_NUM>=110000
406406
uint8 flags = FORMAT_TYPE_TYPEMOD_GIVEN;
407407

408-
#if PG_VERSION_NUM>=150000
408+
#if PG_VERSION_NUM>=140000
409409
if (type_oid >= FirstGenbkiObjectId)
410410
#else
411411
if (type_oid >= FirstBootstrapObjectId)

Diff for: vops.c

+23-8
Original file line numberDiff line numberDiff line change
@@ -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()
11571157
if (HeapTupleIsHeapOnly(tuple))
11581158
return;
11591159

1160-
#if PG_VERSION_NUM>=150000
1160+
#if PG_VERSION_NUM>=140000
11611161
if (estate->es_result_relations[0]->ri_NumIndices > 0)
11621162
{
11631163
recheckIndexes = ExecInsertIndexTuples(estate->es_result_relations[0],
@@ -1171,7 +1171,7 @@ UserTableUpdateOpenIndexes()
11711171
&tuple->t_self,
11721172
#endif
11731173
estate,
1174-
#if PG_VERSION_NUM>=150000
1174+
#if PG_VERSION_NUM>=140000
11751175
true,
11761176
#endif
11771177
false, NULL, NIL);
@@ -1198,7 +1198,7 @@ static void begin_batch_insert(Oid oid)
11981198
resultRelInfo->ri_RelationDesc = rel;
11991199
resultRelInfo->ri_TrigInstrument = NULL;
12001200

1201-
#if PG_VERSION_NUM>=150000
1201+
#if PG_VERSION_NUM>=140000
12021202
estate->es_result_relations = (ResultRelInfo **)palloc(sizeof(ResultRelInfo *));
12031203
estate->es_result_relations[0] = resultRelInfo;
12041204
#else
@@ -1232,7 +1232,7 @@ static void insert_tuple(Datum* values, bool* nulls)
12321232

12331233
static void end_batch_insert()
12341234
{
1235-
#if PG_VERSION_NUM>=150000
1235+
#if PG_VERSION_NUM>=140000
12361236
ExecCloseIndices(estate->es_result_relations[0]);
12371237
#else
12381238
ExecCloseIndices(estate->es_result_relation_info);
@@ -3857,8 +3857,10 @@ vops_expression_tree_mutator(Node *node, void *context)
38573857
}
38583858
/* depth first traversal */
38593859
node = 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)
42674269
else if (IsA(node, A_Const))
42684270
{
42694271
A_Const* ac = (A_Const*)node;
4272+
#if PG_VERSION_NUM >= 150000
4273+
if (ac->val.sval.type == T_String && ac->location >= 0)
4274+
#else
42704275
if (ac->val.type == T_String && ac->location >= 0)
4276+
#endif
42714277
{
42724278
Const* c = consts[ac->location];
42734279
if (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
44494455
parsetree = 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
44524466
parsetree = (Node*) linitial(parsetree_list);
44534467
select = (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
45844598
static void vops_post_parse_analysis_hook(ParseState *pstate, Query *query, JumbleState *jstate)
45854599
#else
45864600
static void vops_post_parse_analysis_hook(ParseState *pstate, Query *query)
45874601
#endif
45884602
{
45894603
vops_var var;
4604+
45904605
/* Invoke original hook if needed */
45914606
if (post_parse_analyze_hook_next)
45924607
{
4593-
#if PG_VERSION_NUM>=150000
4608+
#if PG_VERSION_NUM>=140000
45944609
post_parse_analyze_hook_next(pstate, query, jstate);
45954610
#else
45964611
post_parse_analyze_hook_next(pstate, query);

Diff for: vops_fdw.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "optimizer/paths.h"
3636
#include "optimizer/planmain.h"
3737
#include "optimizer/plancat.h"
38-
#if PG_VERSION_NUM>=150000
38+
#if PG_VERSION_NUM>=140000
3939
#include "optimizer/prep.h"
4040
#endif
4141
#include "optimizer/restrictinfo.h"
@@ -1000,7 +1000,7 @@ estimate_path_cost_size(PlannerInfo *root,
10001000
MemSet(&aggcosts, 0, sizeof(AggClauseCosts));
10011001
if (root->parse->hasAggs)
10021002
{
1003-
#if PG_VERSION_NUM>=150000
1003+
#if PG_VERSION_NUM>=140000
10041004
get_agg_clause_costs(root, AGGSPLIT_SIMPLE, &aggcosts);
10051005
#else
10061006
get_agg_clause_costs(root, (Node *) fpinfo->grouped_tlist,
@@ -1016,7 +1016,7 @@ estimate_path_cost_size(PlannerInfo *root,
10161016
get_sortgrouplist_exprs(root->parse->groupClause,
10171017
fpinfo->grouped_tlist),
10181018
input_rows,
1019-
#if PG_VERSION_NUM>=150000
1019+
#if PG_VERSION_NUM>=140000
10201020
NULL,
10211021
#endif
10221022
NULL);
@@ -1542,7 +1542,11 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,
15421542
if (rowstoskip <= 0)
15431543
{
15441544
/* Choose a random reservoir element to replace. */
1545+
#if PG_VERSION_NUM >= 150000
1546+
int pos = (int) (targrows * sampler_random_fract(&rstate.randstate));
1547+
#else
15451548
int pos = (int) (targrows * sampler_random_fract(rstate.randstate));
1549+
#endif
15461550
Assert(pos >= 0 && pos < targrows);
15471551
SPI_freetuple(rows[pos]);
15481552
rows[pos] = SPI_copytuple(SPI_tuptable->vals[0]);

0 commit comments

Comments
 (0)