Check ownership before taking locks in distributed table creation

pull/2561/head
Marco Slot 2018-12-18 15:32:07 +01:00
parent 88717f31b3
commit 5b9376a7f8
1 changed files with 4 additions and 1 deletions

View File

@ -132,6 +132,7 @@ master_create_distributed_table(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
EnsureCoordinator();
EnsureTableOwner(relationId);
/*
* Lock target relation with an exclusive lock - there's no way to make
@ -197,6 +198,8 @@ create_distributed_table(PG_FUNCTION_ARGS)
distributionMethodOid = PG_GETARG_OID(2);
colocateWithTableNameText = PG_GETARG_TEXT_P(3);
EnsureTableOwner(relationId);
/*
* Lock target relation with an exclusive lock - there's no way to make
* sense of this table until we've committed, and we don't want multiple
@ -253,6 +256,7 @@ create_reference_table(PG_FUNCTION_ARGS)
EnsureCoordinator();
CheckCitusVersion(ERROR);
EnsureTableOwner(relationId);
/*
* Ensure schema exists on each worker node. We can not run this function
@ -638,7 +642,6 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
char *relationName = NULL;
Oid parentRelationId = InvalidOid;
EnsureTableOwner(relationId);
EnsureTableNotDistributed(relationId);
EnsureLocalTableEmptyIfNecessary(relationId, distributionMethod, viaDeprecatedAPI);
EnsureReplicationSettings(InvalidOid, replicationModel);