mirror of https://github.com/citusdata/citus.git
Add table ownership check for identity column modifications
parent
fe9304054a
commit
41e8255b16
|
@ -146,6 +146,8 @@ worker_modify_identity_columns(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
Oid tableRelationId = PG_GETARG_OID(0);
|
Oid tableRelationId = PG_GETARG_OID(0);
|
||||||
|
|
||||||
|
EnsureTableOwner(tableRelationId);
|
||||||
|
|
||||||
Relation tableRelation = relation_open(tableRelationId, AccessShareLock);
|
Relation tableRelation = relation_open(tableRelationId, AccessShareLock);
|
||||||
TupleDesc tableTupleDesc = RelationGetDescr(tableRelation);
|
TupleDesc tableTupleDesc = RelationGetDescr(tableRelation);
|
||||||
relation_close(tableRelation, NoLock);
|
relation_close(tableRelation, NoLock);
|
||||||
|
|
|
@ -289,6 +289,14 @@ CREATE TABLE color (
|
||||||
color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE,
|
color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE,
|
||||||
color_name VARCHAR NOT NULL
|
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;
|
SET citus.shard_replication_factor TO 1;
|
||||||
SELECT create_distributed_table_concurrently('color', 'color_id');
|
SELECT create_distributed_table_concurrently('color', 'color_id');
|
||||||
create_distributed_table_concurrently
|
create_distributed_table_concurrently
|
||||||
|
@ -297,10 +305,6 @@ SELECT create_distributed_table_concurrently('color', 'color_id');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
RESET citus.shard_replication_factor;
|
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
|
\c - identity_test_user - :worker_1_port
|
||||||
SET search_path TO generated_identities;
|
SET search_path TO generated_identities;
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
|
@ -155,14 +155,19 @@ CREATE TABLE color (
|
||||||
color_name VARCHAR NOT NULL
|
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
|
-- https://github.com/citusdata/citus/issues/6694
|
||||||
CREATE USER identity_test_user;
|
CREATE USER identity_test_user;
|
||||||
GRANT INSERT ON color TO identity_test_user;
|
GRANT INSERT ON color TO identity_test_user;
|
||||||
GRANT USAGE ON SCHEMA generated_identities 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
|
\c - identity_test_user - :worker_1_port
|
||||||
SET search_path TO generated_identities;
|
SET search_path TO generated_identities;
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
|
|
Loading…
Reference in New Issue