Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38da2f7

Browse files
committed
add 'pg_pathman.enable' GUC variable, move pmstate to pg_pathman.c
1 parentde5be1d commit38da2f7

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

‎pathman.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ typedef struct PathmanState
119119
DsmArraydatabases;
120120
}PathmanState;
121121

122-
PathmanState*pmstate;
122+
externboolpg_pathman_enable;
123+
externPathmanState*pmstate;
123124

124125
#definePATHMAN_GET_DATUM(value,by_val) ( (by_val) ? (value) : PointerGetDatum(&value) )
125126

‎pg_pathman.c

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include"utils/date.h"
3434
#include"utils/typcache.h"
3535
#include"utils/lsyscache.h"
36+
#include"utils/guc.h"
3637
#include"access/heapam.h"
3738
#include"access/nbtree.h"
3839
#include"storage/ipc.h"
@@ -55,6 +56,9 @@ typedef struct
5556
List*rangeset;
5657
}WrapperNode;
5758

59+
boolpg_pathman_enable;
60+
PathmanState*pmstate;
61+
5862
/* Original hooks */
5963
staticset_rel_pathlist_hook_typeset_rel_pathlist_hook_original=NULL;
6064
staticshmem_startup_hook_typeshmem_startup_hook_original=NULL;
@@ -152,6 +156,17 @@ _PG_init(void)
152156
post_parse_analyze_hook=pathman_post_parse_analysis_hook;
153157
planner_hook_original=planner_hook;
154158
planner_hook=pathman_planner_hook;
159+
160+
DefineCustomBoolVariable("pg_pathman.enable",
161+
"Enables pg_pathman's optimizations during the planner stage",
162+
NULL,
163+
&pg_pathman_enable,
164+
true,
165+
PGC_USERSET,
166+
0,
167+
NULL,
168+
NULL,
169+
NULL);
155170
}
156171

157172
void
@@ -227,27 +242,30 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
227242
PlannedStmt*result;
228243
ListCell*lc;
229244

230-
inheritance_disabled= false;
231-
switch(parse->commandType)
245+
if (pg_pathman_enable)
232246
{
233-
caseCMD_SELECT:
234-
disable_inheritance(parse);
235-
break;
236-
caseCMD_UPDATE:
237-
caseCMD_DELETE:
238-
handle_modification_query(parse);
239-
break;
240-
default:
241-
break;
242-
}
247+
inheritance_disabled= false;
248+
switch(parse->commandType)
249+
{
250+
caseCMD_SELECT:
251+
disable_inheritance(parse);
252+
break;
253+
caseCMD_UPDATE:
254+
caseCMD_DELETE:
255+
handle_modification_query(parse);
256+
break;
257+
default:
258+
break;
259+
}
243260

244-
/* If query contains CTE (WITH statement) then handle subqueries too */
245-
foreach(lc,parse->cteList)
246-
{
247-
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
261+
/* If query contains CTE (WITH statement) then handle subqueries too */
262+
foreach(lc,parse->cteList)
263+
{
264+
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
248265

249-
if (IsA(cte->ctequery,Query))
250-
disable_inheritance((Query*)cte->ctequery);
266+
if (IsA(cte->ctequery,Query))
267+
disable_inheritance((Query*)cte->ctequery);
268+
}
251269
}
252270

253271
/* Invoke original hook */
@@ -382,6 +400,9 @@ pathman_set_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, Ran
382400
boolfound;
383401
intfirst_child_relid=0;
384402

403+
if (!pg_pathman_enable)
404+
return;
405+
385406
/* This works only for SELECT queries */
386407
if (root->parse->commandType!=CMD_SELECT|| !inheritance_disabled)
387408
return;
@@ -1017,29 +1038,29 @@ handle_binary_opexpr(const PartRelationInfo *prel, WrapperNode *result,
10171038

10181039
if ((cmp_min<0&&
10191040
(strategy==BTLessEqualStrategyNumber||
1020-
strategy==BTEqualStrategyNumber))||
1041+
strategy==BTEqualStrategyNumber))||
10211042
(cmp_min <=0&&strategy==BTLessStrategyNumber))
10221043
{
10231044
result->rangeset=NIL;
10241045
return;
10251046
}
10261047

1027-
if (cmp_max >=0&& (strategy==BTGreaterEqualStrategyNumber||
1048+
if (cmp_max >=0&& (strategy==BTGreaterEqualStrategyNumber||
10281049
strategy==BTGreaterStrategyNumber||
10291050
strategy==BTEqualStrategyNumber))
10301051
{
10311052
result->rangeset=NIL;
10321053
return;
10331054
}
10341055

1035-
if ((cmp_min<0&&strategy==BTGreaterStrategyNumber)||
1056+
if ((cmp_min<0&&strategy==BTGreaterStrategyNumber)||
10361057
(cmp_min <=0&&strategy==BTGreaterEqualStrategyNumber))
10371058
{
10381059
result->rangeset=list_make1_irange(make_irange(startidx,endidx, false));
10391060
return;
10401061
}
10411062

1042-
if (cmp_max >=0&& (strategy==BTLessEqualStrategyNumber||
1063+
if (cmp_max >=0&& (strategy==BTLessEqualStrategyNumber||
10431064
strategy==BTLessStrategyNumber))
10441065
{
10451066
result->rangeset=list_make1_irange(make_irange(startidx,endidx, false));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp