summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2018-07-30 08:47:20 +0000
committerPavan Deolasee2018-07-31 07:07:35 +0000
commitcc03f5d3c371920f1d545f2bf6fe5ae08a2075f4 (patch)
tree751d9c49dc6a63946d473768bd8009f4e69be22e
parentd27064c246ad280080b5db19929535b0199d8276 (diff)
Ensure partition child tables inherit distribution properties correctly
While in restore mode, that we use to load schema when a new node is added to the cluster, the partition child tables should correctly inherit the distribution properties from the parent table. This support was lacking, thus leading to incorrect handling of such tables. Per report by Virendra Kumar.
-rw-r--r--src/backend/parser/parse_utilcmd.c11
-rw-r--r--src/backend/utils/cache/relcache.c10
2 files changed, 18 insertions, 3 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index d0870fd0dd..af1c429995 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -367,7 +367,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
* ERROR since Postgres-XL does not support inheriting from multiple
* parents.
*/
- if (stmt->inhRelations && IS_PGXC_COORDINATOR && autodistribute)
+ if (autodistribute && stmt->inhRelations &&
+ (IS_PGXC_COORDINATOR || isRestoreMode))
{
RangeVar *inh = (RangeVar *) linitial(stmt->inhRelations);
Relation rel;
@@ -468,6 +469,14 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
*/
if (IS_PGXC_COORDINATOR && autodistribute && !stmt->distributeby)
{
+ /*
+ * In restore-mode, the distribution clause should either be derived
+ * from the parent table or it must have been included in the table
+ * schema dump. Otherwise we risk deriving a different distribution
+ * strategy when dump is loaded on a new node.
+ */
+ Assert(!isRestoreMode);
+
/* always apply suggested subcluster */
stmt->subcluster = copyObject(cxt.subcluster);
if (cxt.distributeby)
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7a586f95cf..77206dc425 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1366,8 +1366,14 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
relation->trigdesc = NULL;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR &&
- relation->rd_id >= FirstNormalObjectId)
+ /*
+ * We need the locator info while restoring from a dump while adding a new
+ * node to the cluster and when there are partition tables. Distribution
+ * information for partition tables is derived from the parent table and we
+ * need the locator info for that.
+ */
+ if ((IS_PGXC_COORDINATOR || isRestoreMode) &&
+ relation->rd_id >= FirstNormalObjectId)
RelationBuildLocator(relation);
#endif
if (relation->rd_rel->relrowsecurity)