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

Commitf6f991f

Browse files
committed
Merge master (resolve conflicts)
2 parents98d44c0 +bb30bce commitf6f991f

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

‎pg_pathman.c

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ static PlannedStmt * pathman_planner_hook(Query *parse, int cursorOptions, Param
7070
staticvoidhandle_modification_query(Query*parse);
7171
staticNode*wrapper_make_expression(WrapperNode*wrap,intindex,bool*alwaysTrue);
7272
staticvoiddisable_inheritance(Query*parse);
73+
staticvoiddisable_inheritance_cte(Query*parse);
74+
staticvoiddisable_inheritance_subselect(Query*parse);
7375

7476
/* Expression tree handlers */
7577
staticintmake_hash(constPartRelationInfo*prel,intvalue);
@@ -252,7 +254,6 @@ PlannedStmt *
252254
pathman_planner_hook(Query*parse,intcursorOptions,ParamListInfoboundParams)
253255
{
254256
PlannedStmt*result;
255-
ListCell*lc;
256257

257258
if (pg_pathman_enable)
258259
{
@@ -264,20 +265,13 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
264265
break;
265266
caseCMD_UPDATE:
266267
caseCMD_DELETE:
268+
disable_inheritance_cte(parse);
269+
disable_inheritance_subselect(parse);
267270
handle_modification_query(parse);
268271
break;
269272
default:
270273
break;
271274
}
272-
273-
/* If query contains CTE (WITH statement) then handle subqueries too */
274-
foreach(lc,parse->cteList)
275-
{
276-
CommonTableExpr*cte= (CommonTableExpr*)lfirst(lc);
277-
278-
if (IsA(cte->ctequery,Query))
279-
disable_inheritance((Query*)cte->ctequery);
280-
}
281275
}
282276

283277
/* Invoke original hook */
@@ -296,10 +290,16 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
296290
staticvoid
297291
disable_inheritance(Query*parse)
298292
{
299-
RangeTblEntry*rte;
300-
ListCell*lc;
293+
ListCell*lc;
294+
RangeTblEntry*rte;
301295
PartRelationInfo*prel;
302-
boolfound;
296+
boolfound;
297+
298+
/* If query contains CTE (WITH statement) then handle subqueries too */
299+
disable_inheritance_cte(parse);
300+
301+
/* If query contains subselects */
302+
disable_inheritance_subselect(parse);
303303

304304
foreach(lc,parse->rtable)
305305
{
@@ -334,6 +334,38 @@ disable_inheritance(Query *parse)
334334
}
335335
}
336336

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp