Skip to content

Commit 5081a7b

Browse files
authored
Merge pull request #5 from supabase/master
Add compatiblity with postgres 13
2 parents db0f7a6 + 5ee64d2 commit 5081a7b

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

plan_filter.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@
2121
#include "optimizer/planner.h"
2222
#include "utils/guc.h"
2323

24+
#define PG13_GTE (PG_VERSION_NUM >= 130000)
25+
26+
#if PG13_GTE
27+
#define PLANNER_HOOK_PARAMS \
28+
Query *parse, const char *queryString \
29+
, int cursorOptions, ParamListInfo boundParams
30+
#else
31+
#define PLANNER_HOOK_PARAMS \
32+
Query *parse \
33+
, int cursorOptions, ParamListInfo boundParams
34+
#endif
35+
36+
#if PG13_GTE
37+
#define PLANNER_HOOK_ARGS \
38+
parse, queryString \
39+
, cursorOptions, boundParams
40+
#else
41+
#define PLANNER_HOOK_ARGS \
42+
parse \
43+
, cursorOptions, boundParams
44+
#endif
45+
46+
2447
PG_MODULE_MAGIC;
2548

2649
static double statement_cost_limit = 0.0;
@@ -31,9 +54,7 @@ static bool filter_select_only = false;
3154

3255
static planner_hook_type prev_planner_hook = NULL;
3356

34-
static PlannedStmt *limit_func(Query *parse,
35-
int cursorOptions,
36-
ParamListInfo boundParams);
57+
static PlannedStmt *limit_func(PLANNER_HOOK_PARAMS);
3758

3859
void _PG_init(void);
3960
void _PG_fini(void);
@@ -102,15 +123,15 @@ _PG_fini(void)
102123
}
103124

104125
static PlannedStmt *
105-
limit_func(Query *parse, int cursorOptions, ParamListInfo boundParams)
126+
limit_func(PLANNER_HOOK_PARAMS)
106127
{
107128
PlannedStmt *result;
108129

109130
/* this way we can daisy chain planner hooks if necessary */
110131
if (prev_planner_hook != NULL)
111-
result = (*prev_planner_hook) (parse, cursorOptions, boundParams);
132+
result = (*prev_planner_hook) (PLANNER_HOOK_ARGS);
112133
else
113-
result = standard_planner(parse, cursorOptions, boundParams);
134+
result = standard_planner(PLANNER_HOOK_ARGS);
114135

115136
if(filter_select_only && parse->commandType != CMD_SELECT)
116137
return result;

0 commit comments

Comments
 (0)