21
21
#include "optimizer/planner.h"
22
22
#include "utils/guc.h"
23
23
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
+
24
47
PG_MODULE_MAGIC ;
25
48
26
49
static double statement_cost_limit = 0.0 ;
@@ -31,9 +54,7 @@ static bool filter_select_only = false;
31
54
32
55
static planner_hook_type prev_planner_hook = NULL ;
33
56
34
- static PlannedStmt * limit_func (Query * parse ,
35
- int cursorOptions ,
36
- ParamListInfo boundParams );
57
+ static PlannedStmt * limit_func (PLANNER_HOOK_PARAMS );
37
58
38
59
void _PG_init (void );
39
60
void _PG_fini (void );
@@ -102,15 +123,15 @@ _PG_fini(void)
102
123
}
103
124
104
125
static PlannedStmt *
105
- limit_func (Query * parse , int cursorOptions , ParamListInfo boundParams )
126
+ limit_func (PLANNER_HOOK_PARAMS )
106
127
{
107
128
PlannedStmt * result ;
108
129
109
130
/* this way we can daisy chain planner hooks if necessary */
110
131
if (prev_planner_hook != NULL )
111
- result = (* prev_planner_hook ) (parse , cursorOptions , boundParams );
132
+ result = (* prev_planner_hook ) (PLANNER_HOOK_ARGS );
112
133
else
113
- result = standard_planner (parse , cursorOptions , boundParams );
134
+ result = standard_planner (PLANNER_HOOK_ARGS );
114
135
115
136
if (filter_select_only && parse -> commandType != CMD_SELECT )
116
137
return result ;
0 commit comments