diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0b2a52463f..a1937d078b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -20388,6 +20388,14 @@ createPartitionTable(RangeVar *newPartName, Relation modelRel, */ newRel = table_openrv(newPartName, NoLock); + /* Check for case namespace was renamed during partition creation. */ + if (RelationGetNamespace(newRel) != RelationGetNamespace(modelRel)) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot create partition because namespace \"%s\" was changed to \"%s\"", + get_namespace_name(RelationGetNamespace(newRel)), + get_namespace_name(RelationGetNamespace(modelRel))))); + /* * We intended to create the partition with the same persistence as the * parent table, but we still need to recheck because that might be