mirror of https://github.com/citusdata/citus.git
mat view should not be converted to tenant table (#7043)
We allow materialized view to exist in distrbuted schema but they should not be tried to be converted to a tenant table since they cannot be distributed. Fixes https://github.com/citusdata/citus/issues/7041pull/7013/merge
parent
5051be86ff
commit
719d92c8b9
|
@ -4154,6 +4154,15 @@ ConvertNewTableIfNecessary(Node *createStmt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We allow mat views in a distributed schema but do not make them a tenant
|
||||||
|
* table. We should skip converting them.
|
||||||
|
*/
|
||||||
|
if (get_rel_relkind(createdRelationId) == RELKIND_MATVIEW)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CreateTenantSchemaTable(createdRelationId);
|
CreateTenantSchemaTable(createdRelationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1694,8 +1694,34 @@ $$);
|
||||||
t
|
t
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
-- mat view can be created under tenant schema
|
||||||
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
CREATE SCHEMA sc1;
|
||||||
|
CREATE TABLE sc1.t1 (a int);
|
||||||
|
CREATE MATERIALIZED VIEW sc1.v1 AS SELECT * FROM sc1.t1;
|
||||||
|
SET citus.enable_schema_based_sharding TO OFF;
|
||||||
|
-- on coordinator, verify that schema is distributed
|
||||||
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
|
WHERE schemaid::regnamespace::text = 'sc1';
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- on workers, verify that schema is distributed
|
||||||
|
SELECT result FROM run_command_on_workers($$
|
||||||
|
SELECT array_agg(colocationid > 0) FROM pg_dist_schema
|
||||||
|
WHERE schemaid::regnamespace::text = 'sc1'
|
||||||
|
$$);
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
{t}
|
||||||
|
{t}
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema CASCADE;
|
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1 CASCADE;
|
||||||
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
||||||
SELECT citus_remove_node('localhost', :master_port);
|
SELECT citus_remove_node('localhost', :master_port);
|
||||||
citus_remove_node
|
citus_remove_node
|
||||||
|
|
|
@ -1154,8 +1154,26 @@ SELECT result FROM run_command_on_all_nodes($$
|
||||||
WHERE schemaid::regnamespace::text = 'authschema';
|
WHERE schemaid::regnamespace::text = 'authschema';
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
-- mat view can be created under tenant schema
|
||||||
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
CREATE SCHEMA sc1;
|
||||||
|
CREATE TABLE sc1.t1 (a int);
|
||||||
|
CREATE MATERIALIZED VIEW sc1.v1 AS SELECT * FROM sc1.t1;
|
||||||
|
SET citus.enable_schema_based_sharding TO OFF;
|
||||||
|
|
||||||
|
-- on coordinator, verify that schema is distributed
|
||||||
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
|
WHERE schemaid::regnamespace::text = 'sc1';
|
||||||
|
|
||||||
|
-- on workers, verify that schema is distributed
|
||||||
|
SELECT result FROM run_command_on_workers($$
|
||||||
|
SELECT array_agg(colocationid > 0) FROM pg_dist_schema
|
||||||
|
WHERE schemaid::regnamespace::text = 'sc1'
|
||||||
|
$$);
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema CASCADE;
|
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1 CASCADE;
|
||||||
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
||||||
|
|
||||||
SELECT citus_remove_node('localhost', :master_port);
|
SELECT citus_remove_node('localhost', :master_port);
|
||||||
|
|
Loading…
Reference in New Issue