mirror of https://github.com/citusdata/citus.git
Rename pg_dist tenant_schema to pg_dist_schema (#7001)
parent
ba40eb363c
commit
dbdf04e8ba
|
@ -2846,33 +2846,33 @@ DistColocationConfigurationIndexId(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return oid of pg_dist_tenant_schema relation */
|
/* return oid of pg_dist_schema relation */
|
||||||
Oid
|
Oid
|
||||||
DistTenantSchemaRelationId(void)
|
DistTenantSchemaRelationId(void)
|
||||||
{
|
{
|
||||||
CachedRelationLookup("pg_dist_tenant_schema",
|
CachedRelationLookup("pg_dist_schema",
|
||||||
&MetadataCache.distTenantSchemaRelationId);
|
&MetadataCache.distTenantSchemaRelationId);
|
||||||
|
|
||||||
return MetadataCache.distTenantSchemaRelationId;
|
return MetadataCache.distTenantSchemaRelationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return oid of pg_dist_tenant_schema_pkey index */
|
/* return oid of pg_dist_schema_pkey index */
|
||||||
Oid
|
Oid
|
||||||
DistTenantSchemaPrimaryKeyIndexId(void)
|
DistTenantSchemaPrimaryKeyIndexId(void)
|
||||||
{
|
{
|
||||||
CachedRelationLookup("pg_dist_tenant_schema_pkey",
|
CachedRelationLookup("pg_dist_schema_pkey",
|
||||||
&MetadataCache.distTenantSchemaPrimaryKeyIndexId);
|
&MetadataCache.distTenantSchemaPrimaryKeyIndexId);
|
||||||
|
|
||||||
return MetadataCache.distTenantSchemaPrimaryKeyIndexId;
|
return MetadataCache.distTenantSchemaPrimaryKeyIndexId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return oid of pg_dist_tenant_schema_unique_colocationid_index index */
|
/* return oid of pg_dist_schema_unique_colocationid_index index */
|
||||||
Oid
|
Oid
|
||||||
DistTenantSchemaUniqueColocationIdIndexId(void)
|
DistTenantSchemaUniqueColocationIdIndexId(void)
|
||||||
{
|
{
|
||||||
CachedRelationLookup("pg_dist_tenant_schema_unique_colocationid_index",
|
CachedRelationLookup("pg_dist_schema_unique_colocationid_index",
|
||||||
&MetadataCache.distTenantSchemaUniqueColocationIdIndexId);
|
&MetadataCache.distTenantSchemaUniqueColocationIdIndexId);
|
||||||
|
|
||||||
return MetadataCache.distTenantSchemaUniqueColocationIdIndexId;
|
return MetadataCache.distTenantSchemaUniqueColocationIdIndexId;
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
#include "distributed/pg_dist_colocation.h"
|
#include "distributed/pg_dist_colocation.h"
|
||||||
#include "distributed/pg_dist_node.h"
|
#include "distributed/pg_dist_node.h"
|
||||||
#include "distributed/pg_dist_shard.h"
|
#include "distributed/pg_dist_shard.h"
|
||||||
#include "distributed/pg_dist_tenant_schema.h"
|
#include "distributed/pg_dist_schema.h"
|
||||||
#include "distributed/relation_access_tracking.h"
|
#include "distributed/relation_access_tracking.h"
|
||||||
#include "distributed/remote_commands.h"
|
#include "distributed/remote_commands.h"
|
||||||
#include "distributed/resource_lock.h"
|
#include "distributed/resource_lock.h"
|
||||||
|
@ -4452,7 +4452,7 @@ SyncDistributedObjects(MetadataSyncContext *context)
|
||||||
SendDistObjectCommands(context);
|
SendDistObjectCommands(context);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commands to insert pg_dist_tenant_schema entries.
|
* Commands to insert pg_dist_schema entries.
|
||||||
*
|
*
|
||||||
* Need to be done after syncing distributed objects because the schemas
|
* Need to be done after syncing distributed objects because the schemas
|
||||||
* need to exist on the worker.
|
* need to exist on the worker.
|
||||||
|
@ -4532,7 +4532,7 @@ SendMetadataDeletionCommands(MetadataSyncContext *context)
|
||||||
/* remove pg_dist_colocation entries */
|
/* remove pg_dist_colocation entries */
|
||||||
SendOrCollectCommandListToActivatedNodes(context, list_make1(DELETE_ALL_COLOCATION));
|
SendOrCollectCommandListToActivatedNodes(context, list_make1(DELETE_ALL_COLOCATION));
|
||||||
|
|
||||||
/* remove pg_dist_tenant_schema entries */
|
/* remove pg_dist_schema entries */
|
||||||
SendOrCollectCommandListToActivatedNodes(context,
|
SendOrCollectCommandListToActivatedNodes(context,
|
||||||
list_make1(DELETE_ALL_TENANT_SCHEMAS));
|
list_make1(DELETE_ALL_TENANT_SCHEMAS));
|
||||||
}
|
}
|
||||||
|
@ -4662,8 +4662,8 @@ SendTenantSchemaMetadataCommands(MetadataSyncContext *context)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Form_pg_dist_tenant_schema tenantSchemaForm =
|
Form_pg_dist_schema tenantSchemaForm =
|
||||||
(Form_pg_dist_tenant_schema) GETSTRUCT(heapTuple);
|
(Form_pg_dist_schema) GETSTRUCT(heapTuple);
|
||||||
|
|
||||||
StringInfo insertTenantSchemaCommand = makeStringInfo();
|
StringInfo insertTenantSchemaCommand = makeStringInfo();
|
||||||
appendStringInfo(insertTenantSchemaCommand,
|
appendStringInfo(insertTenantSchemaCommand,
|
||||||
|
|
|
@ -2,25 +2,25 @@
|
||||||
|
|
||||||
-- bump version to 12.0-1
|
-- bump version to 12.0-1
|
||||||
|
|
||||||
CREATE TABLE citus.pg_dist_tenant_schema (
|
CREATE TABLE citus.pg_dist_schema (
|
||||||
schemaid oid NOT NULL,
|
schemaid oid NOT NULL,
|
||||||
colocationid int NOT NULL,
|
colocationid int NOT NULL,
|
||||||
CONSTRAINT pg_dist_tenant_schema_pkey PRIMARY KEY (schemaid),
|
CONSTRAINT pg_dist_schema_pkey PRIMARY KEY (schemaid),
|
||||||
CONSTRAINT pg_dist_tenant_schema_unique_colocationid_index UNIQUE (colocationid)
|
CONSTRAINT pg_dist_schema_unique_colocationid_index UNIQUE (colocationid)
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE citus.pg_dist_tenant_schema SET SCHEMA pg_catalog;
|
ALTER TABLE citus.pg_dist_schema SET SCHEMA pg_catalog;
|
||||||
|
|
||||||
GRANT SELECT ON pg_catalog.pg_dist_tenant_schema TO public;
|
GRANT SELECT ON pg_catalog.pg_dist_schema TO public;
|
||||||
|
|
||||||
-- udfs used to modify pg_dist_tenant_schema on workers, to sync metadata
|
-- udfs used to modify pg_dist_schema on workers, to sync metadata
|
||||||
#include "udfs/citus_internal_add_tenant_schema/12.0-1.sql"
|
#include "udfs/citus_internal_add_tenant_schema/12.0-1.sql"
|
||||||
#include "udfs/citus_internal_delete_tenant_schema/12.0-1.sql"
|
#include "udfs/citus_internal_delete_tenant_schema/12.0-1.sql"
|
||||||
|
|
||||||
#include "udfs/citus_prepare_pg_upgrade/12.0-1.sql"
|
#include "udfs/citus_prepare_pg_upgrade/12.0-1.sql"
|
||||||
#include "udfs/citus_finish_pg_upgrade/12.0-1.sql"
|
#include "udfs/citus_finish_pg_upgrade/12.0-1.sql"
|
||||||
|
|
||||||
-- udfs used to modify pg_dist_tenant_schema globally via drop trigger
|
-- udfs used to modify pg_dist_schema globally via drop trigger
|
||||||
#include "udfs/citus_internal_unregister_tenant_schema_globally/12.0-1.sql"
|
#include "udfs/citus_internal_unregister_tenant_schema_globally/12.0-1.sql"
|
||||||
#include "udfs/citus_drop_trigger/12.0-1.sql"
|
#include "udfs/citus_drop_trigger/12.0-1.sql"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
DO $$
|
DO $$
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Throw an error if user has created any tenant schemas.
|
-- Throw an error if user has created any tenant schemas.
|
||||||
IF EXISTS (SELECT 1 FROM pg_catalog.pg_dist_tenant_schema)
|
IF EXISTS (SELECT 1 FROM pg_catalog.pg_dist_schema)
|
||||||
THEN
|
THEN
|
||||||
RAISE EXCEPTION 'cannot downgrade Citus because there are '
|
RAISE EXCEPTION 'cannot downgrade Citus because there are '
|
||||||
'tenant schemas created.'
|
'tenant schemas created.'
|
||||||
|
@ -54,7 +54,7 @@ DROP FUNCTION pg_catalog.citus_shard_sizes;
|
||||||
#include "../udfs/citus_tables/11.1-1.sql"
|
#include "../udfs/citus_tables/11.1-1.sql"
|
||||||
#include "../udfs/citus_shards/11.1-1.sql"
|
#include "../udfs/citus_shards/11.1-1.sql"
|
||||||
|
|
||||||
DROP TABLE pg_catalog.pg_dist_tenant_schema;
|
DROP TABLE pg_catalog.pg_dist_schema;
|
||||||
|
|
||||||
DROP VIEW pg_catalog.citus_stat_tenants_local;
|
DROP VIEW pg_catalog.citus_stat_tenants_local;
|
||||||
DROP FUNCTION pg_catalog.citus_stat_tenants_local_internal(
|
DROP FUNCTION pg_catalog.citus_stat_tenants_local_internal(
|
||||||
|
|
|
@ -36,13 +36,13 @@ BEGIN
|
||||||
|
|
||||||
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
||||||
LOOP
|
LOOP
|
||||||
-- Remove entries from pg_catalog.pg_dist_tenant_schema for all dropped tenant schemas.
|
-- Remove entries from pg_catalog.pg_dist_schema for all dropped tenant schemas.
|
||||||
-- Also delete the corresponding colocation group from pg_catalog.pg_dist_colocation.
|
-- Also delete the corresponding colocation group from pg_catalog.pg_dist_colocation.
|
||||||
--
|
--
|
||||||
-- Although normally we automatically delete the colocation groups when they become empty,
|
-- Although normally we automatically delete the colocation groups when they become empty,
|
||||||
-- we don't do so for the colocation groups that are created for tenant schemas. For this
|
-- we don't do so for the colocation groups that are created for tenant schemas. For this
|
||||||
-- reason, here we need to delete the colocation group when the tenant schema is dropped.
|
-- reason, here we need to delete the colocation group when the tenant schema is dropped.
|
||||||
IF v_obj.object_type = 'schema' AND EXISTS (SELECT 1 FROM pg_catalog.pg_dist_tenant_schema WHERE schemaid = v_obj.objid)
|
IF v_obj.object_type = 'schema' AND EXISTS (SELECT 1 FROM pg_catalog.pg_dist_schema WHERE schemaid = v_obj.objid)
|
||||||
THEN
|
THEN
|
||||||
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -36,13 +36,13 @@ BEGIN
|
||||||
|
|
||||||
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
||||||
LOOP
|
LOOP
|
||||||
-- Remove entries from pg_catalog.pg_dist_tenant_schema for all dropped tenant schemas.
|
-- Remove entries from pg_catalog.pg_dist_schema for all dropped tenant schemas.
|
||||||
-- Also delete the corresponding colocation group from pg_catalog.pg_dist_colocation.
|
-- Also delete the corresponding colocation group from pg_catalog.pg_dist_colocation.
|
||||||
--
|
--
|
||||||
-- Although normally we automatically delete the colocation groups when they become empty,
|
-- Although normally we automatically delete the colocation groups when they become empty,
|
||||||
-- we don't do so for the colocation groups that are created for tenant schemas. For this
|
-- we don't do so for the colocation groups that are created for tenant schemas. For this
|
||||||
-- reason, here we need to delete the colocation group when the tenant schema is dropped.
|
-- reason, here we need to delete the colocation group when the tenant schema is dropped.
|
||||||
IF v_obj.object_type = 'schema' AND EXISTS (SELECT 1 FROM pg_catalog.pg_dist_tenant_schema WHERE schemaid = v_obj.objid)
|
IF v_obj.object_type = 'schema' AND EXISTS (SELECT 1 FROM pg_catalog.pg_dist_schema WHERE schemaid = v_obj.objid)
|
||||||
THEN
|
THEN
|
||||||
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -63,7 +63,7 @@ BEGIN
|
||||||
INSERT INTO pg_catalog.pg_dist_transaction SELECT * FROM public.pg_dist_transaction;
|
INSERT INTO pg_catalog.pg_dist_transaction SELECT * FROM public.pg_dist_transaction;
|
||||||
INSERT INTO pg_catalog.pg_dist_colocation SELECT * FROM public.pg_dist_colocation;
|
INSERT INTO pg_catalog.pg_dist_colocation SELECT * FROM public.pg_dist_colocation;
|
||||||
INSERT INTO pg_catalog.pg_dist_cleanup SELECT * FROM public.pg_dist_cleanup;
|
INSERT INTO pg_catalog.pg_dist_cleanup SELECT * FROM public.pg_dist_cleanup;
|
||||||
INSERT INTO pg_catalog.pg_dist_tenant_schema SELECT schemaname::regnamespace, colocationid FROM public.pg_dist_tenant_schema;
|
INSERT INTO pg_catalog.pg_dist_schema SELECT schemaname::regnamespace, colocationid FROM public.pg_dist_schema;
|
||||||
-- enterprise catalog tables
|
-- enterprise catalog tables
|
||||||
INSERT INTO pg_catalog.pg_dist_authinfo SELECT * FROM public.pg_dist_authinfo;
|
INSERT INTO pg_catalog.pg_dist_authinfo SELECT * FROM public.pg_dist_authinfo;
|
||||||
INSERT INTO pg_catalog.pg_dist_poolinfo SELECT * FROM public.pg_dist_poolinfo;
|
INSERT INTO pg_catalog.pg_dist_poolinfo SELECT * FROM public.pg_dist_poolinfo;
|
||||||
|
@ -94,7 +94,7 @@ BEGIN
|
||||||
DROP TABLE public.pg_dist_transaction;
|
DROP TABLE public.pg_dist_transaction;
|
||||||
DROP TABLE public.pg_dist_rebalance_strategy;
|
DROP TABLE public.pg_dist_rebalance_strategy;
|
||||||
DROP TABLE public.pg_dist_cleanup;
|
DROP TABLE public.pg_dist_cleanup;
|
||||||
DROP TABLE public.pg_dist_tenant_schema;
|
DROP TABLE public.pg_dist_schema;
|
||||||
--
|
--
|
||||||
-- reset sequences
|
-- reset sequences
|
||||||
--
|
--
|
||||||
|
|
|
@ -63,7 +63,7 @@ BEGIN
|
||||||
INSERT INTO pg_catalog.pg_dist_transaction SELECT * FROM public.pg_dist_transaction;
|
INSERT INTO pg_catalog.pg_dist_transaction SELECT * FROM public.pg_dist_transaction;
|
||||||
INSERT INTO pg_catalog.pg_dist_colocation SELECT * FROM public.pg_dist_colocation;
|
INSERT INTO pg_catalog.pg_dist_colocation SELECT * FROM public.pg_dist_colocation;
|
||||||
INSERT INTO pg_catalog.pg_dist_cleanup SELECT * FROM public.pg_dist_cleanup;
|
INSERT INTO pg_catalog.pg_dist_cleanup SELECT * FROM public.pg_dist_cleanup;
|
||||||
INSERT INTO pg_catalog.pg_dist_tenant_schema SELECT schemaname::regnamespace, colocationid FROM public.pg_dist_tenant_schema;
|
INSERT INTO pg_catalog.pg_dist_schema SELECT schemaname::regnamespace, colocationid FROM public.pg_dist_schema;
|
||||||
-- enterprise catalog tables
|
-- enterprise catalog tables
|
||||||
INSERT INTO pg_catalog.pg_dist_authinfo SELECT * FROM public.pg_dist_authinfo;
|
INSERT INTO pg_catalog.pg_dist_authinfo SELECT * FROM public.pg_dist_authinfo;
|
||||||
INSERT INTO pg_catalog.pg_dist_poolinfo SELECT * FROM public.pg_dist_poolinfo;
|
INSERT INTO pg_catalog.pg_dist_poolinfo SELECT * FROM public.pg_dist_poolinfo;
|
||||||
|
@ -94,7 +94,7 @@ BEGIN
|
||||||
DROP TABLE public.pg_dist_transaction;
|
DROP TABLE public.pg_dist_transaction;
|
||||||
DROP TABLE public.pg_dist_rebalance_strategy;
|
DROP TABLE public.pg_dist_rebalance_strategy;
|
||||||
DROP TABLE public.pg_dist_cleanup;
|
DROP TABLE public.pg_dist_cleanup;
|
||||||
DROP TABLE public.pg_dist_tenant_schema;
|
DROP TABLE public.pg_dist_schema;
|
||||||
--
|
--
|
||||||
-- reset sequences
|
-- reset sequences
|
||||||
--
|
--
|
||||||
|
|
|
@ -5,4 +5,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_tenant_schema(schema_id
|
||||||
AS 'MODULE_PATHNAME';
|
AS 'MODULE_PATHNAME';
|
||||||
|
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_internal_add_tenant_schema(Oid, int) IS
|
COMMENT ON FUNCTION pg_catalog.citus_internal_add_tenant_schema(Oid, int) IS
|
||||||
'insert given tenant schema into pg_dist_tenant_schema with given colocation id';
|
'insert given tenant schema into pg_dist_schema with given colocation id';
|
||||||
|
|
|
@ -5,4 +5,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_tenant_schema(schema_id
|
||||||
AS 'MODULE_PATHNAME';
|
AS 'MODULE_PATHNAME';
|
||||||
|
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_internal_add_tenant_schema(Oid, int) IS
|
COMMENT ON FUNCTION pg_catalog.citus_internal_add_tenant_schema(Oid, int) IS
|
||||||
'insert given tenant schema into pg_dist_tenant_schema with given colocation id';
|
'insert given tenant schema into pg_dist_schema with given colocation id';
|
||||||
|
|
|
@ -5,4 +5,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_tenant_schema(schema
|
||||||
AS 'MODULE_PATHNAME';
|
AS 'MODULE_PATHNAME';
|
||||||
|
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_tenant_schema(Oid) IS
|
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_tenant_schema(Oid) IS
|
||||||
'delete given tenant schema from pg_dist_tenant_schema';
|
'delete given tenant schema from pg_dist_schema';
|
||||||
|
|
|
@ -5,4 +5,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_delete_tenant_schema(schema
|
||||||
AS 'MODULE_PATHNAME';
|
AS 'MODULE_PATHNAME';
|
||||||
|
|
||||||
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_tenant_schema(Oid) IS
|
COMMENT ON FUNCTION pg_catalog.citus_internal_delete_tenant_schema(Oid) IS
|
||||||
'delete given tenant schema from pg_dist_tenant_schema';
|
'delete given tenant schema from pg_dist_schema';
|
||||||
|
|
|
@ -33,7 +33,7 @@ BEGIN
|
||||||
DROP TABLE IF EXISTS public.pg_dist_rebalance_strategy;
|
DROP TABLE IF EXISTS public.pg_dist_rebalance_strategy;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_object;
|
DROP TABLE IF EXISTS public.pg_dist_object;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_cleanup;
|
DROP TABLE IF EXISTS public.pg_dist_cleanup;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_tenant_schema;
|
DROP TABLE IF EXISTS public.pg_dist_schema;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_clock_logical_seq;
|
DROP TABLE IF EXISTS public.pg_dist_clock_logical_seq;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -49,7 +49,7 @@ BEGIN
|
||||||
CREATE TABLE public.pg_dist_colocation AS SELECT * FROM pg_catalog.pg_dist_colocation;
|
CREATE TABLE public.pg_dist_colocation AS SELECT * FROM pg_catalog.pg_dist_colocation;
|
||||||
CREATE TABLE public.pg_dist_cleanup AS SELECT * FROM pg_catalog.pg_dist_cleanup;
|
CREATE TABLE public.pg_dist_cleanup AS SELECT * FROM pg_catalog.pg_dist_cleanup;
|
||||||
-- save names of the tenant schemas instead of their oids because the oids might change after pg upgrade
|
-- save names of the tenant schemas instead of their oids because the oids might change after pg upgrade
|
||||||
CREATE TABLE public.pg_dist_tenant_schema AS SELECT schemaid::regnamespace::text AS schemaname, colocationid FROM pg_catalog.pg_dist_tenant_schema;
|
CREATE TABLE public.pg_dist_schema AS SELECT schemaid::regnamespace::text AS schemaname, colocationid FROM pg_catalog.pg_dist_schema;
|
||||||
-- enterprise catalog tables
|
-- enterprise catalog tables
|
||||||
CREATE TABLE public.pg_dist_authinfo AS SELECT * FROM pg_catalog.pg_dist_authinfo;
|
CREATE TABLE public.pg_dist_authinfo AS SELECT * FROM pg_catalog.pg_dist_authinfo;
|
||||||
CREATE TABLE public.pg_dist_poolinfo AS SELECT * FROM pg_catalog.pg_dist_poolinfo;
|
CREATE TABLE public.pg_dist_poolinfo AS SELECT * FROM pg_catalog.pg_dist_poolinfo;
|
||||||
|
|
|
@ -33,7 +33,7 @@ BEGIN
|
||||||
DROP TABLE IF EXISTS public.pg_dist_rebalance_strategy;
|
DROP TABLE IF EXISTS public.pg_dist_rebalance_strategy;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_object;
|
DROP TABLE IF EXISTS public.pg_dist_object;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_cleanup;
|
DROP TABLE IF EXISTS public.pg_dist_cleanup;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_tenant_schema;
|
DROP TABLE IF EXISTS public.pg_dist_schema;
|
||||||
DROP TABLE IF EXISTS public.pg_dist_clock_logical_seq;
|
DROP TABLE IF EXISTS public.pg_dist_clock_logical_seq;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -49,7 +49,7 @@ BEGIN
|
||||||
CREATE TABLE public.pg_dist_colocation AS SELECT * FROM pg_catalog.pg_dist_colocation;
|
CREATE TABLE public.pg_dist_colocation AS SELECT * FROM pg_catalog.pg_dist_colocation;
|
||||||
CREATE TABLE public.pg_dist_cleanup AS SELECT * FROM pg_catalog.pg_dist_cleanup;
|
CREATE TABLE public.pg_dist_cleanup AS SELECT * FROM pg_catalog.pg_dist_cleanup;
|
||||||
-- save names of the tenant schemas instead of their oids because the oids might change after pg upgrade
|
-- save names of the tenant schemas instead of their oids because the oids might change after pg upgrade
|
||||||
CREATE TABLE public.pg_dist_tenant_schema AS SELECT schemaid::regnamespace::text AS schemaname, colocationid FROM pg_catalog.pg_dist_tenant_schema;
|
CREATE TABLE public.pg_dist_schema AS SELECT schemaid::regnamespace::text AS schemaname, colocationid FROM pg_catalog.pg_dist_schema;
|
||||||
-- enterprise catalog tables
|
-- enterprise catalog tables
|
||||||
CREATE TABLE public.pg_dist_authinfo AS SELECT * FROM pg_catalog.pg_dist_authinfo;
|
CREATE TABLE public.pg_dist_authinfo AS SELECT * FROM pg_catalog.pg_dist_authinfo;
|
||||||
CREATE TABLE public.pg_dist_poolinfo AS SELECT * FROM pg_catalog.pg_dist_poolinfo;
|
CREATE TABLE public.pg_dist_poolinfo AS SELECT * FROM pg_catalog.pg_dist_poolinfo;
|
||||||
|
|
|
@ -3,7 +3,7 @@ SELECT
|
||||||
pg_dist_shard.logicalrelid AS table_name,
|
pg_dist_shard.logicalrelid AS table_name,
|
||||||
pg_dist_shard.shardid,
|
pg_dist_shard.shardid,
|
||||||
shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) as shard_name,
|
shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) as shard_name,
|
||||||
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_tenant_schema) THEN 'schema'
|
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_schema) THEN 'schema'
|
||||||
WHEN partkey IS NOT NULL THEN 'distributed'
|
WHEN partkey IS NOT NULL THEN 'distributed'
|
||||||
WHEN repmodel = 't' THEN 'reference'
|
WHEN repmodel = 't' THEN 'reference'
|
||||||
WHEN colocationid = 0 THEN 'local'
|
WHEN colocationid = 0 THEN 'local'
|
||||||
|
|
|
@ -3,7 +3,7 @@ SELECT
|
||||||
pg_dist_shard.logicalrelid AS table_name,
|
pg_dist_shard.logicalrelid AS table_name,
|
||||||
pg_dist_shard.shardid,
|
pg_dist_shard.shardid,
|
||||||
shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) as shard_name,
|
shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) as shard_name,
|
||||||
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_tenant_schema) THEN 'schema'
|
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_schema) THEN 'schema'
|
||||||
WHEN partkey IS NOT NULL THEN 'distributed'
|
WHEN partkey IS NOT NULL THEN 'distributed'
|
||||||
WHEN repmodel = 't' THEN 'reference'
|
WHEN repmodel = 't' THEN 'reference'
|
||||||
WHEN colocationid = 0 THEN 'local'
|
WHEN colocationid = 0 THEN 'local'
|
||||||
|
|
|
@ -40,7 +40,7 @@ BEGIN
|
||||||
L.cpu_usage_in_last_period,
|
L.cpu_usage_in_last_period,
|
||||||
L.score
|
L.score
|
||||||
FROM pg_catalog.citus_stat_tenants_local_internal(return_all_tenants) L
|
FROM pg_catalog.citus_stat_tenants_local_internal(return_all_tenants) L
|
||||||
LEFT JOIN pg_dist_tenant_schema S ON L.tenant_attribute IS NULL AND L.colocation_id = S.colocationid
|
LEFT JOIN pg_dist_schema S ON L.tenant_attribute IS NULL AND L.colocation_id = S.colocationid
|
||||||
LEFT JOIN pg_namespace N ON N.oid = S.schemaid
|
LEFT JOIN pg_namespace N ON N.oid = S.schemaid
|
||||||
ORDER BY L.score DESC;
|
ORDER BY L.score DESC;
|
||||||
END;
|
END;
|
||||||
|
|
|
@ -40,7 +40,7 @@ BEGIN
|
||||||
L.cpu_usage_in_last_period,
|
L.cpu_usage_in_last_period,
|
||||||
L.score
|
L.score
|
||||||
FROM pg_catalog.citus_stat_tenants_local_internal(return_all_tenants) L
|
FROM pg_catalog.citus_stat_tenants_local_internal(return_all_tenants) L
|
||||||
LEFT JOIN pg_dist_tenant_schema S ON L.tenant_attribute IS NULL AND L.colocation_id = S.colocationid
|
LEFT JOIN pg_dist_schema S ON L.tenant_attribute IS NULL AND L.colocation_id = S.colocationid
|
||||||
LEFT JOIN pg_namespace N ON N.oid = S.schemaid
|
LEFT JOIN pg_namespace N ON N.oid = S.schemaid
|
||||||
ORDER BY L.score DESC;
|
ORDER BY L.score DESC;
|
||||||
END;
|
END;
|
||||||
|
|
|
@ -6,7 +6,7 @@ citus_tables_create_query=$CTCQ$
|
||||||
CREATE OR REPLACE VIEW %I.citus_tables AS
|
CREATE OR REPLACE VIEW %I.citus_tables AS
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid AS table_name,
|
logicalrelid AS table_name,
|
||||||
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_tenant_schema) THEN 'schema'
|
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_schema) THEN 'schema'
|
||||||
WHEN partkey IS NOT NULL THEN 'distributed'
|
WHEN partkey IS NOT NULL THEN 'distributed'
|
||||||
WHEN repmodel = 't' THEN 'reference'
|
WHEN repmodel = 't' THEN 'reference'
|
||||||
WHEN colocationid = 0 THEN 'local'
|
WHEN colocationid = 0 THEN 'local'
|
||||||
|
|
|
@ -6,7 +6,7 @@ citus_tables_create_query=$CTCQ$
|
||||||
CREATE OR REPLACE VIEW %I.citus_tables AS
|
CREATE OR REPLACE VIEW %I.citus_tables AS
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid AS table_name,
|
logicalrelid AS table_name,
|
||||||
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_tenant_schema) THEN 'schema'
|
CASE WHEN colocationid IN (SELECT colocationid FROM pg_dist_schema) THEN 'schema'
|
||||||
WHEN partkey IS NOT NULL THEN 'distributed'
|
WHEN partkey IS NOT NULL THEN 'distributed'
|
||||||
WHEN repmodel = 't' THEN 'reference'
|
WHEN repmodel = 't' THEN 'reference'
|
||||||
WHEN colocationid = 0 THEN 'local'
|
WHEN colocationid = 0 THEN 'local'
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "distributed/colocation_utils.h"
|
#include "distributed/colocation_utils.h"
|
||||||
#include "distributed/metadata_cache.h"
|
#include "distributed/metadata_cache.h"
|
||||||
#include "distributed/metadata_sync.h"
|
#include "distributed/metadata_sync.h"
|
||||||
#include "distributed/pg_dist_tenant_schema.h"
|
#include "distributed/pg_dist_schema.h"
|
||||||
#include "distributed/tenant_schema_metadata.h"
|
#include "distributed/tenant_schema_metadata.h"
|
||||||
#include "storage/lockdefs.h"
|
#include "storage/lockdefs.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
@ -33,7 +33,7 @@ IsTenantSchema(Oid schemaId)
|
||||||
/*
|
/*
|
||||||
* We don't allow creating tenant schemas when there is a version
|
* We don't allow creating tenant schemas when there is a version
|
||||||
* mismatch. Even more, SchemaIdGetTenantColocationId() would throw an
|
* mismatch. Even more, SchemaIdGetTenantColocationId() would throw an
|
||||||
* error if the underlying pg_dist_tenant_schema metadata table has not
|
* error if the underlying pg_dist_schema metadata table has not
|
||||||
* been created yet, which is the case in older versions. For this reason,
|
* been created yet, which is the case in older versions. For this reason,
|
||||||
* it's safe to assume that it cannot be a tenant schema when there is a
|
* it's safe to assume that it cannot be a tenant schema when there is a
|
||||||
* version mismatch.
|
* version mismatch.
|
||||||
|
@ -45,7 +45,7 @@ IsTenantSchema(Oid schemaId)
|
||||||
* fail when deciding whether we should create a tenant table or not.
|
* fail when deciding whether we should create a tenant table or not.
|
||||||
*
|
*
|
||||||
* The downside of doing so is that, for example, we will skip deleting
|
* The downside of doing so is that, for example, we will skip deleting
|
||||||
* the tenant schema entry from pg_dist_tenant_schema when dropping a
|
* the tenant schema entry from pg_dist_schema when dropping a
|
||||||
* tenant schema while the version checks are disabled even if there was
|
* tenant schema while the version checks are disabled even if there was
|
||||||
* no version mismatch. But we're okay with that because we don't expect
|
* no version mismatch. But we're okay with that because we don't expect
|
||||||
* users to disable version checks anyway.
|
* users to disable version checks anyway.
|
||||||
|
@ -89,7 +89,7 @@ SchemaIdGetTenantColocationId(Oid schemaId)
|
||||||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||||
AccessShareLock);
|
AccessShareLock);
|
||||||
ScanKeyData scanKey[1];
|
ScanKeyData scanKey[1];
|
||||||
ScanKeyInit(&scanKey[0], Anum_pg_dist_tenant_schema_schemaid, BTEqualStrategyNumber,
|
ScanKeyInit(&scanKey[0], Anum_pg_dist_schema_schemaid, BTEqualStrategyNumber,
|
||||||
F_OIDEQ, ObjectIdGetDatum(schemaId));
|
F_OIDEQ, ObjectIdGetDatum(schemaId));
|
||||||
|
|
||||||
bool indexOk = true;
|
bool indexOk = true;
|
||||||
|
@ -103,7 +103,7 @@ SchemaIdGetTenantColocationId(Oid schemaId)
|
||||||
bool isNull = false;
|
bool isNull = false;
|
||||||
colocationId = DatumGetUInt32(
|
colocationId = DatumGetUInt32(
|
||||||
heap_getattr(heapTuple,
|
heap_getattr(heapTuple,
|
||||||
Anum_pg_dist_tenant_schema_colocationid,
|
Anum_pg_dist_schema_colocationid,
|
||||||
RelationGetDescr(pgDistTenantSchema),
|
RelationGetDescr(pgDistTenantSchema),
|
||||||
&isNull));
|
&isNull));
|
||||||
Assert(!isNull);
|
Assert(!isNull);
|
||||||
|
@ -133,7 +133,7 @@ ColocationIdGetTenantSchemaId(uint32 colocationId)
|
||||||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||||
AccessShareLock);
|
AccessShareLock);
|
||||||
ScanKeyData scanKey[1];
|
ScanKeyData scanKey[1];
|
||||||
ScanKeyInit(&scanKey[0], Anum_pg_dist_tenant_schema_colocationid,
|
ScanKeyInit(&scanKey[0], Anum_pg_dist_schema_colocationid,
|
||||||
BTEqualStrategyNumber, F_INT4EQ, UInt32GetDatum(colocationId));
|
BTEqualStrategyNumber, F_INT4EQ, UInt32GetDatum(colocationId));
|
||||||
|
|
||||||
bool indexOk = true;
|
bool indexOk = true;
|
||||||
|
@ -146,7 +146,7 @@ ColocationIdGetTenantSchemaId(uint32 colocationId)
|
||||||
if (HeapTupleIsValid(heapTuple))
|
if (HeapTupleIsValid(heapTuple))
|
||||||
{
|
{
|
||||||
bool isNull = false;
|
bool isNull = false;
|
||||||
schemaId = heap_getattr(heapTuple, Anum_pg_dist_tenant_schema_schemaid,
|
schemaId = heap_getattr(heapTuple, Anum_pg_dist_schema_schemaid,
|
||||||
RelationGetDescr(pgDistTenantSchema), &isNull);
|
RelationGetDescr(pgDistTenantSchema), &isNull);
|
||||||
Assert(!isNull);
|
Assert(!isNull);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ ColocationIdGetTenantSchemaId(uint32 colocationId)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InsertTenantSchemaLocally inserts an entry into pg_dist_tenant_schema
|
* InsertTenantSchemaLocally inserts an entry into pg_dist_schema
|
||||||
* with given schemaId and colocationId.
|
* with given schemaId and colocationId.
|
||||||
*
|
*
|
||||||
* Throws a constraint violation error if there is already an entry with
|
* Throws a constraint violation error if there is already an entry with
|
||||||
|
@ -179,11 +179,11 @@ InsertTenantSchemaLocally(Oid schemaId, uint32 colocationId)
|
||||||
ereport(ERROR, (errmsg("colocation id is invalid")));
|
ereport(ERROR, (errmsg("colocation id is invalid")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum values[Natts_pg_dist_tenant_schema] = { 0 };
|
Datum values[Natts_pg_dist_schema] = { 0 };
|
||||||
bool isNulls[Natts_pg_dist_tenant_schema] = { 0 };
|
bool isNulls[Natts_pg_dist_schema] = { 0 };
|
||||||
|
|
||||||
values[Anum_pg_dist_tenant_schema_schemaid - 1] = ObjectIdGetDatum(schemaId);
|
values[Anum_pg_dist_schema_schemaid - 1] = ObjectIdGetDatum(schemaId);
|
||||||
values[Anum_pg_dist_tenant_schema_colocationid - 1] = UInt32GetDatum(colocationId);
|
values[Anum_pg_dist_schema_colocationid - 1] = UInt32GetDatum(colocationId);
|
||||||
|
|
||||||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||||
RowExclusiveLock);
|
RowExclusiveLock);
|
||||||
|
@ -199,7 +199,7 @@ InsertTenantSchemaLocally(Oid schemaId, uint32 colocationId)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DeleteTenantSchemaLocally deletes the entry for given schemaId from
|
* DeleteTenantSchemaLocally deletes the entry for given schemaId from
|
||||||
* pg_dist_tenant_schema.
|
* pg_dist_schema.
|
||||||
*
|
*
|
||||||
* Throws an error if there is no such tenant schema.
|
* Throws an error if there is no such tenant schema.
|
||||||
*/
|
*/
|
||||||
|
@ -214,7 +214,7 @@ DeleteTenantSchemaLocally(Oid schemaId)
|
||||||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||||
RowExclusiveLock);
|
RowExclusiveLock);
|
||||||
ScanKeyData scanKey[1];
|
ScanKeyData scanKey[1];
|
||||||
ScanKeyInit(&scanKey[0], Anum_pg_dist_tenant_schema_schemaid, BTEqualStrategyNumber,
|
ScanKeyInit(&scanKey[0], Anum_pg_dist_schema_schemaid, BTEqualStrategyNumber,
|
||||||
F_OIDEQ, ObjectIdGetDatum(schemaId));
|
F_OIDEQ, ObjectIdGetDatum(schemaId));
|
||||||
|
|
||||||
bool indexOk = true;
|
bool indexOk = true;
|
||||||
|
|
|
@ -177,7 +177,7 @@ extern void SendInterTableRelationshipCommands(MetadataSyncContext *context);
|
||||||
#define DELETE_ALL_DISTRIBUTED_OBJECTS "DELETE FROM pg_catalog.pg_dist_object"
|
#define DELETE_ALL_DISTRIBUTED_OBJECTS "DELETE FROM pg_catalog.pg_dist_object"
|
||||||
#define DELETE_ALL_PARTITIONS "DELETE FROM pg_dist_partition"
|
#define DELETE_ALL_PARTITIONS "DELETE FROM pg_dist_partition"
|
||||||
#define DELETE_ALL_COLOCATION "DELETE FROM pg_catalog.pg_dist_colocation"
|
#define DELETE_ALL_COLOCATION "DELETE FROM pg_catalog.pg_dist_colocation"
|
||||||
#define DELETE_ALL_TENANT_SCHEMAS "DELETE FROM pg_catalog.pg_dist_tenant_schema"
|
#define DELETE_ALL_TENANT_SCHEMAS "DELETE FROM pg_catalog.pg_dist_schema"
|
||||||
#define WORKER_DROP_ALL_SHELL_TABLES \
|
#define WORKER_DROP_ALL_SHELL_TABLES \
|
||||||
"CALL pg_catalog.worker_drop_all_shell_tables(%s)"
|
"CALL pg_catalog.worker_drop_all_shell_tables(%s)"
|
||||||
#define CITUS_INTERNAL_MARK_NODE_NOT_SYNCED \
|
#define CITUS_INTERNAL_MARK_NODE_NOT_SYNCED \
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* pg_dist_schema.h
|
||||||
|
* definition of the system catalog for the schemas used for schema-based
|
||||||
|
* sharding in Citus.
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PG_DIST_SCHEMA_H
|
||||||
|
#define PG_DIST_SCHEMA_H
|
||||||
|
|
||||||
|
#include "postgres.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* pg_dist_schema definition.
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
typedef struct FormData_pg_dist_schema
|
||||||
|
{
|
||||||
|
Oid schemaid;
|
||||||
|
uint32 colocationid;
|
||||||
|
} FormData_pg_dist_schema;
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* Form_pg_dist_schema corresponds to a pointer to a tuple with
|
||||||
|
* the format of pg_dist_schema relation.
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
typedef FormData_pg_dist_schema *Form_pg_dist_schema;
|
||||||
|
|
||||||
|
/* ----------------
|
||||||
|
* compiler constants for pg_dist_schema
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
#define Natts_pg_dist_schema 2
|
||||||
|
#define Anum_pg_dist_schema_schemaid 1
|
||||||
|
#define Anum_pg_dist_schema_colocationid 2
|
||||||
|
|
||||||
|
#endif /* PG_DIST_SCHEMA_H */
|
|
@ -1,41 +0,0 @@
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* pg_dist_tenant_schema.h
|
|
||||||
* definition of the system catalog for the schemas used for schema-based
|
|
||||||
* sharding in Citus.
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PG_DIST_TENANT_SCHEMA_H
|
|
||||||
#define PG_DIST_TENANT_SCHEMA_H
|
|
||||||
|
|
||||||
#include "postgres.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* pg_dist_tenant_schema definition.
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
typedef struct FormData_pg_dist_tenant_schema
|
|
||||||
{
|
|
||||||
Oid schemaid;
|
|
||||||
uint32 colocationid;
|
|
||||||
} FormData_pg_dist_tenant_schema;
|
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* Form_pg_dist_tenant_schema corresponds to a pointer to a tuple with
|
|
||||||
* the format of pg_dist_tenant_schema relation.
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
typedef FormData_pg_dist_tenant_schema *Form_pg_dist_tenant_schema;
|
|
||||||
|
|
||||||
/* ----------------
|
|
||||||
* compiler constants for pg_dist_tenant_schema
|
|
||||||
* ----------------
|
|
||||||
*/
|
|
||||||
#define Natts_pg_dist_tenant_schema 2
|
|
||||||
#define Anum_pg_dist_tenant_schema_schemaid 1
|
|
||||||
#define Anum_pg_dist_tenant_schema_colocationid 2
|
|
||||||
|
|
||||||
#endif /* PG_DIST_TENANT_SCHEMA_H */
|
|
|
@ -309,11 +309,11 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
-- below query verifies the same colocationid in pg_dist_tenant_schema, pg_dist_colocation and all entries in pg_dist_partition at the same time
|
-- below query verifies the same colocationid in pg_dist_schema, pg_dist_colocation and all entries in pg_dist_partition at the same time
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -340,7 +340,7 @@ SELECT citus_schema_undistribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -384,10 +384,10 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -414,7 +414,7 @@ SELECT citus_schema_undistribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -576,10 +576,10 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -617,7 +617,7 @@ SELECT citus_schema_undistribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -703,10 +703,10 @@ SELECT citus_schema_distribute('"CiTuS.TeeN"');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''"CiTuS.TeeN"%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''"CiTuS.TeeN"%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -733,7 +733,7 @@ SELECT citus_schema_undistribute('"CiTuS.TeeN"');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -811,10 +811,10 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -841,7 +841,7 @@ SELECT citus_schema_undistribute('tenant1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -874,8 +874,8 @@ SELECT citus_schema_distribute('empty_tenant');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace FROM pg_dist_colocation JOIN pg_dist_tenant_schema USING(colocationid) $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace FROM pg_dist_colocation JOIN pg_dist_schema USING(colocationid) $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
empty_tenant
|
empty_tenant
|
||||||
|
@ -890,7 +890,7 @@ SELECT citus_schema_undistribute('empty_tenant');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
result
|
result
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-schema: <... completed>
|
step s2-drop-schema: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -70,7 +70,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-schema: <... completed>
|
step s2-drop-schema: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -106,7 +106,7 @@ step s1-commit:
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -153,7 +153,7 @@ step s1-commit:
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -191,7 +191,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-add-table: <... completed>
|
step s2-add-table: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -240,7 +240,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-add-table: <... completed>
|
step s2-add-table: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -278,7 +278,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-table: <... completed>
|
step s2-drop-table: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -325,7 +325,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-table: <... completed>
|
step s2-drop-table: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -362,7 +362,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-alter-col-type: <... completed>
|
step s2-alter-col-type: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -410,7 +410,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-alter-col-type: <... completed>
|
step s2-alter-col-type: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -448,7 +448,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-add-foreign-key: <... completed>
|
step s2-add-foreign-key: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -496,7 +496,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-add-foreign-key: <... completed>
|
step s2-add-foreign-key: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -535,7 +535,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-foreign-key: <... completed>
|
step s2-drop-foreign-key: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -583,7 +583,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-drop-foreign-key: <... completed>
|
step s2-drop-foreign-key: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid|partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -620,7 +620,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-create-unique-index: <... completed>
|
step s2-create-unique-index: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -668,7 +668,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-create-unique-index: <... completed>
|
step s2-create-unique-index: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -706,7 +706,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-create-unique-index-concurrently: <... completed>
|
step s2-create-unique-index-concurrently: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -754,7 +754,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-create-unique-index-concurrently: <... completed>
|
step s2-create-unique-index-concurrently: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -795,7 +795,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-reindex-unique-concurrently: <... completed>
|
step s2-reindex-unique-concurrently: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -846,7 +846,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-reindex-unique-concurrently: <... completed>
|
step s2-reindex-unique-concurrently: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -885,7 +885,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-insert: <... completed>
|
step s2-insert: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -934,7 +934,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-insert: <... completed>
|
step s2-insert: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -976,7 +976,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-update: <... completed>
|
step s2-update: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1028,7 +1028,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-update: <... completed>
|
step s2-update: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1070,7 +1070,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-delete: <... completed>
|
step s2-delete: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1122,7 +1122,7 @@ step s1-commit:
|
||||||
|
|
||||||
step s2-delete: <... completed>
|
step s2-delete: <... completed>
|
||||||
step s1-verify-distributed-schema:
|
step s1-verify-distributed-schema:
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
|
|
||||||
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
logicalrelid |partmethod|partkey|is_correct_colocid|repmodel|autoconverted
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ SELECT * FROM multi_extension.print_extension_changes();
|
||||||
| function citus_schema_distribute(regnamespace) void
|
| function citus_schema_distribute(regnamespace) void
|
||||||
| function citus_schema_undistribute(regnamespace) void
|
| function citus_schema_undistribute(regnamespace) void
|
||||||
| function citus_stat_tenants_local_internal(boolean) SETOF record
|
| function citus_stat_tenants_local_internal(boolean) SETOF record
|
||||||
| table pg_dist_tenant_schema
|
| table pg_dist_schema
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
||||||
|
@ -1791,7 +1791,7 @@ CREATE TABLE tenant_schema.test(x int, y int);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_schema.test'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_schema.test'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_schema';
|
WHERE schemaid::regnamespace::text = 'tenant_schema';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1861,7 +1861,7 @@ DROP TABLE test;
|
||||||
DROP EXTENSION citus_columnar;
|
DROP EXTENSION citus_columnar;
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE EXTENSION citus_columnar;
|
CREATE EXTENSION citus_columnar;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN ('columnar'::regnamespace, 'columnar_internal'::regnamespace);
|
WHERE schemaid IN ('columnar'::regnamespace, 'columnar_internal'::regnamespace);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -76,7 +76,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION pg_database_owner
|
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION pg_database_owner
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -147,7 +147,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.single_shard_tbl (a integer) USING heap
|
CREATE TABLE public.single_shard_tbl (a integer) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -216,7 +216,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -277,7 +277,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -345,7 +345,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -406,7 +406,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -1977,7 +1977,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.test_table (id integer DEFAULT worker_nextval('public.mx_test_sequence_0'::regclass), id2 integer DEFAULT worker_nextval('public.mx_test_sequence_1'::regclass)) USING heap
|
CREATE TABLE public.test_table (id integer DEFAULT worker_nextval('public.mx_test_sequence_0'::regclass), id2 integer DEFAULT worker_nextval('public.mx_test_sequence_1'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
|
|
@ -76,7 +76,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION postgres
|
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION postgres
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -147,7 +147,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.single_shard_tbl (a integer) USING heap
|
CREATE TABLE public.single_shard_tbl (a integer) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -216,7 +216,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -277,7 +277,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -345,7 +345,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -406,7 +406,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL, col_4 bigint DEFAULT nextval('public.user_defined_seq'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
@ -1977,7 +1977,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
||||||
CREATE TABLE public.test_table (id integer DEFAULT worker_nextval('public.mx_test_sequence_0'::regclass), id2 integer DEFAULT worker_nextval('public.mx_test_sequence_1'::regclass)) USING heap
|
CREATE TABLE public.test_table (id integer DEFAULT worker_nextval('public.mx_test_sequence_0'::regclass), id2 integer DEFAULT worker_nextval('public.mx_test_sequence_1'::regclass)) USING heap
|
||||||
DELETE FROM pg_catalog.pg_dist_colocation
|
DELETE FROM pg_catalog.pg_dist_colocation
|
||||||
DELETE FROM pg_catalog.pg_dist_object
|
DELETE FROM pg_catalog.pg_dist_object
|
||||||
DELETE FROM pg_catalog.pg_dist_tenant_schema
|
DELETE FROM pg_catalog.pg_dist_schema
|
||||||
DELETE FROM pg_dist_node
|
DELETE FROM pg_dist_node
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
DELETE FROM pg_dist_placement
|
DELETE FROM pg_dist_placement
|
||||||
|
|
|
@ -41,8 +41,8 @@ SELECT create_distributed_table('regular_schema.test_table', 'a');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
-- show that regular_schema doesn't show up in pg_dist_tenant_schema
|
-- show that regular_schema doesn't show up in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -99,7 +99,7 @@ ERROR: tenant_2 is not allowed for ALTER TABLE SET SCHEMA because it is a distr
|
||||||
ALTER TABLE tenant_2.test_table SET SCHEMA tenant_3;
|
ALTER TABLE tenant_2.test_table SET SCHEMA tenant_3;
|
||||||
ERROR: tenant_2.test_table is not allowed for ALTER TABLE SET SCHEMA because it belongs to a distributed schema
|
ERROR: tenant_2.test_table is not allowed for ALTER TABLE SET SCHEMA because it belongs to a distributed schema
|
||||||
-- (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_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -109,7 +109,7 @@ WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
|
|
||||||
-- (on workers) verify that colocation id is set for empty tenants too
|
-- (on workers) verify that colocation id is set for empty tenants too
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT array_agg(colocationid > 0) FROM pg_dist_tenant_schema
|
SELECT array_agg(colocationid > 0) FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -132,7 +132,7 @@ WHERE logicalrelid = 'tenant_2.test_table'::regclass AND
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -144,7 +144,7 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -159,7 +159,7 @@ CREATE TABLE tenant_1.test_table(a int, b text);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -171,7 +171,7 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -181,7 +181,7 @@ $$);
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- verify that tenant_1 and tenant_2 have different colocation ids
|
-- verify that tenant_1 and tenant_2 have different colocation ids
|
||||||
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_tenant_schema
|
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_2');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_2');
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -465,7 +465,7 @@ SELECT COUNT(*) = 5
|
||||||
FROM pg_dist_partition
|
FROM pg_dist_partition
|
||||||
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
||||||
partmethod = 'n' AND repmodel = 's' AND colocationid = (
|
partmethod = 'n' AND repmodel = 's' AND colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5'
|
WHERE schemaid::regnamespace::text = 'tenant_5'
|
||||||
);
|
);
|
||||||
?column?
|
?column?
|
||||||
|
@ -499,10 +499,10 @@ ERROR: tenant tables cannot inherit or be inherited
|
||||||
CREATE TABLE tenant_5.tbl_2(a int, b text);
|
CREATE TABLE tenant_5.tbl_2(a int, b text);
|
||||||
CREATE SCHEMA "CiTuS.TeeN_108";
|
CREATE SCHEMA "CiTuS.TeeN_108";
|
||||||
ALTER SCHEMA "CiTuS.TeeN_108" RENAME TO citus_teen_proper;
|
ALTER SCHEMA "CiTuS.TeeN_108" RENAME TO citus_teen_proper;
|
||||||
SELECT schemaid AS citus_teen_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
SELECT schemaid AS citus_teen_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||||
SELECT colocationid AS citus_teen_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
SELECT colocationid AS citus_teen_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO citus_teen_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO citus_teen_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'citus_teen_proper'
|
WHERE schemaid::regnamespace::text = 'citus_teen_proper'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -521,7 +521,7 @@ SELECT :citus_teen_colocationid > 0;
|
||||||
-- (on workers) verify that the same colocation id is used on workers too
|
-- (on workers) verify that the same colocation id is used on workers too
|
||||||
SELECT format(
|
SELECT format(
|
||||||
'SELECT result FROM run_command_on_workers($$
|
'SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=1 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = ''citus_teen_proper'' AND
|
WHERE schemaid::regnamespace::text = ''citus_teen_proper'' AND
|
||||||
colocationid = %s;
|
colocationid = %s;
|
||||||
$$);',
|
$$);',
|
||||||
|
@ -571,10 +571,10 @@ WHERE logicalrelid::regclass::text LIKE 'tenant_5.%';
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT schemaid AS tenant_4_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
SELECT schemaid AS tenant_4_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||||
SELECT colocationid AS tenant_4_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
SELECT colocationid AS tenant_4_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_4_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_4_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_4'
|
WHERE schemaid::regnamespace::text = 'tenant_4'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -585,14 +585,14 @@ $$);
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
-- Rename it to a name that contains a single quote to verify that we properly
|
-- Rename it to a name that contains a single quote to verify that we properly
|
||||||
-- escape its name when sending the command to delete the pg_dist_tenant_schema
|
-- escape its name when sending the command to delete the pg_dist_schema
|
||||||
-- entry on workers.
|
-- entry on workers.
|
||||||
ALTER SCHEMA tenant_4 RENAME TO "tenant\'_4";
|
ALTER SCHEMA tenant_4 RENAME TO "tenant\'_4";
|
||||||
DROP SCHEMA "tenant\'_4", "CiTuS.TeeN_108" CASCADE;
|
DROP SCHEMA "tenant\'_4", "CiTuS.TeeN_108" CASCADE;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
||||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_4_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_4_schemaid;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -604,7 +604,7 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_4_colocat
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :citus_teen_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :citus_teen_schemaid;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -617,9 +617,9 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :citus_teen_coloc
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema deletes the associated
|
-- (on workers) Verify that dropping a tenant schema deletes the associated
|
||||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -629,7 +629,7 @@ $$);
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM citus_teen_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM citus_teen_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -698,7 +698,7 @@ SELECT create_distributed_table('regular_schema.null_shard_key_table_2', null);
|
||||||
|
|
||||||
-- Show that we don't chose to colocate regular single-shard tables with
|
-- Show that we don't chose to colocate regular single-shard tables with
|
||||||
-- tenant tables by default.
|
-- tenant tables by default.
|
||||||
SELECT * FROM pg_dist_tenant_schema WHERE colocationid = (
|
SELECT * FROM pg_dist_schema WHERE colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'regular_schema.null_shard_key_table_2'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'regular_schema.null_shard_key_table_2'::regclass
|
||||||
);
|
);
|
||||||
schemaid | colocationid
|
schemaid | colocationid
|
||||||
|
@ -706,13 +706,13 @@ SELECT * FROM pg_dist_tenant_schema WHERE colocationid = (
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- save the colocation id used for tenant_5
|
-- save the colocation id used for tenant_5
|
||||||
SELECT colocationid AS tenant_5_old_colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid AS tenant_5_old_colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5' \gset
|
WHERE schemaid::regnamespace::text = 'tenant_5' \gset
|
||||||
-- drop all the tables that belong to tenant_5 and create a new one
|
-- drop all the tables that belong to tenant_5 and create a new one
|
||||||
DROP TABLE tenant_5.tbl_1, tenant_5.tbl_2, tenant_5.tbl_3;
|
DROP TABLE tenant_5.tbl_1, tenant_5.tbl_2, tenant_5.tbl_3;
|
||||||
CREATE TABLE tenant_5.tbl_4(a int, b text);
|
CREATE TABLE tenant_5.tbl_4(a int, b text);
|
||||||
-- (on coordinator) verify that tenant_5 is still associated with the same colocation id
|
-- (on coordinator) verify that tenant_5 is still associated with the same colocation id
|
||||||
SELECT colocationid = :tenant_5_old_colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid = :tenant_5_old_colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5';
|
WHERE schemaid::regnamespace::text = 'tenant_5';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -722,7 +722,7 @@ WHERE schemaid::regnamespace::text = 'tenant_5';
|
||||||
-- (on workers) verify that tenant_5 is still associated with the same colocation id
|
-- (on workers) verify that tenant_5 is still associated with the same colocation id
|
||||||
SELECT format(
|
SELECT format(
|
||||||
'SELECT result FROM run_command_on_workers($$
|
'SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = %s FROM pg_dist_tenant_schema
|
SELECT colocationid = %s FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = ''tenant_5'';
|
WHERE schemaid::regnamespace::text = ''tenant_5'';
|
||||||
$$);',
|
$$);',
|
||||||
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
||||||
|
@ -733,12 +733,12 @@ SELECT format(
|
||||||
t
|
t
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
||||||
SELECT colocationid AS tenant_1_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
SELECT colocationid AS tenant_1_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
||||||
SELECT schemaid AS tenant_2_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
SELECT schemaid AS tenant_2_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||||
SELECT colocationid AS tenant_2_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
SELECT colocationid AS tenant_2_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_1_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_1_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1'
|
WHERE schemaid::regnamespace::text = 'tenant_1'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -748,7 +748,7 @@ $$);
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_2_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_2_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2'
|
WHERE schemaid::regnamespace::text = 'tenant_2'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -788,9 +788,9 @@ DROP OWNED BY test_non_super_user CASCADE;
|
||||||
DROP ROLE test_non_super_user;
|
DROP ROLE test_non_super_user;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
-- (on coordinator) Verify that dropping a tenant schema always deletes
|
-- (on coordinator) Verify that dropping a tenant schema always deletes
|
||||||
-- the associated pg_dist_tenant_schema entry even if the the schema was
|
-- the associated pg_dist_schema entry even if the the schema was
|
||||||
-- dropped while the GUC was set to off.
|
-- dropped while the GUC was set to off.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_1_schemaid, :tenant_2_schemaid);
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IN (:tenant_1_schemaid, :tenant_2_schemaid);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -803,10 +803,10 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_1_coloc
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema always deletes
|
-- (on workers) Verify that dropping a tenant schema always deletes
|
||||||
-- the associated pg_dist_tenant_schema entry even if the the schema was
|
-- the associated pg_dist_schema entry even if the the schema was
|
||||||
-- dropped while the GUC was set to off.
|
-- dropped while the GUC was set to off.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_1_schemaid UNION SELECT schemaid FROM tenant_2_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_1_schemaid UNION SELECT schemaid FROM tenant_2_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -847,29 +847,29 @@ $$);
|
||||||
|
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
-- show that all schemaid values are unique and non-null in pg_dist_tenant_schema
|
-- show that all schemaid values are unique and non-null in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IS NULL;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IS NULL;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_tenant_schema);
|
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_schema);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- show that all colocationid values are unique and non-null in pg_dist_tenant_schema
|
-- show that all colocationid values are unique and non-null in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE colocationid IS NULL;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE colocationid IS NULL;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_tenant_schema);
|
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_schema);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -877,7 +877,7 @@ SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
||||||
|
|
||||||
CREATE TABLE public.cannot_be_a_tenant_table(a int, b text);
|
CREATE TABLE public.cannot_be_a_tenant_table(a int, b text);
|
||||||
-- show that we don't consider public schema as a tenant schema
|
-- show that we don't consider public schema as a tenant schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'public';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'public';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -889,7 +889,7 @@ BEGIN;
|
||||||
CREATE SCHEMA public;
|
CREATE SCHEMA public;
|
||||||
-- Show that we don't consider public schema as a tenant schema,
|
-- Show that we don't consider public schema as a tenant schema,
|
||||||
-- even if it's recreated.
|
-- even if it's recreated.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'public';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'public';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -898,7 +898,7 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
||||||
-- show that we don't consider temporary schemas as tenant schemas
|
-- show that we don't consider temporary schemas as tenant schemas
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = '%pg_temp%';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = '%pg_temp%';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -913,7 +913,7 @@ BEGIN;
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_7.tbl_1'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_7.tbl_1'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_7';
|
WHERE schemaid::regnamespace::text = 'tenant_7';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -936,7 +936,7 @@ BEGIN;
|
||||||
CREATE TABLE tenant_8.tbl_1(a int, b text);
|
CREATE TABLE tenant_8.tbl_1(a int, b text);
|
||||||
CREATE TABLE tenant_8.tbl_2(a int, b text);
|
CREATE TABLE tenant_8.tbl_2(a int, b text);
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_8';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_8';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -1003,10 +1003,10 @@ CREATE TABLE tenant_5.tbl_5(a int, b text, FOREIGN KEY(a) REFERENCES tenant_7.tb
|
||||||
ERROR: cannot create foreign key constraint since relations are not colocated or not referencing a reference table
|
ERROR: cannot create foreign key constraint since relations are not colocated or not referencing a reference table
|
||||||
DETAIL: A distributed table can only have foreign keys if it is referencing another colocated hash distributed table or a reference table
|
DETAIL: A distributed table can only have foreign keys if it is referencing another colocated hash distributed table or a reference table
|
||||||
CREATE SCHEMA tenant_9;
|
CREATE SCHEMA tenant_9;
|
||||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_9'
|
WHERE schemaid::regnamespace::text = 'tenant_9'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1017,9 +1017,9 @@ $$);
|
||||||
|
|
||||||
DROP SCHEMA tenant_9;
|
DROP SCHEMA tenant_9;
|
||||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||||
-- doesn't leave any dangling entries in pg_dist_tenant_schema and
|
-- doesn't leave any dangling entries in pg_dist_schema and
|
||||||
-- pg_dist_colocation.
|
-- pg_dist_colocation.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -1032,10 +1032,10 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocat
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- (on workers) Make sure that dropping an empty tenant schema
|
-- (on workers) Make sure that dropping an empty tenant schema
|
||||||
-- doesn't leave any dangling entries in pg_dist_tenant_schema and
|
-- doesn't leave any dangling entries in pg_dist_schema and
|
||||||
-- pg_dist_colocation.
|
-- pg_dist_colocation.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1147,10 +1147,10 @@ SET citus.shard_count TO 32;
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_9'
|
WHERE schemaid::regnamespace::text = 'tenant_9'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1162,8 +1162,8 @@ $$);
|
||||||
DROP OWNED BY test_other_super_user;
|
DROP OWNED BY test_other_super_user;
|
||||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
-- pg_dist_schema and pg_dist_colocation.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -1177,9 +1177,9 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocat
|
||||||
|
|
||||||
-- (on workers) Make sure that dropping an empty tenant schema
|
-- (on workers) Make sure that dropping an empty tenant schema
|
||||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
-- pg_dist_schema and pg_dist_colocation.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1234,12 +1234,12 @@ CREATE TABLE tenant_10.tbl_1(a int, b text);
|
||||||
CREATE TABLE tenant_10.tbl_2(a int, b text);
|
CREATE TABLE tenant_10.tbl_2(a int, b text);
|
||||||
DROP TABLE tenant_10.tbl_2;
|
DROP TABLE tenant_10.tbl_2;
|
||||||
CREATE SCHEMA tenant_11;
|
CREATE SCHEMA tenant_11;
|
||||||
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
||||||
SELECT colocationid AS tenant_10_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
SELECT colocationid AS tenant_10_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
||||||
SELECT schemaid AS tenant_11_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
SELECT schemaid AS tenant_11_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||||
SELECT colocationid AS tenant_11_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
SELECT colocationid AS tenant_11_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_10_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_10_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_10'
|
WHERE schemaid::regnamespace::text = 'tenant_10'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1249,7 +1249,7 @@ $$);
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_11_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_11_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_11'
|
WHERE schemaid::regnamespace::text = 'tenant_11'
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1259,7 +1259,7 @@ $$);
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- (on coordinator) Verify metadata for tenant schemas that are created via non-super-user.
|
-- (on coordinator) Verify metadata for tenant schemas that are created via non-super-user.
|
||||||
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -1273,7 +1273,7 @@ SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_colocation WHERE colocationi
|
||||||
|
|
||||||
-- (on workers) Verify metadata for tenant schemas that are created via non-super-user.
|
-- (on workers) Verify metadata for tenant schemas that are created via non-super-user.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_tenant_schema
|
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -1298,8 +1298,8 @@ SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA tenant_10, tenant_11 CASCADE;
|
DROP SCHEMA tenant_10, tenant_11 CASCADE;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
||||||
-- deletes the associated pg_dist_tenant_schema entry.
|
-- deletes the associated pg_dist_schema entry.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
@ -1312,9 +1312,9 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colo
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema via non-super-user
|
-- (on workers) Verify that dropping a tenant schema via non-super-user
|
||||||
-- deletes the associated pg_dist_tenant_schema entry.
|
-- deletes the associated pg_dist_schema entry.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
|
|
@ -160,8 +160,8 @@ ERROR: relation "single_node_nullkey_c1_90630532" is a shard relation
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE SCHEMA tenant_1;
|
CREATE SCHEMA tenant_1;
|
||||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
|
|
@ -160,8 +160,8 @@ ERROR: relation "single_node_nullkey_c1_90630532" is a shard relation
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE SCHEMA tenant_1;
|
CREATE SCHEMA tenant_1;
|
||||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
|
|
@ -311,8 +311,8 @@ ORDER BY 1;
|
||||||
table pg_dist_placement
|
table pg_dist_placement
|
||||||
table pg_dist_poolinfo
|
table pg_dist_poolinfo
|
||||||
table pg_dist_rebalance_strategy
|
table pg_dist_rebalance_strategy
|
||||||
|
table pg_dist_schema
|
||||||
table pg_dist_shard
|
table pg_dist_shard
|
||||||
table pg_dist_tenant_schema
|
|
||||||
table pg_dist_transaction
|
table pg_dist_transaction
|
||||||
type citus.distribution_type
|
type citus.distribution_type
|
||||||
type citus.shard_transfer_mode
|
type citus.shard_transfer_mode
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ALTER SCHEMA "tenant\'_1" RENAME TO tenant_1;
|
ALTER SCHEMA "tenant\'_1" RENAME TO tenant_1;
|
||||||
ALTER SCHEMA "tenant\'_2" RENAME TO tenant_2;
|
ALTER SCHEMA "tenant\'_2" RENAME TO tenant_2;
|
||||||
-- verify that colocation id is set even for empty tenant
|
-- verify that colocation id is set even for empty tenant
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -10,7 +10,7 @@ WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
|
|
||||||
-- verify the same on workers
|
-- verify the same on workers
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -23,7 +23,7 @@ $$);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -35,7 +35,7 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
$$);
|
$$);
|
||||||
result
|
result
|
||||||
|
@ -61,7 +61,7 @@ SELECT colocationid = (
|
||||||
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
||||||
partmethod = 'n' AND repmodel = 's'
|
partmethod = 'n' AND repmodel = 's'
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -73,7 +73,7 @@ SELECT colocationid = (
|
||||||
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
||||||
partmethod = 'n' AND repmodel = 's'
|
partmethod = 'n' AND repmodel = 's'
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -87,7 +87,7 @@ ALTER SCHEMA tenant_2 RENAME TO "tenant\'_2";
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE SCHEMA tenant_3;
|
CREATE SCHEMA tenant_3;
|
||||||
-- Show that we can create furher tenant schemas after pg upgrade.
|
-- Show that we can create furher tenant schemas after pg upgrade.
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_3';
|
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_3';
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
t
|
t
|
||||||
|
|
|
@ -41,7 +41,7 @@ step "s1-schema-undistribute"
|
||||||
|
|
||||||
step "s1-verify-distributed-schema"
|
step "s1-verify-distributed-schema"
|
||||||
{
|
{
|
||||||
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_tenant_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
SELECT logicalrelid, partmethod, partkey, (colocationid = (SELECT colocationid AS tenant_colocid FROM pg_dist_schema)) AS is_correct_colocid, repmodel, autoconverted FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant%' ORDER BY logicalrelid;
|
||||||
}
|
}
|
||||||
|
|
||||||
step "s1-commit"
|
step "s1-commit"
|
||||||
|
|
|
@ -199,11 +199,11 @@ SET role dummyregular;
|
||||||
SELECT citus_schema_distribute('tenant1');
|
SELECT citus_schema_distribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
-- below query verifies the same colocationid in pg_dist_tenant_schema, pg_dist_colocation and all entries in pg_dist_partition at the same time
|
-- below query verifies the same colocationid in pg_dist_schema, pg_dist_colocation and all entries in pg_dist_partition at the same time
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -213,7 +213,7 @@ SELECT result FROM run_command_on_all_nodes(:verify_tenant_query);
|
||||||
SELECT citus_schema_undistribute('tenant1');
|
SELECT citus_schema_undistribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
-- below query verifies the tenant colocationid is removed from both pg_dist_colocation and all entries in pg_dist_partition at the same time
|
-- below query verifies the tenant colocationid is removed from both pg_dist_colocation and all entries in pg_dist_partition at the same time
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
@ -227,10 +227,10 @@ SET role dummysuper;
|
||||||
SELECT citus_schema_distribute('tenant1');
|
SELECT citus_schema_distribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -240,7 +240,7 @@ SELECT result FROM run_command_on_all_nodes(:verify_tenant_query);
|
||||||
SELECT citus_schema_undistribute('tenant1');
|
SELECT citus_schema_undistribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
|
||||||
|
@ -304,10 +304,10 @@ SELECT citus_schema_distribute('tenant1');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -323,7 +323,7 @@ SET client_min_messages TO WARNING;
|
||||||
SELECT citus_schema_undistribute('tenant1');
|
SELECT citus_schema_undistribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
|
||||||
|
@ -359,10 +359,10 @@ INSERT INTO "CiTuS.TeeN"."TeeNTabLE.1!?!" SELECT i, 'asd'::text FROM generate_se
|
||||||
SELECT citus_schema_distribute('"CiTuS.TeeN"');
|
SELECT citus_schema_distribute('"CiTuS.TeeN"');
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''"CiTuS.TeeN"%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''"CiTuS.TeeN"%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -372,7 +372,7 @@ SELECT result FROM run_command_on_all_nodes(:verify_tenant_query);
|
||||||
SELECT citus_schema_undistribute('"CiTuS.TeeN"');
|
SELECT citus_schema_undistribute('"CiTuS.TeeN"');
|
||||||
|
|
||||||
-- show the schema is a regular schema
|
-- show the schema is a regular schema
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
|
||||||
|
@ -394,10 +394,10 @@ SELECT undistribute_table('tenant1.single_shard_t');
|
||||||
SELECT citus_schema_distribute('tenant1');
|
SELECT citus_schema_distribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT '$$' ||
|
SELECT '$$' ||
|
||||||
' SELECT colocationid = ' || :tenant1_colocid ||
|
' SELECT colocationid = ' || :tenant1_colocid ||
|
||||||
' FROM pg_dist_tenant_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
' FROM pg_dist_schema JOIN pg_dist_colocation USING(colocationid)' ||
|
||||||
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
' WHERE colocationid = ALL(SELECT colocationid FROM pg_dist_partition WHERE logicalrelid::text LIKE ''tenant1%'')' ||
|
||||||
'$$'
|
'$$'
|
||||||
AS verify_tenant_query \gset
|
AS verify_tenant_query \gset
|
||||||
|
@ -407,7 +407,7 @@ SELECT result FROM run_command_on_all_nodes(:verify_tenant_query);
|
||||||
SELECT citus_schema_undistribute('tenant1');
|
SELECT citus_schema_undistribute('tenant1');
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT COUNT(*)=0 FROM pg_dist_colocation FULL JOIN pg_dist_partition USING(colocationid) WHERE (logicalrelid::text LIKE 'tenant1.%' OR logicalrelid is NULL) AND colocationid > 0 $$);
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT array_agg(logicalrelid ORDER BY logicalrelid) FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant1.%' AND colocationid > 0 $$);
|
||||||
|
|
||||||
|
@ -416,13 +416,13 @@ CREATE SCHEMA empty_tenant;
|
||||||
SELECT citus_schema_distribute('empty_tenant');
|
SELECT citus_schema_distribute('empty_tenant');
|
||||||
|
|
||||||
-- show the schema is a tenant schema now
|
-- show the schema is a tenant schema now
|
||||||
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_tenant_schema schemaid \gset
|
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_schema schemaid \gset
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace FROM pg_dist_colocation JOIN pg_dist_tenant_schema USING(colocationid) $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace FROM pg_dist_colocation JOIN pg_dist_schema USING(colocationid) $$);
|
||||||
|
|
||||||
SELECT citus_schema_undistribute('empty_tenant');
|
SELECT citus_schema_undistribute('empty_tenant');
|
||||||
|
|
||||||
-- show the schema is a regular schema now
|
-- show the schema is a regular schema now
|
||||||
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_tenant_schema $$);
|
SELECT result FROM run_command_on_all_nodes($$ SELECT schemaid::regnamespace as schemaname FROM pg_dist_schema $$);
|
||||||
SELECT '$$' || 'SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = ' || :empty_tenant_colocid || '$$'
|
SELECT '$$' || 'SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = ' || :empty_tenant_colocid || '$$'
|
||||||
AS verify_empty_tenant_query \gset
|
AS verify_empty_tenant_query \gset
|
||||||
SELECT result FROM run_command_on_all_nodes(:verify_empty_tenant_query);
|
SELECT result FROM run_command_on_all_nodes(:verify_empty_tenant_query);
|
||||||
|
|
|
@ -938,7 +938,7 @@ CREATE TABLE tenant_schema.test(x int, y int);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_schema.test'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_schema.test'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_schema';
|
WHERE schemaid::regnamespace::text = 'tenant_schema';
|
||||||
|
|
||||||
-- and make sure that we can't remove the coordinator due to "test"
|
-- and make sure that we can't remove the coordinator due to "test"
|
||||||
|
@ -983,7 +983,7 @@ DROP EXTENSION citus_columnar;
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
|
||||||
CREATE EXTENSION citus_columnar;
|
CREATE EXTENSION citus_columnar;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN ('columnar'::regnamespace, 'columnar_internal'::regnamespace);
|
WHERE schemaid IN ('columnar'::regnamespace, 'columnar_internal'::regnamespace);
|
||||||
|
|
||||||
RESET citus.enable_schema_based_sharding;
|
RESET citus.enable_schema_based_sharding;
|
||||||
|
|
|
@ -28,8 +28,8 @@ CREATE TABLE regular_schema.test_table(a int, b text);
|
||||||
SELECT create_distributed_table('regular_schema.test_table', 'a');
|
SELECT create_distributed_table('regular_schema.test_table', 'a');
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
|
||||||
-- show that regular_schema doesn't show up in pg_dist_tenant_schema
|
-- show that regular_schema doesn't show up in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||||
|
|
||||||
-- empty tenant
|
-- empty tenant
|
||||||
CREATE SCHEMA "tenant\'_1";
|
CREATE SCHEMA "tenant\'_1";
|
||||||
|
@ -73,12 +73,12 @@ ALTER TABLE regular_schema.test_table SET SCHEMA tenant_2;
|
||||||
ALTER TABLE tenant_2.test_table SET SCHEMA tenant_3;
|
ALTER TABLE tenant_2.test_table SET SCHEMA tenant_3;
|
||||||
|
|
||||||
-- (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_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
|
|
||||||
-- (on workers) verify that colocation id is set for empty tenants too
|
-- (on workers) verify that colocation id is set for empty tenants too
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT array_agg(colocationid > 0) FROM pg_dist_tenant_schema
|
SELECT array_agg(colocationid > 0) FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ WHERE logicalrelid = 'tenant_2.test_table'::regclass AND
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
|
|
||||||
-- (on workers) verify that colocation id is properly set for non-empty tenant schema
|
-- (on workers) verify that colocation id is properly set for non-empty tenant schema
|
||||||
|
@ -100,7 +100,7 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ CREATE TABLE tenant_1.test_table(a int, b text);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
|
|
||||||
-- (on workers) verify that colocation id is properly set for now-non-empty tenant schema
|
-- (on workers) verify that colocation id is properly set for now-non-empty tenant schema
|
||||||
|
@ -119,12 +119,12 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_1.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
-- verify that tenant_1 and tenant_2 have different colocation ids
|
-- verify that tenant_1 and tenant_2 have different colocation ids
|
||||||
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_tenant_schema
|
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_2');
|
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_2');
|
||||||
|
|
||||||
-- verify that we don't allow creating tenant tables via CREATE SCHEMA command
|
-- verify that we don't allow creating tenant tables via CREATE SCHEMA command
|
||||||
|
@ -322,7 +322,7 @@ SELECT COUNT(*) = 5
|
||||||
FROM pg_dist_partition
|
FROM pg_dist_partition
|
||||||
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
||||||
partmethod = 'n' AND repmodel = 's' AND colocationid = (
|
partmethod = 'n' AND repmodel = 's' AND colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5'
|
WHERE schemaid::regnamespace::text = 'tenant_5'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -347,11 +347,11 @@ CREATE TABLE tenant_5.tbl_2(a int, b text);
|
||||||
CREATE SCHEMA "CiTuS.TeeN_108";
|
CREATE SCHEMA "CiTuS.TeeN_108";
|
||||||
ALTER SCHEMA "CiTuS.TeeN_108" RENAME TO citus_teen_proper;
|
ALTER SCHEMA "CiTuS.TeeN_108" RENAME TO citus_teen_proper;
|
||||||
|
|
||||||
SELECT schemaid AS citus_teen_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
SELECT schemaid AS citus_teen_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||||
SELECT colocationid AS citus_teen_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
SELECT colocationid AS citus_teen_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO citus_teen_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO citus_teen_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'citus_teen_proper'
|
WHERE schemaid::regnamespace::text = 'citus_teen_proper'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ SELECT :citus_teen_colocationid > 0;
|
||||||
-- (on workers) verify that the same colocation id is used on workers too
|
-- (on workers) verify that the same colocation id is used on workers too
|
||||||
SELECT format(
|
SELECT format(
|
||||||
'SELECT result FROM run_command_on_workers($$
|
'SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=1 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = ''citus_teen_proper'' AND
|
WHERE schemaid::regnamespace::text = ''citus_teen_proper'' AND
|
||||||
colocationid = %s;
|
colocationid = %s;
|
||||||
$$);',
|
$$);',
|
||||||
|
@ -394,18 +394,18 @@ WHERE logicalrelid::regclass::text LIKE 'tenant_4.%';
|
||||||
SELECT COUNT(DISTINCT(colocationid))=1 FROM pg_dist_partition
|
SELECT COUNT(DISTINCT(colocationid))=1 FROM pg_dist_partition
|
||||||
WHERE logicalrelid::regclass::text LIKE 'tenant_5.%';
|
WHERE logicalrelid::regclass::text LIKE 'tenant_5.%';
|
||||||
|
|
||||||
SELECT schemaid AS tenant_4_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
SELECT schemaid AS tenant_4_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||||
SELECT colocationid AS tenant_4_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
SELECT colocationid AS tenant_4_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_4_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_4_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_4'
|
WHERE schemaid::regnamespace::text = 'tenant_4'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
|
|
||||||
-- Rename it to a name that contains a single quote to verify that we properly
|
-- Rename it to a name that contains a single quote to verify that we properly
|
||||||
-- escape its name when sending the command to delete the pg_dist_tenant_schema
|
-- escape its name when sending the command to delete the pg_dist_schema
|
||||||
-- entry on workers.
|
-- entry on workers.
|
||||||
ALTER SCHEMA tenant_4 RENAME TO "tenant\'_4";
|
ALTER SCHEMA tenant_4 RENAME TO "tenant\'_4";
|
||||||
|
|
||||||
|
@ -414,22 +414,22 @@ DROP SCHEMA "tenant\'_4", "CiTuS.TeeN_108" CASCADE;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
|
|
||||||
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
||||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_4_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_4_schemaid;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_4_colocationid;
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_4_colocationid;
|
||||||
|
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :citus_teen_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :citus_teen_schemaid;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :citus_teen_colocationid;
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :citus_teen_colocationid;
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema deletes the associated
|
-- (on workers) Verify that dropping a tenant schema deletes the associated
|
||||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM citus_teen_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM citus_teen_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -467,12 +467,12 @@ SELECT create_distributed_table('regular_schema.null_shard_key_table_2', null);
|
||||||
|
|
||||||
-- Show that we don't chose to colocate regular single-shard tables with
|
-- Show that we don't chose to colocate regular single-shard tables with
|
||||||
-- tenant tables by default.
|
-- tenant tables by default.
|
||||||
SELECT * FROM pg_dist_tenant_schema WHERE colocationid = (
|
SELECT * FROM pg_dist_schema WHERE colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'regular_schema.null_shard_key_table_2'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'regular_schema.null_shard_key_table_2'::regclass
|
||||||
);
|
);
|
||||||
|
|
||||||
-- save the colocation id used for tenant_5
|
-- save the colocation id used for tenant_5
|
||||||
SELECT colocationid AS tenant_5_old_colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid AS tenant_5_old_colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5' \gset
|
WHERE schemaid::regnamespace::text = 'tenant_5' \gset
|
||||||
|
|
||||||
-- drop all the tables that belong to tenant_5 and create a new one
|
-- drop all the tables that belong to tenant_5 and create a new one
|
||||||
|
@ -480,32 +480,32 @@ DROP TABLE tenant_5.tbl_1, tenant_5.tbl_2, tenant_5.tbl_3;
|
||||||
CREATE TABLE tenant_5.tbl_4(a int, b text);
|
CREATE TABLE tenant_5.tbl_4(a int, b text);
|
||||||
|
|
||||||
-- (on coordinator) verify that tenant_5 is still associated with the same colocation id
|
-- (on coordinator) verify that tenant_5 is still associated with the same colocation id
|
||||||
SELECT colocationid = :tenant_5_old_colocationid FROM pg_dist_tenant_schema
|
SELECT colocationid = :tenant_5_old_colocationid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_5';
|
WHERE schemaid::regnamespace::text = 'tenant_5';
|
||||||
|
|
||||||
-- (on workers) verify that tenant_5 is still associated with the same colocation id
|
-- (on workers) verify that tenant_5 is still associated with the same colocation id
|
||||||
SELECT format(
|
SELECT format(
|
||||||
'SELECT result FROM run_command_on_workers($$
|
'SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = %s FROM pg_dist_tenant_schema
|
SELECT colocationid = %s FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = ''tenant_5'';
|
WHERE schemaid::regnamespace::text = ''tenant_5'';
|
||||||
$$);',
|
$$);',
|
||||||
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
||||||
|
|
||||||
:verify_workers_query
|
:verify_workers_query
|
||||||
|
|
||||||
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
||||||
SELECT colocationid AS tenant_1_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
SELECT colocationid AS tenant_1_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1' \gset
|
||||||
|
|
||||||
SELECT schemaid AS tenant_2_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
SELECT schemaid AS tenant_2_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||||
SELECT colocationid AS tenant_2_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
SELECT colocationid AS tenant_2_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_1_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_1_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1'
|
WHERE schemaid::regnamespace::text = 'tenant_1'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_2_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_2_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2'
|
WHERE schemaid::regnamespace::text = 'tenant_2'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -537,16 +537,16 @@ DROP ROLE test_non_super_user;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
|
|
||||||
-- (on coordinator) Verify that dropping a tenant schema always deletes
|
-- (on coordinator) Verify that dropping a tenant schema always deletes
|
||||||
-- the associated pg_dist_tenant_schema entry even if the the schema was
|
-- the associated pg_dist_schema entry even if the the schema was
|
||||||
-- dropped while the GUC was set to off.
|
-- dropped while the GUC was set to off.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_1_schemaid, :tenant_2_schemaid);
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IN (:tenant_1_schemaid, :tenant_2_schemaid);
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_1_colocationid, :tenant_2_colocationid);
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_1_colocationid, :tenant_2_colocationid);
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema always deletes
|
-- (on workers) Verify that dropping a tenant schema always deletes
|
||||||
-- the associated pg_dist_tenant_schema entry even if the the schema was
|
-- the associated pg_dist_schema entry even if the the schema was
|
||||||
-- dropped while the GUC was set to off.
|
-- dropped while the GUC was set to off.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_1_schemaid UNION SELECT schemaid FROM tenant_2_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_1_schemaid UNION SELECT schemaid FROM tenant_2_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -569,20 +569,20 @@ $$);
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
|
|
||||||
-- show that all schemaid values are unique and non-null in pg_dist_tenant_schema
|
-- show that all schemaid values are unique and non-null in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IS NULL;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IS NULL;
|
||||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_tenant_schema);
|
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_schema);
|
||||||
|
|
||||||
-- show that all colocationid values are unique and non-null in pg_dist_tenant_schema
|
-- show that all colocationid values are unique and non-null in pg_dist_schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE colocationid IS NULL;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE colocationid IS NULL;
|
||||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_tenant_schema);
|
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_schema);
|
||||||
|
|
||||||
CREATE TABLE public.cannot_be_a_tenant_table(a int, b text);
|
CREATE TABLE public.cannot_be_a_tenant_table(a int, b text);
|
||||||
|
|
||||||
-- show that we don't consider public schema as a tenant schema
|
-- show that we don't consider public schema as a tenant schema
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'public';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'public';
|
||||||
|
|
||||||
DROP TABLE public.cannot_be_a_tenant_table;
|
DROP TABLE public.cannot_be_a_tenant_table;
|
||||||
|
|
||||||
|
@ -592,13 +592,13 @@ BEGIN;
|
||||||
|
|
||||||
-- Show that we don't consider public schema as a tenant schema,
|
-- Show that we don't consider public schema as a tenant schema,
|
||||||
-- even if it's recreated.
|
-- even if it's recreated.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'public';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'public';
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
||||||
|
|
||||||
-- show that we don't consider temporary schemas as tenant schemas
|
-- show that we don't consider temporary schemas as tenant schemas
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = '%pg_temp%';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = '%pg_temp%';
|
||||||
|
|
||||||
DROP TABLE temp_table;
|
DROP TABLE temp_table;
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ BEGIN;
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_7.tbl_1'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_7.tbl_1'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_7';
|
WHERE schemaid::regnamespace::text = 'tenant_7';
|
||||||
|
|
||||||
-- make sure that both tables created in tenant_7 are colocated
|
-- make sure that both tables created in tenant_7 are colocated
|
||||||
|
@ -627,7 +627,7 @@ BEGIN;
|
||||||
CREATE TABLE tenant_8.tbl_2(a int, b text);
|
CREATE TABLE tenant_8.tbl_2(a int, b text);
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_8';
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_8';
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant_8.%';
|
SELECT COUNT(*)=0 FROM pg_dist_partition WHERE logicalrelid::text LIKE 'tenant_8.%';
|
||||||
|
|
||||||
-- Verify that citus.enable_schema_based_sharding and citus.use_citus_managed_tables
|
-- Verify that citus.enable_schema_based_sharding and citus.use_citus_managed_tables
|
||||||
|
@ -675,27 +675,27 @@ CREATE TABLE tenant_5.tbl_5(a int, b text, FOREIGN KEY(a) REFERENCES tenant_7.tb
|
||||||
|
|
||||||
CREATE SCHEMA tenant_9;
|
CREATE SCHEMA tenant_9;
|
||||||
|
|
||||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_9'
|
WHERE schemaid::regnamespace::text = 'tenant_9'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
DROP SCHEMA tenant_9;
|
DROP SCHEMA tenant_9;
|
||||||
|
|
||||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||||
-- doesn't leave any dangling entries in pg_dist_tenant_schema and
|
-- doesn't leave any dangling entries in pg_dist_schema and
|
||||||
-- pg_dist_colocation.
|
-- pg_dist_colocation.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocationid;
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocationid;
|
||||||
|
|
||||||
-- (on workers) Make sure that dropping an empty tenant schema
|
-- (on workers) Make sure that dropping an empty tenant schema
|
||||||
-- doesn't leave any dangling entries in pg_dist_tenant_schema and
|
-- doesn't leave any dangling entries in pg_dist_schema and
|
||||||
-- pg_dist_colocation.
|
-- pg_dist_colocation.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -776,11 +776,11 @@ SET citus.shard_replication_factor TO 1;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
SET citus.enable_schema_based_sharding TO ON;
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
|
||||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
SELECT colocationid AS tenant_9_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_9_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_9'
|
WHERE schemaid::regnamespace::text = 'tenant_9'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -788,15 +788,15 @@ DROP OWNED BY test_other_super_user;
|
||||||
|
|
||||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
-- pg_dist_schema and pg_dist_colocation.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocationid;
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocationid;
|
||||||
|
|
||||||
-- (on workers) Make sure that dropping an empty tenant schema
|
-- (on workers) Make sure that dropping an empty tenant schema
|
||||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
-- pg_dist_schema and pg_dist_colocation.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -841,29 +841,29 @@ DROP TABLE tenant_10.tbl_2;
|
||||||
|
|
||||||
CREATE SCHEMA tenant_11;
|
CREATE SCHEMA tenant_11;
|
||||||
|
|
||||||
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
||||||
SELECT colocationid AS tenant_10_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
SELECT colocationid AS tenant_10_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_10' \gset
|
||||||
|
|
||||||
SELECT schemaid AS tenant_11_schemaid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
SELECT schemaid AS tenant_11_schemaid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||||
SELECT colocationid AS tenant_11_colocationid FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
SELECT colocationid AS tenant_11_colocationid FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_10_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_10_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_10'
|
WHERE schemaid::regnamespace::text = 'tenant_10'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT schemaid INTO tenant_11_schemaid FROM pg_dist_tenant_schema
|
SELECT schemaid INTO tenant_11_schemaid FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_11'
|
WHERE schemaid::regnamespace::text = 'tenant_11'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
-- (on coordinator) Verify metadata for tenant schemas that are created via non-super-user.
|
-- (on coordinator) Verify metadata for tenant schemas that are created via non-super-user.
|
||||||
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||||
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colocationid, :tenant_11_colocationid);
|
SELECT COUNT(DISTINCT(colocationid))=2 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colocationid, :tenant_11_colocationid);
|
||||||
|
|
||||||
-- (on workers) Verify metadata for tenant schemas that are created via non-super-user.
|
-- (on workers) Verify metadata for tenant schemas that are created via non-super-user.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_tenant_schema
|
SELECT COUNT(DISTINCT(schemaid))=2 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -880,14 +880,14 @@ DROP SCHEMA tenant_10, tenant_11 CASCADE;
|
||||||
SET client_min_messages TO NOTICE;
|
SET client_min_messages TO NOTICE;
|
||||||
|
|
||||||
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
||||||
-- deletes the associated pg_dist_tenant_schema entry.
|
-- deletes the associated pg_dist_schema entry.
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colocationid, :tenant_11_colocationid);
|
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colocationid, :tenant_11_colocationid);
|
||||||
|
|
||||||
-- (on workers) Verify that dropping a tenant schema via non-super-user
|
-- (on workers) Verify that dropping a tenant schema via non-super-user
|
||||||
-- deletes the associated pg_dist_tenant_schema entry.
|
-- deletes the associated pg_dist_schema entry.
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema
|
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||||
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
WHERE schemaid IN (SELECT schemaid FROM tenant_10_schemaid UNION SELECT schemaid FROM tenant_11_schemaid)
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
|
|
@ -104,8 +104,8 @@ SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE SCHEMA tenant_1;
|
CREATE SCHEMA tenant_1;
|
||||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||||
|
|
||||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
|
|
||||||
-- verify that tenant_1.tbl_1 is recorded in pg_dist_partition, as a single-shard table
|
-- verify that tenant_1.tbl_1 is recorded in pg_dist_partition, as a single-shard table
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_partition
|
SELECT COUNT(*)=1 FROM pg_dist_partition
|
||||||
|
|
|
@ -2,12 +2,12 @@ ALTER SCHEMA "tenant\'_1" RENAME TO tenant_1;
|
||||||
ALTER SCHEMA "tenant\'_2" RENAME TO tenant_2;
|
ALTER SCHEMA "tenant\'_2" RENAME TO tenant_2;
|
||||||
|
|
||||||
-- verify that colocation id is set even for empty tenant
|
-- verify that colocation id is set even for empty tenant
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
|
|
||||||
-- verify the same on workers
|
-- verify the same on workers
|
||||||
SELECT result FROM run_command_on_workers($$
|
SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
SELECT colocationid > 0 FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ $$);
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
|
|
||||||
-- verify the same on workers
|
-- verify the same on workers
|
||||||
|
@ -23,7 +23,7 @@ SELECT result FROM run_command_on_workers($$
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
SELECT colocationid FROM pg_dist_partition WHERE logicalrelid = 'tenant_2.test_table'::regclass
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ SELECT colocationid = (
|
||||||
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
||||||
partmethod = 'n' AND repmodel = 's'
|
partmethod = 'n' AND repmodel = 's'
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||||
|
|
||||||
SELECT colocationid = (
|
SELECT colocationid = (
|
||||||
|
@ -49,7 +49,7 @@ SELECT colocationid = (
|
||||||
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
||||||
partmethod = 'n' AND repmodel = 's'
|
partmethod = 'n' AND repmodel = 's'
|
||||||
)
|
)
|
||||||
FROM pg_dist_tenant_schema
|
FROM pg_dist_schema
|
||||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||||
|
|
||||||
-- rollback the changes made on following schemas to make this test idempotent
|
-- rollback the changes made on following schemas to make this test idempotent
|
||||||
|
@ -62,7 +62,7 @@ SET citus.enable_schema_based_sharding TO ON;
|
||||||
CREATE SCHEMA tenant_3;
|
CREATE SCHEMA tenant_3;
|
||||||
|
|
||||||
-- Show that we can create furher tenant schemas after pg upgrade.
|
-- Show that we can create furher tenant schemas after pg upgrade.
|
||||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_3';
|
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_3';
|
||||||
|
|
||||||
-- drop the schema created in this test to this test idempotent
|
-- drop the schema created in this test to this test idempotent
|
||||||
DROP SCHEMA tenant_3 CASCADE;
|
DROP SCHEMA tenant_3 CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue