We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentd78bf69 commitf102e6eCopy full SHA for f102e6e
pg_pathman.c
@@ -187,6 +187,7 @@ PlannedStmt *
187
pathman_planner_hook(Query*parse,intcursorOptions,ParamListInfoboundParams)
188
{
189
PlannedStmt*result;
190
+ListCell*lc;
191
192
if (initialization_needed)
193
@@ -196,6 +197,15 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
196
197
inheritance_disabled= false;
198
disable_inheritance(parse);
199
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
209
/* Invoke original hook */
210
if (planner_hook_original)
211
result=planner_hook_original(parse,cursorOptions,boundParams);