Skip to content

Commit 6760448

Browse files
committed
resolve merge conflicts
2 parents 1a27df7 + 38da2f7 commit 6760448

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

pathman.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ typedef struct PathmanState
121121
DsmArray databases;
122122
} PathmanState;
123123

124-
PathmanState *pmstate;
124+
extern bool pg_pathman_enable;
125+
extern PathmanState *pmstate;
125126

126127
#define PATHMAN_GET_DATUM(value, by_val) ( (by_val) ? (value) : PointerGetDatum(&value) )
127128

pg_pathman.c

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ typedef struct
5151
Oid new_varno;
5252
} change_varno_context;
5353

54+
bool pg_pathman_enable;
55+
PathmanState *pmstate;
56+
5457
/* Original hooks */
5558
static set_rel_pathlist_hook_type set_rel_pathlist_hook_original = NULL;
5659
static shmem_startup_hook_type shmem_startup_hook_original = NULL;
@@ -170,6 +173,17 @@ _PG_init(void)
170173
pickyappend_exec_methods.RestrPosCustomScan = NULL;
171174
pickyappend_exec_methods.ExplainCustomScan = pickyppend_explain;
172175

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+
173187
DefineCustomBoolVariable("pg_pathman.enable_pickyappend",
174188
"Enables the planner's use of PickyAppend custom node.",
175189
NULL,
@@ -255,27 +269,30 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
255269
PlannedStmt *result;
256270
ListCell *lc;
257271

258-
inheritance_disabled = false;
259-
switch(parse->commandType)
272+
if (pg_pathman_enable)
260273
{
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+
}
271287

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);
276292

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+
}
279296
}
280297

281298
/* Invoke original hook */
@@ -411,6 +428,9 @@ pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, Ran
411428
bool found;
412429
int first_child_relid = 0;
413430

431+
if (!pg_pathman_enable)
432+
return;
433+
414434
/* This works only for SELECT queries */
415435
if (root->parse->commandType != CMD_SELECT || !inheritance_disabled)
416436
return;

0 commit comments

Comments
 (0)