mirror of https://github.com/citusdata/citus.git
Check table ownership in upgrade_to_reference_table
parent
fc9f981525
commit
aab9f623eb
|
@ -60,8 +60,9 @@ upgrade_to_reference_table(PG_FUNCTION_ARGS)
|
||||||
uint64 shardId = INVALID_SHARD_ID;
|
uint64 shardId = INVALID_SHARD_ID;
|
||||||
DistTableCacheEntry *tableEntry = NULL;
|
DistTableCacheEntry *tableEntry = NULL;
|
||||||
|
|
||||||
EnsureCoordinator();
|
|
||||||
CheckCitusVersion(ERROR);
|
CheckCitusVersion(ERROR);
|
||||||
|
EnsureCoordinator();
|
||||||
|
EnsureTableOwner(relationId);
|
||||||
|
|
||||||
if (!IsDistributedTable(relationId))
|
if (!IsDistributedTable(relationId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,14 @@ SELECT create_distributed_table('test', 'id');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.shard_count TO 1;
|
||||||
|
CREATE TABLE singleshard (id integer, val integer);
|
||||||
|
SELECT create_distributed_table('singleshard', 'id');
|
||||||
|
create_distributed_table
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- turn off propagation to avoid Enterprise processing the following section
|
-- turn off propagation to avoid Enterprise processing the following section
|
||||||
SET citus.enable_ddl_propagation TO off;
|
SET citus.enable_ddl_propagation TO off;
|
||||||
CREATE USER full_access;
|
CREATE USER full_access;
|
||||||
|
@ -212,6 +220,9 @@ ERROR: permission denied for table test
|
||||||
ABORT;
|
ABORT;
|
||||||
SELECT * FROM citus_stat_statements_reset();
|
SELECT * FROM citus_stat_statements_reset();
|
||||||
ERROR: permission denied for function citus_stat_statements_reset
|
ERROR: permission denied for function citus_stat_statements_reset
|
||||||
|
-- should not be allowed to upgrade to reference table
|
||||||
|
SELECT upgrade_to_reference_table('singleshard');
|
||||||
|
ERROR: must be owner of table singleshard
|
||||||
-- table owner should be the same on the shards, even when distributing the table as superuser
|
-- table owner should be the same on the shards, even when distributing the table as superuser
|
||||||
SET ROLE full_access;
|
SET ROLE full_access;
|
||||||
CREATE TABLE my_table (id integer, val integer);
|
CREATE TABLE my_table (id integer, val integer);
|
||||||
|
@ -231,6 +242,7 @@ SELECT result FROM run_command_on_workers($$SELECT tableowner FROM pg_tables WHE
|
||||||
|
|
||||||
DROP TABLE my_table;
|
DROP TABLE my_table;
|
||||||
DROP TABLE test;
|
DROP TABLE test;
|
||||||
|
DROP TABLE singleshard;
|
||||||
DROP USER full_access;
|
DROP USER full_access;
|
||||||
DROP USER read_access;
|
DROP USER read_access;
|
||||||
DROP USER no_access;
|
DROP USER no_access;
|
||||||
|
|
|
@ -16,6 +16,10 @@ SET citus.shard_replication_factor TO 1;
|
||||||
CREATE TABLE test (id integer, val integer);
|
CREATE TABLE test (id integer, val integer);
|
||||||
SELECT create_distributed_table('test', 'id');
|
SELECT create_distributed_table('test', 'id');
|
||||||
|
|
||||||
|
SET citus.shard_count TO 1;
|
||||||
|
CREATE TABLE singleshard (id integer, val integer);
|
||||||
|
SELECT create_distributed_table('singleshard', 'id');
|
||||||
|
|
||||||
-- turn off propagation to avoid Enterprise processing the following section
|
-- turn off propagation to avoid Enterprise processing the following section
|
||||||
SET citus.enable_ddl_propagation TO off;
|
SET citus.enable_ddl_propagation TO off;
|
||||||
|
|
||||||
|
@ -138,6 +142,9 @@ ABORT;
|
||||||
|
|
||||||
SELECT * FROM citus_stat_statements_reset();
|
SELECT * FROM citus_stat_statements_reset();
|
||||||
|
|
||||||
|
-- should not be allowed to upgrade to reference table
|
||||||
|
SELECT upgrade_to_reference_table('singleshard');
|
||||||
|
|
||||||
-- table owner should be the same on the shards, even when distributing the table as superuser
|
-- table owner should be the same on the shards, even when distributing the table as superuser
|
||||||
SET ROLE full_access;
|
SET ROLE full_access;
|
||||||
CREATE TABLE my_table (id integer, val integer);
|
CREATE TABLE my_table (id integer, val integer);
|
||||||
|
@ -147,6 +154,7 @@ SELECT result FROM run_command_on_workers($$SELECT tableowner FROM pg_tables WHE
|
||||||
|
|
||||||
DROP TABLE my_table;
|
DROP TABLE my_table;
|
||||||
DROP TABLE test;
|
DROP TABLE test;
|
||||||
|
DROP TABLE singleshard;
|
||||||
DROP USER full_access;
|
DROP USER full_access;
|
||||||
DROP USER read_access;
|
DROP USER read_access;
|
||||||
DROP USER no_access;
|
DROP USER no_access;
|
||||||
|
|
Loading…
Reference in New Issue