Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f102e6e

Browse files
committed
handle CTE subqueries
1 parent d78bf69 commit f102e6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pg_pathman.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ PlannedStmt *
187187
pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
188188
{
189189
PlannedStmt *result;
190+
ListCell *lc;
190191

191192
if (initialization_needed)
192193
{
@@ -196,6 +197,15 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
196197
inheritance_disabled = false;
197198
disable_inheritance(parse);
198199

200+
/* If query contains CTE (WITH statement) then handle subqueries too */
201+
foreach(lc, parse->cteList)
202+
{
203+
CommonTableExpr *cte = (CommonTableExpr*) lfirst(lc);
204+
205+
if (IsA(cte->ctequery, Query))
206+
disable_inheritance((Query *)cte->ctequery);
207+
}
208+
199209
/* Invoke original hook */
200210
if (planner_hook_original)
201211
result = planner_hook_original(parse, cursorOptions, boundParams);

0 commit comments

Comments
 (0)