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

Commit1dd543c

Browse files
committed
disable constraint exclusion for subselects
1 parent524baca commit1dd543c

File tree

1 file changed

+42
-13
lines changed

1 file changed

+42
-13
lines changed

‎pg_pathman.c

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ static int append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
8181
RangeTblEntry*rte,intindex,OidchildOID,List*wrappers);
8282
staticNode*wrapper_make_expression(WrapperNode*wrap,intindex,bool*alwaysTrue);
8383
staticvoiddisable_inheritance(Query*parse);
84+
staticvoiddisable_inheritance_cte(Query*parse);
85+
staticvoiddisable_inheritance_subselect(Query*parse);
8486
boolinheritance_disabled;
8587

8688
/* Expression tree handlers */
@@ -240,7 +242,6 @@ PlannedStmt *
240242
pathman_planner_hook(Query*parse,intcursorOptions,ParamListInfoboundParams)
241243
{
242244
PlannedStmt*result;
243-
ListCell*lc;
244245

245246
if (pg_pathman_enable)
246247
{
@@ -252,20 +253,13 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
252253
break;
253254
caseCMD_UPDATE:
254255
caseCMD_DELETE:
256+
disable_inheritance_cte(parse);
257+
disable_inheritance_subselect(parse);
255258
handle_modification_query(parse);
256259
break;
257260
default:
258261
break;
259262
}
260-
261-
/* If query contains CTE (WITH statement) then handle subqueries too */
262-
foreach(lc,parse->cteList)
263-
{
264-
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
265-
266-
if (IsA(cte->ctequery,Query))
267-
disable_inheritance((Query*)cte->ctequery);
268-
}
269263
}
270264

271265
/* Invoke original hook */
@@ -284,10 +278,16 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
284278
staticvoid
285279
disable_inheritance(Query*parse)
286280
{
287-
RangeTblEntry*rte;
288-
ListCell*lc;
281+
ListCell*lc;
282+
RangeTblEntry*rte;
289283
PartRelationInfo*prel;
290-
boolfound;
284+
boolfound;
285+
286+
/* If query contains CTE (WITH statement) then handle subqueries too */
287+
disable_inheritance_cte(parse);
288+
289+
/* If query contains subselects */
290+
disable_inheritance_subselect(parse);
291291

292292
foreach(lc,parse->rtable)
293293
{
@@ -322,6 +322,35 @@ disable_inheritance(Query *parse)
322322
}
323323
}
324324

325+
staticvoid
326+
disable_inheritance_cte(Query*parse)
327+
{
328+
ListCell*lc;
329+
330+
foreach(lc,parse->cteList)
331+
{
332+
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
333+
334+
if (IsA(cte->ctequery,Query))
335+
disable_inheritance((Query*)cte->ctequery);
336+
}
337+
}
338+
339+
staticvoid
340+
disable_inheritance_subselect(Query*parse)
341+
{
342+
SubLink*sublink;
343+
344+
if (!parse->jointree|| !parse->jointree->quals)
345+
return;
346+
347+
sublink= (SubLink*)parse->jointree->quals;
348+
if (!IsA(sublink->subselect,Query))
349+
return;
350+
351+
disable_inheritance((Query*)sublink->subselect);
352+
}
353+
325354
/*
326355
* Checks if query is affects only one partition. If true then substitute
327356
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp