diff options
| -rw-r--r-- | src/backend/parser/parse_utilcmd.c | 11 | ||||
| -rw-r--r-- | src/backend/utils/cache/relcache.c | 10 |
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) |
