From: Tomas Vondra Date: Thu, 20 Apr 2017 19:05:25 +0000 (+0200) Subject: Propagate the distribution up when (root->distribution==NULL). X-Git-Tag: XL_10_R1BETA1~362 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=977fe5bc37454efe0c727fbb41df9be75a5af822;p=postgres-xl.git Propagate the distribution up when (root->distribution==NULL). Without this patch the planner was constricting paths like this: -> Material -> SubquerySubPath -> RemoteSubPath -> BitmapHeapScan which then led to failures to plan some of the UPDATE and DELETE queries in updatable_views. This fixes it, and makes the planner build the same paths as on XL 9.5 (without the RemoteSubPath, discarding the distribution info). This resolved all the 'could not plan distributed UPDATE/DELETE' in updatable_views, but not universally. So either this still is not entirely correct, or there's another independent bug. --- diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 7cc28acd24..89031d265e 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -6236,6 +6236,13 @@ equal_distributions(PlannerInfo *root, Distribution *dst1, static Path * adjust_path_distribution(PlannerInfo *root, Query *parse, Path *path) { + /* if the root distribution is NULL, set it to path distribution */ + if (!root->distribution) + { + root->distribution = path->distribution; + return path; + } + /* don't touch paths without distribution attached (catalogs etc.) */ if ((path->distribution == NULL) && (root->distribution == NULL)) return path;