From 5b9376a7f82d11e4c04948f497adc520fce880f5 Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Tue, 18 Dec 2018 15:32:07 +0100 Subject: [PATCH] Check ownership before taking locks in distributed table creation --- src/backend/distributed/commands/create_distributed_table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 7e061c5bd..995a44226 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -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);