diff --git a/src/backend/distributed/worker/worker_data_fetch_protocol.c b/src/backend/distributed/worker/worker_data_fetch_protocol.c index f26fb4892..9774f0fd4 100644 --- a/src/backend/distributed/worker/worker_data_fetch_protocol.c +++ b/src/backend/distributed/worker/worker_data_fetch_protocol.c @@ -146,6 +146,8 @@ worker_modify_identity_columns(PG_FUNCTION_ARGS) Oid tableRelationId = PG_GETARG_OID(0); + EnsureTableOwner(tableRelationId); + Relation tableRelation = relation_open(tableRelationId, AccessShareLock); TupleDesc tableTupleDesc = RelationGetDescr(tableRelation); relation_close(tableRelation, NoLock); diff --git a/src/test/regress/expected/generated_identity.out b/src/test/regress/expected/generated_identity.out index 4d21d3e68..29177e993 100644 --- a/src/test/regress/expected/generated_identity.out +++ b/src/test/regress/expected/generated_identity.out @@ -289,6 +289,14 @@ CREATE TABLE color ( color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE, color_name VARCHAR NOT NULL ); +-- https://github.com/citusdata/citus/issues/6694 +CREATE USER identity_test_user; +GRANT INSERT ON color TO identity_test_user; +GRANT USAGE ON SCHEMA generated_identities TO identity_test_user; +SET ROLE identity_test_user; +SELECT create_distributed_table('color', 'color_id'); +ERROR: must be owner of table color +SET ROLE postgres; SET citus.shard_replication_factor TO 1; SELECT create_distributed_table_concurrently('color', 'color_id'); create_distributed_table_concurrently @@ -297,10 +305,6 @@ SELECT create_distributed_table_concurrently('color', 'color_id'); (1 row) RESET citus.shard_replication_factor; --- https://github.com/citusdata/citus/issues/6694 -CREATE USER identity_test_user; -GRANT INSERT ON color TO identity_test_user; -GRANT USAGE ON SCHEMA generated_identities TO identity_test_user; \c - identity_test_user - :worker_1_port SET search_path TO generated_identities; SET client_min_messages to ERROR; diff --git a/src/test/regress/sql/generated_identity.sql b/src/test/regress/sql/generated_identity.sql index e1fbecd44..3638a1079 100644 --- a/src/test/regress/sql/generated_identity.sql +++ b/src/test/regress/sql/generated_identity.sql @@ -155,14 +155,19 @@ CREATE TABLE color ( color_name VARCHAR NOT NULL ); -SET citus.shard_replication_factor TO 1; -SELECT create_distributed_table_concurrently('color', 'color_id'); -RESET citus.shard_replication_factor; -- https://github.com/citusdata/citus/issues/6694 CREATE USER identity_test_user; GRANT INSERT ON color TO identity_test_user; GRANT USAGE ON SCHEMA generated_identities TO identity_test_user; +SET ROLE identity_test_user; +SELECT create_distributed_table('color', 'color_id'); + +SET ROLE postgres; +SET citus.shard_replication_factor TO 1; +SELECT create_distributed_table_concurrently('color', 'color_id'); +RESET citus.shard_replication_factor; + \c - identity_test_user - :worker_1_port SET search_path TO generated_identities; SET client_min_messages to ERROR;