@@ -51,6 +51,9 @@ typedef struct
51
51
Oid new_varno ;
52
52
}change_varno_context ;
53
53
54
+ bool pg_pathman_enable ;
55
+ PathmanState * pmstate ;
56
+
54
57
/* Original hooks */
55
58
static set_rel_pathlist_hook_type set_rel_pathlist_hook_original = NULL ;
56
59
static shmem_startup_hook_type shmem_startup_hook_original = NULL ;
@@ -170,6 +173,17 @@ _PG_init(void)
170
173
pickyappend_exec_methods .RestrPosCustomScan = NULL ;
171
174
pickyappend_exec_methods .ExplainCustomScan = pickyppend_explain ;
172
175
176
+ DefineCustomBoolVariable ("pg_pathman.enable" ,
177
+ "Enables pg_pathman's optimizations during the planner stage" ,
178
+ NULL ,
179
+ & pg_pathman_enable ,
180
+ true,
181
+ PGC_USERSET ,
182
+ 0 ,
183
+ NULL ,
184
+ NULL ,
185
+ NULL );
186
+
173
187
DefineCustomBoolVariable ("pg_pathman.enable_pickyappend" ,
174
188
"Enables the planner's use of PickyAppend custom node." ,
175
189
NULL ,
@@ -255,27 +269,30 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
255
269
PlannedStmt * result ;
256
270
ListCell * lc ;
257
271
258
- inheritance_disabled = false;
259
- switch (parse -> commandType )
272
+ if (pg_pathman_enable )
260
273
{
261
- case CMD_SELECT :
262
- disable_inheritance (parse );
263
- break ;
264
- case CMD_UPDATE :
265
- case CMD_DELETE :
266
- handle_modification_query (parse );
267
- break ;
268
- default :
269
- break ;
270
- }
274
+ inheritance_disabled = false;
275
+ switch (parse -> commandType )
276
+ {
277
+ case CMD_SELECT :
278
+ disable_inheritance (parse );
279
+ break ;
280
+ case CMD_UPDATE :
281
+ case CMD_DELETE :
282
+ handle_modification_query (parse );
283
+ break ;
284
+ default :
285
+ break ;
286
+ }
271
287
272
- /* If query contains CTE (WITH statement) then handle subqueries too */
273
- foreach (lc ,parse -> cteList )
274
- {
275
- CommonTableExpr * cte = (CommonTableExpr * )lfirst (lc );
288
+ /* If query contains CTE (WITH statement) then handle subqueries too */
289
+ foreach (lc ,parse -> cteList )
290
+ {
291
+ CommonTableExpr * cte = (CommonTableExpr * )lfirst (lc );
276
292
277
- if (IsA (cte -> ctequery ,Query ))
278
- disable_inheritance ((Query * )cte -> ctequery );
293
+ if (IsA (cte -> ctequery ,Query ))
294
+ disable_inheritance ((Query * )cte -> ctequery );
295
+ }
279
296
}
280
297
281
298
/* Invoke original hook */
@@ -411,6 +428,9 @@ pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, Ran
411
428
bool found ;
412
429
int first_child_relid = 0 ;
413
430
431
+ if (!pg_pathman_enable )
432
+ return ;
433
+
414
434
/* This works only for SELECT queries */
415
435
if (root -> parse -> commandType != CMD_SELECT || !inheritance_disabled )
416
436
return ;