mirror of https://github.com/citusdata/citus.git
Disable alter_distributed_table for tenant tables
parent
4b67e398b1
commit
f68ea20009
|
@ -196,6 +196,7 @@ static void EnsureTableNotReferencing(Oid relationId, char conversionType);
|
||||||
static void EnsureTableNotReferenced(Oid relationId, char conversionType);
|
static void EnsureTableNotReferenced(Oid relationId, char conversionType);
|
||||||
static void EnsureTableNotForeign(Oid relationId);
|
static void EnsureTableNotForeign(Oid relationId);
|
||||||
static void EnsureTableNotPartition(Oid relationId);
|
static void EnsureTableNotPartition(Oid relationId);
|
||||||
|
static void ErrorIfColocateWithTenantTable(char *colocateWith);
|
||||||
static TableConversionState * CreateTableConversion(TableConversionParameters *params);
|
static TableConversionState * CreateTableConversion(TableConversionParameters *params);
|
||||||
static void CreateDistributedTableLike(TableConversionState *con);
|
static void CreateDistributedTableLike(TableConversionState *con);
|
||||||
static void CreateCitusTableLike(TableConversionState *con);
|
static void CreateCitusTableLike(TableConversionState *con);
|
||||||
|
@ -437,6 +438,9 @@ AlterDistributedTable(TableConversionParameters *params)
|
||||||
"is not distributed")));
|
"is not distributed")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorIfTenantTable(params->relationId, "alter_distributed_table");
|
||||||
|
ErrorIfColocateWithTenantTable(params->colocateWith);
|
||||||
|
|
||||||
EnsureTableNotForeign(params->relationId);
|
EnsureTableNotForeign(params->relationId);
|
||||||
EnsureTableNotPartition(params->relationId);
|
EnsureTableNotPartition(params->relationId);
|
||||||
EnsureHashDistributedTable(params->relationId);
|
EnsureHashDistributedTable(params->relationId);
|
||||||
|
@ -1182,6 +1186,24 @@ EnsureTableNotPartition(Oid relationId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ErrorIfColocateWithTenantTable errors out if given colocateWith text refers to
|
||||||
|
* a tenant table.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ErrorIfColocateWithTenantTable(char *colocateWith)
|
||||||
|
{
|
||||||
|
if (colocateWith != NULL &&
|
||||||
|
!IsColocateWithDefault(colocateWith) &&
|
||||||
|
!IsColocateWithNone(colocateWith))
|
||||||
|
{
|
||||||
|
text *colocateWithTableNameText = cstring_to_text(colocateWith);
|
||||||
|
Oid colocateWithTableId = ResolveRelationId(colocateWithTableNameText, false);
|
||||||
|
ErrorIfTenantTable(colocateWithTableId, "colocate_with");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TableConversionState *
|
TableConversionState *
|
||||||
CreateTableConversion(TableConversionParameters *params)
|
CreateTableConversion(TableConversionParameters *params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,6 +83,12 @@ ERROR: test_table is not allowed for colocate_with because it is a tenant table
|
||||||
-- verify we don't allow undistribute_table for tenant tables
|
-- verify we don't allow undistribute_table for tenant tables
|
||||||
SELECT undistribute_table('tenant_2.test_table');
|
SELECT undistribute_table('tenant_2.test_table');
|
||||||
ERROR: test_table is not allowed for undistribute_table because it is a tenant table
|
ERROR: test_table is not allowed for undistribute_table because it is a tenant table
|
||||||
|
-- verify we don't allow alter_distributed_table for tenant tables
|
||||||
|
SELECT alter_distributed_table('tenant_2.test_table', colocate_with => 'none');
|
||||||
|
ERROR: test_table is not allowed for alter_distributed_table because it is a tenant table
|
||||||
|
-- verify we also don't allow colocate_with a tenant table
|
||||||
|
SELECT alter_distributed_table('regular_schema.test_table', colocate_with => 'tenant_2.test_table');
|
||||||
|
ERROR: test_table is not allowed for colocate_with because it is a tenant table
|
||||||
-- (on coordinator) verify that colocation id is set for empty tenants too
|
-- (on coordinator) verify that colocation id is set for empty tenants too
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
|
|
|
@ -61,6 +61,10 @@ SELECT update_distributed_table_colocation('tenant_2.test_table', colocate_with
|
||||||
SELECT update_distributed_table_colocation('regular_schema.test_table', colocate_with => 'tenant_2.test_table');
|
SELECT update_distributed_table_colocation('regular_schema.test_table', colocate_with => 'tenant_2.test_table');
|
||||||
-- verify we don't allow undistribute_table for tenant tables
|
-- verify we don't allow undistribute_table for tenant tables
|
||||||
SELECT undistribute_table('tenant_2.test_table');
|
SELECT undistribute_table('tenant_2.test_table');
|
||||||
|
-- verify we don't allow alter_distributed_table for tenant tables
|
||||||
|
SELECT alter_distributed_table('tenant_2.test_table', colocate_with => 'none');
|
||||||
|
-- verify we also don't allow colocate_with a tenant table
|
||||||
|
SELECT alter_distributed_table('regular_schema.test_table', colocate_with => 'tenant_2.test_table');
|
||||||
|
|
||||||
-- (on coordinator) verify that colocation id is set for empty tenants too
|
-- (on coordinator) verify that colocation id is set for empty tenants too
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
||||||
|
|
Loading…
Reference in New Issue