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

Commit71132d4

Browse files
committed
pathman: disable constraint exclusion mechanism for subselects
1 parentacafdea commit71132d4

File tree

1 file changed

+42
-13
lines changed

1 file changed

+42
-13
lines changed

‎contrib/pg_pathman/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 */
@@ -254,7 +256,6 @@ PlannedStmt *
254256
pathman_planner_hook(Query*parse,intcursorOptions,ParamListInfoboundParams)
255257
{
256258
PlannedStmt*result;
257-
ListCell*lc;
258259

259260
if (pg_pathman_enable)
260261
{
@@ -266,20 +267,13 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
266267
break;
267268
caseCMD_UPDATE:
268269
caseCMD_DELETE:
270+
disable_inheritance_cte(parse);
271+
disable_inheritance_subselect(parse);
269272
handle_modification_query(parse);
270273
break;
271274
default:
272275
break;
273276
}
274-
275-
/* If query contains CTE (WITH statement) then handle subqueries too */
276-
foreach(lc,parse->cteList)
277-
{
278-
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
279-
280-
if (IsA(cte->ctequery,Query))
281-
disable_inheritance((Query*)cte->ctequery);
282-
}
283277
}
284278

285279
/* Invoke original hook */
@@ -298,10 +292,16 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
298292
staticvoid
299293
disable_inheritance(Query*parse)
300294
{
301-
RangeTblEntry*rte;
302-
ListCell*lc;
295+
ListCell*lc;
296+
RangeTblEntry*rte;
303297
PartRelationInfo*prel;
304-
boolfound;
298+
boolfound;
299+
300+
/* If query contains CTE (WITH statement) then handle subqueries too */
301+
disable_inheritance_cte(parse);
302+
303+
/* If query contains subselects */
304+
disable_inheritance_subselect(parse);
305305

306306
foreach(lc,parse->rtable)
307307
{
@@ -336,6 +336,35 @@ disable_inheritance(Query *parse)
336336
}
337337
}
338338

339+
staticvoid
340+
disable_inheritance_cte(Query*parse)
341+
{
342+
ListCell*lc;
343+
344+
foreach(lc,parse->cteList)
345+
{
346+
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
347+
348+
if (IsA(cte->ctequery,Query))
349+
disable_inheritance((Query*)cte->ctequery);
350+
}
351+
}
352+
353+
staticvoid
354+
disable_inheritance_subselect(Query*parse)
355+
{
356+
SubLink*sublink;
357+
358+
if (!parse->jointree|| !parse->jointree->quals)
359+
return;
360+
361+
sublink= (SubLink*)parse->jointree->quals;
362+
if (!IsA(sublink->subselect,Query))
363+
return;
364+
365+
disable_inheritance((Query*)sublink->subselect);
366+
}
367+
339368
/*
340369
* Checks if query is affects only one partition. If true then substitute
341370
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp