onder_correlated
Onder Kalaci 2020-12-15 10:39:02 +03:00
parent 5869859467
commit f4f979bcc3
3 changed files with 5 additions and 3 deletions

View File

@ -934,7 +934,8 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
* push down SQL features within such a function, as long as co-located join * push down SQL features within such a function, as long as co-located join
* checks are applied. * checks are applied.
*/ */
if (!contain_vars_of_level((Node *) subqueryTree, 1)) #include "distributed/recursive_planning.h"
if (!ContainsReferencesToOuterQuery(subqueryTree))
{ {
if (subqueryTree->limitOffset) if (subqueryTree->limitOffset)
{ {

View File

@ -171,7 +171,6 @@ static void RecursivelyPlanSubquery(Query *subquery,
static DistributedSubPlan * CreateDistributedSubPlan(uint32 subPlanId, static DistributedSubPlan * CreateDistributedSubPlan(uint32 subPlanId,
Query *subPlanQuery); Query *subPlanQuery);
static bool CteReferenceListWalker(Node *node, CteReferenceWalkerContext *context); static bool CteReferenceListWalker(Node *node, CteReferenceWalkerContext *context);
static bool ContainsReferencesToOuterQuery(Query *query);
static bool ContainsReferencesToOuterQueryWalker(Node *node, static bool ContainsReferencesToOuterQueryWalker(Node *node,
VarLevelsUpWalkerContext *context); VarLevelsUpWalkerContext *context);
static bool NodeContainsSubqueryReferencingOuterQuery(Node *node); static bool NodeContainsSubqueryReferencingOuterQuery(Node *node);
@ -1238,7 +1237,7 @@ CteReferenceListWalker(Node *node, CteReferenceWalkerContext *context)
* anything that points outside of the query itself. Such queries cannot be * anything that points outside of the query itself. Such queries cannot be
* planned recursively. * planned recursively.
*/ */
static bool bool
ContainsReferencesToOuterQuery(Query *query) ContainsReferencesToOuterQuery(Query *query)
{ {
VarLevelsUpWalkerContext context = { 0 }; VarLevelsUpWalkerContext context = { 0 };

View File

@ -22,6 +22,8 @@
#include "nodes/relation.h" #include "nodes/relation.h"
#endif #endif
extern bool ContainsReferencesToOuterQuery(Query *query);
extern List * GenerateSubplansForSubqueriesAndCTEs(uint64 planId, Query *originalQuery, extern List * GenerateSubplansForSubqueriesAndCTEs(uint64 planId, Query *originalQuery,
PlannerRestrictionContext * PlannerRestrictionContext *
plannerRestrictionContext); plannerRestrictionContext);