Repository: incubator-hawq
Updated Branches:
  refs/heads/master ae38cfbd6 -> 90ab2d406


Fallback to planner for command: ALTER TABLE SET DISTRIBUTED BY


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/90ab2d40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/90ab2d40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/90ab2d40

Branch: refs/heads/master
Commit: 90ab2d40663c06cf87b40ab38c5ffb36c044fdc3
Parents: ae38cfb
Author: Venkatesh Raghavan <[email protected]>
Authored: Fri Jan 15 12:01:46 2016 -0800
Committer: Venkatesh Raghavan <[email protected]>
Committed: Fri Jan 15 12:01:46 2016 -0800

----------------------------------------------------------------------
 src/backend/commands/tablecmds.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/90ab2d40/src/backend/commands/tablecmds.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 35230bb..6126b7e 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -13265,6 +13265,16 @@ ATExecSetDistributedBy(Relation rel, Node *node, 
AlterTableCmd *cmd)
                if (!ldistro)
                        ldistro = make_dist_clause(rel);
 
+               /* force the use of legacy query optimizer, since PQO will not 
redistribute the tuples if the current and required
+                  distributions are both RANDOM even when reorganize is set to 
"true"*/
+               bool saveOptimizerGucValue = optimizer;
+               optimizer = false;
+
+               if (saveOptimizerGucValue)
+               {
+                       elog(LOG, "ALTER SET DISTRIBUTED BY: falling back to 
legacy query optimizer to ensure re-distribution of tuples.");
+               }
+
                PG_TRY();
                {
                        /* 
@@ -13289,10 +13299,14 @@ ATExecSetDistributedBy(Relation rel, Node *node, 
AlterTableCmd *cmd)
 
                        /* Restore the old snapshot */
                        ActiveSnapshot = saveSnapshot;
+                       optimizer = saveOptimizerGucValue;
+
                }
                PG_CATCH();
                {
                        ActiveSnapshot = saveSnapshot;
+                       optimizer = saveOptimizerGucValue;
+
                        PG_RE_THROW();
                }
                PG_END_TRY();

Reply via email to