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
|
||||
DistTenantSchemaRelationId(void)
|
||||
{
|
||||
CachedRelationLookup("pg_dist_tenant_schema",
|
||||
CachedRelationLookup("pg_dist_schema",
|
||||
&MetadataCache.distTenantSchemaRelationId);
|
||||
|
||||
return MetadataCache.distTenantSchemaRelationId;
|
||||
}
|
||||
|
||||
|
||||
/* return oid of pg_dist_tenant_schema_pkey index */
|
||||
/* return oid of pg_dist_schema_pkey index */
|
||||
Oid
|
||||
DistTenantSchemaPrimaryKeyIndexId(void)
|
||||
{
|
||||
CachedRelationLookup("pg_dist_tenant_schema_pkey",
|
||||
CachedRelationLookup("pg_dist_schema_pkey",
|
||||
&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
|
||||
DistTenantSchemaUniqueColocationIdIndexId(void)
|
||||
{
|
||||
CachedRelationLookup("pg_dist_tenant_schema_unique_colocationid_index",
|
||||
CachedRelationLookup("pg_dist_schema_unique_colocationid_index",
|
||||
&MetadataCache.distTenantSchemaUniqueColocationIdIndexId);
|
||||
|
||||
return MetadataCache.distTenantSchemaUniqueColocationIdIndexId;
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#include "distributed/pg_dist_colocation.h"
|
||||
#include "distributed/pg_dist_node.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/remote_commands.h"
|
||||
#include "distributed/resource_lock.h"
|
||||
|
@ -4452,7 +4452,7 @@ SyncDistributedObjects(MetadataSyncContext *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 exist on the worker.
|
||||
|
@ -4532,7 +4532,7 @@ SendMetadataDeletionCommands(MetadataSyncContext *context)
|
|||
/* remove pg_dist_colocation entries */
|
||||
SendOrCollectCommandListToActivatedNodes(context, list_make1(DELETE_ALL_COLOCATION));
|
||||
|
||||
/* remove pg_dist_tenant_schema entries */
|
||||
/* remove pg_dist_schema entries */
|
||||
SendOrCollectCommandListToActivatedNodes(context,
|
||||
list_make1(DELETE_ALL_TENANT_SCHEMAS));
|
||||
}
|
||||
|
@ -4662,8 +4662,8 @@ SendTenantSchemaMetadataCommands(MetadataSyncContext *context)
|
|||
break;
|
||||
}
|
||||
|
||||
Form_pg_dist_tenant_schema tenantSchemaForm =
|
||||
(Form_pg_dist_tenant_schema) GETSTRUCT(heapTuple);
|
||||
Form_pg_dist_schema tenantSchemaForm =
|
||||
(Form_pg_dist_schema) GETSTRUCT(heapTuple);
|
||||
|
||||
StringInfo insertTenantSchemaCommand = makeStringInfo();
|
||||
appendStringInfo(insertTenantSchemaCommand,
|
||||
|
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
-- bump version to 12.0-1
|
||||
|
||||
CREATE TABLE citus.pg_dist_tenant_schema (
|
||||
CREATE TABLE citus.pg_dist_schema (
|
||||
schemaid oid NOT NULL,
|
||||
colocationid int NOT NULL,
|
||||
CONSTRAINT pg_dist_tenant_schema_pkey PRIMARY KEY (schemaid),
|
||||
CONSTRAINT pg_dist_tenant_schema_unique_colocationid_index UNIQUE (colocationid)
|
||||
CONSTRAINT pg_dist_schema_pkey PRIMARY KEY (schemaid),
|
||||
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_delete_tenant_schema/12.0-1.sql"
|
||||
|
||||
#include "udfs/citus_prepare_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_drop_trigger/12.0-1.sql"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
DO $$
|
||||
BEGIN
|
||||
-- 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
|
||||
RAISE EXCEPTION 'cannot downgrade Citus because there are '
|
||||
'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_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 FUNCTION pg_catalog.citus_stat_tenants_local_internal(
|
||||
|
|
|
@ -36,13 +36,13 @@ BEGIN
|
|||
|
||||
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
||||
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.
|
||||
--
|
||||
-- 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
|
||||
-- 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
|
||||
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
||||
END IF;
|
||||
|
|
|
@ -36,13 +36,13 @@ BEGIN
|
|||
|
||||
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects()
|
||||
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.
|
||||
--
|
||||
-- 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
|
||||
-- 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
|
||||
PERFORM pg_catalog.citus_internal_unregister_tenant_schema_globally(v_obj.objid, v_obj.object_name);
|
||||
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_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_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
|
||||
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;
|
||||
|
@ -94,7 +94,7 @@ BEGIN
|
|||
DROP TABLE public.pg_dist_transaction;
|
||||
DROP TABLE public.pg_dist_rebalance_strategy;
|
||||
DROP TABLE public.pg_dist_cleanup;
|
||||
DROP TABLE public.pg_dist_tenant_schema;
|
||||
DROP TABLE public.pg_dist_schema;
|
||||
--
|
||||
-- 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_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_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
|
||||
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;
|
||||
|
@ -94,7 +94,7 @@ BEGIN
|
|||
DROP TABLE public.pg_dist_transaction;
|
||||
DROP TABLE public.pg_dist_rebalance_strategy;
|
||||
DROP TABLE public.pg_dist_cleanup;
|
||||
DROP TABLE public.pg_dist_tenant_schema;
|
||||
DROP TABLE public.pg_dist_schema;
|
||||
--
|
||||
-- reset sequences
|
||||
--
|
||||
|
|
|
@ -5,4 +5,4 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_internal_add_tenant_schema(schema_id
|
|||
AS 'MODULE_PATHNAME';
|
||||
|
||||
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';
|
||||
|
||||
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';
|
||||
|
||||
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';
|
||||
|
||||
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_object;
|
||||
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;
|
||||
|
||||
--
|
||||
|
@ -49,7 +49,7 @@ BEGIN
|
|||
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;
|
||||
-- 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
|
||||
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;
|
||||
|
|
|
@ -33,7 +33,7 @@ BEGIN
|
|||
DROP TABLE IF EXISTS public.pg_dist_rebalance_strategy;
|
||||
DROP TABLE IF EXISTS public.pg_dist_object;
|
||||
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;
|
||||
|
||||
--
|
||||
|
@ -49,7 +49,7 @@ BEGIN
|
|||
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;
|
||||
-- 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
|
||||
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;
|
||||
|
|
|
@ -3,7 +3,7 @@ SELECT
|
|||
pg_dist_shard.logicalrelid AS table_name,
|
||||
pg_dist_shard.shardid,
|
||||
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 repmodel = 't' THEN 'reference'
|
||||
WHEN colocationid = 0 THEN 'local'
|
||||
|
|
|
@ -3,7 +3,7 @@ SELECT
|
|||
pg_dist_shard.logicalrelid AS table_name,
|
||||
pg_dist_shard.shardid,
|
||||
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 repmodel = 't' THEN 'reference'
|
||||
WHEN colocationid = 0 THEN 'local'
|
||||
|
|
|
@ -40,7 +40,7 @@ BEGIN
|
|||
L.cpu_usage_in_last_period,
|
||||
L.score
|
||||
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
|
||||
ORDER BY L.score DESC;
|
||||
END;
|
||||
|
|
|
@ -40,7 +40,7 @@ BEGIN
|
|||
L.cpu_usage_in_last_period,
|
||||
L.score
|
||||
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
|
||||
ORDER BY L.score DESC;
|
||||
END;
|
||||
|
|
|
@ -6,7 +6,7 @@ citus_tables_create_query=$CTCQ$
|
|||
CREATE OR REPLACE VIEW %I.citus_tables AS
|
||||
SELECT
|
||||
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 repmodel = 't' THEN 'reference'
|
||||
WHEN colocationid = 0 THEN 'local'
|
||||
|
|
|
@ -6,7 +6,7 @@ citus_tables_create_query=$CTCQ$
|
|||
CREATE OR REPLACE VIEW %I.citus_tables AS
|
||||
SELECT
|
||||
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 repmodel = 't' THEN 'reference'
|
||||
WHEN colocationid = 0 THEN 'local'
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "distributed/colocation_utils.h"
|
||||
#include "distributed/metadata_cache.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 "storage/lockdefs.h"
|
||||
#include "utils/relcache.h"
|
||||
|
@ -33,7 +33,7 @@ IsTenantSchema(Oid schemaId)
|
|||
/*
|
||||
* We don't allow creating tenant schemas when there is a version
|
||||
* 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,
|
||||
* it's safe to assume that it cannot be a tenant schema when there is a
|
||||
* version mismatch.
|
||||
|
@ -45,7 +45,7 @@ IsTenantSchema(Oid schemaId)
|
|||
* 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 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
|
||||
* no version mismatch. But we're okay with that because we don't expect
|
||||
* users to disable version checks anyway.
|
||||
|
@ -89,7 +89,7 @@ SchemaIdGetTenantColocationId(Oid schemaId)
|
|||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||
AccessShareLock);
|
||||
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));
|
||||
|
||||
bool indexOk = true;
|
||||
|
@ -103,7 +103,7 @@ SchemaIdGetTenantColocationId(Oid schemaId)
|
|||
bool isNull = false;
|
||||
colocationId = DatumGetUInt32(
|
||||
heap_getattr(heapTuple,
|
||||
Anum_pg_dist_tenant_schema_colocationid,
|
||||
Anum_pg_dist_schema_colocationid,
|
||||
RelationGetDescr(pgDistTenantSchema),
|
||||
&isNull));
|
||||
Assert(!isNull);
|
||||
|
@ -133,7 +133,7 @@ ColocationIdGetTenantSchemaId(uint32 colocationId)
|
|||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||
AccessShareLock);
|
||||
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));
|
||||
|
||||
bool indexOk = true;
|
||||
|
@ -146,7 +146,7 @@ ColocationIdGetTenantSchemaId(uint32 colocationId)
|
|||
if (HeapTupleIsValid(heapTuple))
|
||||
{
|
||||
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);
|
||||
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.
|
||||
*
|
||||
* 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")));
|
||||
}
|
||||
|
||||
Datum values[Natts_pg_dist_tenant_schema] = { 0 };
|
||||
bool isNulls[Natts_pg_dist_tenant_schema] = { 0 };
|
||||
Datum values[Natts_pg_dist_schema] = { 0 };
|
||||
bool isNulls[Natts_pg_dist_schema] = { 0 };
|
||||
|
||||
values[Anum_pg_dist_tenant_schema_schemaid - 1] = ObjectIdGetDatum(schemaId);
|
||||
values[Anum_pg_dist_tenant_schema_colocationid - 1] = UInt32GetDatum(colocationId);
|
||||
values[Anum_pg_dist_schema_schemaid - 1] = ObjectIdGetDatum(schemaId);
|
||||
values[Anum_pg_dist_schema_colocationid - 1] = UInt32GetDatum(colocationId);
|
||||
|
||||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||
RowExclusiveLock);
|
||||
|
@ -199,7 +199,7 @@ InsertTenantSchemaLocally(Oid schemaId, uint32 colocationId)
|
|||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -214,7 +214,7 @@ DeleteTenantSchemaLocally(Oid schemaId)
|
|||
Relation pgDistTenantSchema = table_open(DistTenantSchemaRelationId(),
|
||||
RowExclusiveLock);
|
||||
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));
|
||||
|
||||
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_PARTITIONS "DELETE FROM pg_dist_partition"
|
||||
#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 \
|
||||
"CALL pg_catalog.worker_drop_all_shell_tables(%s)"
|
||||
#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)
|
||||
|
||||
-- show the schema is a tenant schema now
|
||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_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
|
||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -340,7 +340,7 @@ SELECT citus_schema_undistribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -384,10 +384,10 @@ SELECT citus_schema_distribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -414,7 +414,7 @@ SELECT citus_schema_undistribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -539,7 +539,7 @@ SELECT citus_schema_distribute('tenant1');
|
|||
|
||||
ROLLBACK;
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -576,10 +576,10 @@ SELECT citus_schema_distribute('tenant1');
|
|||
|
||||
COMMIT;
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -617,7 +617,7 @@ SELECT citus_schema_undistribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -703,10 +703,10 @@ SELECT citus_schema_distribute('"CiTuS.TeeN"');
|
|||
(1 row)
|
||||
|
||||
-- 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 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"%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -733,7 +733,7 @@ SELECT citus_schema_undistribute('"CiTuS.TeeN"');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -811,10 +811,10 @@ SELECT citus_schema_distribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -841,7 +841,7 @@ SELECT citus_schema_undistribute('tenant1');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
@ -874,8 +874,8 @@ SELECT citus_schema_distribute('empty_tenant');
|
|||
(1 row)
|
||||
|
||||
-- show the schema is a tenant schema now
|
||||
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_tenant_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 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_schema USING(colocationid) $$);
|
||||
result
|
||||
---------------------------------------------------------------------
|
||||
empty_tenant
|
||||
|
@ -890,7 +890,7 @@ SELECT citus_schema_undistribute('empty_tenant');
|
|||
(1 row)
|
||||
|
||||
-- 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
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@ citus_schema_distribute
|
|||
step s2-drop-schema:
|
||||
DROP SCHEMA tenant1 CASCADE;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-schema: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -65,12 +65,12 @@ citus_schema_undistribute
|
|||
step s2-drop-schema:
|
||||
DROP SCHEMA tenant1 CASCADE;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-schema: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -106,7 +106,7 @@ step s1-commit:
|
|||
COMMIT;
|
||||
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -153,7 +153,7 @@ step s1-commit:
|
|||
COMMIT;
|
||||
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -186,12 +186,12 @@ citus_schema_distribute
|
|||
step s2-add-table:
|
||||
CREATE TABLE tenant1.table4(id int PRIMARY KEY, name text, col bigint);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-add-table: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -235,12 +235,12 @@ citus_schema_undistribute
|
|||
step s2-add-table:
|
||||
CREATE TABLE tenant1.table4(id int PRIMARY KEY, name text, col bigint);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-add-table: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -273,12 +273,12 @@ citus_schema_distribute
|
|||
step s2-drop-table:
|
||||
DROP TABLE tenant1.table3;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-table: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -320,12 +320,12 @@ citus_schema_undistribute
|
|||
step s2-drop-table:
|
||||
DROP TABLE tenant1.table3;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-table: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -357,12 +357,12 @@ citus_schema_distribute
|
|||
step s2-alter-col-type:
|
||||
ALTER TABLE tenant1.table3 ALTER COLUMN col1 TYPE text;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-alter-col-type: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -405,12 +405,12 @@ citus_schema_undistribute
|
|||
step s2-alter-col-type:
|
||||
ALTER TABLE tenant1.table3 ALTER COLUMN col1 TYPE text;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-alter-col-type: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -443,12 +443,12 @@ citus_schema_distribute
|
|||
step s2-add-foreign-key:
|
||||
ALTER TABLE tenant1.table3 ADD CONSTRAINT table3_fk1 FOREIGN KEY (id) REFERENCES tenant1.table2 (id);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-add-foreign-key: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -491,12 +491,12 @@ citus_schema_undistribute
|
|||
step s2-add-foreign-key:
|
||||
ALTER TABLE tenant1.table3 ADD CONSTRAINT table3_fk1 FOREIGN KEY (id) REFERENCES tenant1.table2 (id);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-add-foreign-key: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -530,12 +530,12 @@ citus_schema_distribute
|
|||
step s2-drop-foreign-key:
|
||||
ALTER TABLE tenant1.table3 DROP CONSTRAINT table3_col_fkey;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-foreign-key: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -578,12 +578,12 @@ citus_schema_undistribute
|
|||
step s2-drop-foreign-key:
|
||||
ALTER TABLE tenant1.table3 DROP CONSTRAINT table3_col_fkey;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-drop-foreign-key: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -615,12 +615,12 @@ citus_schema_distribute
|
|||
step s2-create-unique-index:
|
||||
CREATE UNIQUE INDEX idx_2 ON tenant1.table3 (col);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-create-unique-index: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -663,12 +663,12 @@ citus_schema_undistribute
|
|||
step s2-create-unique-index:
|
||||
CREATE UNIQUE INDEX idx_2 ON tenant1.table3 (col);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-create-unique-index: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -701,12 +701,12 @@ citus_schema_distribute
|
|||
step s2-create-unique-index-concurrently:
|
||||
CREATE UNIQUE INDEX CONCURRENTLY idx_3 ON tenant1.table3 (col);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-create-unique-index-concurrently: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -749,12 +749,12 @@ citus_schema_undistribute
|
|||
step s2-create-unique-index-concurrently:
|
||||
CREATE UNIQUE INDEX CONCURRENTLY idx_3 ON tenant1.table3 (col);
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-create-unique-index-concurrently: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -790,12 +790,12 @@ citus_schema_distribute
|
|||
step s2-reindex-unique-concurrently:
|
||||
REINDEX INDEX CONCURRENTLY tenant1.idx_2;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-reindex-unique-concurrently: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -841,12 +841,12 @@ citus_schema_undistribute
|
|||
step s2-reindex-unique-concurrently:
|
||||
REINDEX INDEX CONCURRENTLY tenant1.idx_2;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-reindex-unique-concurrently: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -880,12 +880,12 @@ step s2-insert:
|
|||
INSERT INTO public.ref SELECT i FROM generate_series(11, 20) i;
|
||||
INSERT INTO tenant1.table3 SELECT i, 'asd', i*1000 FROM generate_series(11, 20) i;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-insert: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -929,12 +929,12 @@ step s2-insert:
|
|||
INSERT INTO public.ref SELECT i FROM generate_series(11, 20) i;
|
||||
INSERT INTO tenant1.table3 SELECT i, 'asd', i*1000 FROM generate_series(11, 20) i;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-insert: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -971,12 +971,12 @@ citus_schema_distribute
|
|||
step s2-update:
|
||||
UPDATE tenant1.table3 SET col = 11 WHERE col = 11;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-update: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -1023,12 +1023,12 @@ citus_schema_undistribute
|
|||
step s2-update:
|
||||
UPDATE tenant1.table3 SET col = 11 WHERE col = 11;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-update: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -1065,12 +1065,12 @@ citus_schema_distribute
|
|||
step s2-delete:
|
||||
DELETE FROM tenant1.table3;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-delete: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
@ -1117,12 +1117,12 @@ citus_schema_undistribute
|
|||
step s2-delete:
|
||||
DELETE FROM tenant1.table3;
|
||||
<waiting ...>
|
||||
step s1-commit:
|
||||
step s1-commit:
|
||||
COMMIT;
|
||||
|
||||
step s2-delete: <... completed>
|
||||
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
|
||||
---------------------------------------------------------------------
|
||||
|
|
|
@ -1365,7 +1365,7 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
| function citus_schema_distribute(regnamespace) void
|
||||
| function citus_schema_undistribute(regnamespace) void
|
||||
| function citus_stat_tenants_local_internal(boolean) SETOF record
|
||||
| table pg_dist_tenant_schema
|
||||
| table pg_dist_schema
|
||||
(7 rows)
|
||||
|
||||
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 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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -1861,7 +1861,7 @@ DROP TABLE test;
|
|||
DROP EXTENSION citus_columnar;
|
||||
SET citus.enable_schema_based_sharding TO ON;
|
||||
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);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
|
|
@ -76,7 +76,7 @@ SELECT unnest(activate_node_snapshot()) order by 1;
|
|||
CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION pg_database_owner
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
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
|
||||
DELETE FROM pg_catalog.pg_dist_colocation
|
||||
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_partition
|
||||
DELETE FROM pg_dist_placement
|
||||
|
|
|
@ -41,8 +41,8 @@ SELECT create_distributed_table('regular_schema.test_table', 'a');
|
|||
(1 row)
|
||||
|
||||
SET citus.enable_schema_based_sharding TO ON;
|
||||
-- show that regular_schema doesn't show up in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||
-- show that regular_schema doesn't show up in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
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;
|
||||
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
|
||||
SELECT colocationid > 0 FROM pg_dist_tenant_schema
|
||||
SELECT colocationid > 0 FROM pg_dist_schema
|
||||
WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_3');
|
||||
?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
|
||||
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');
|
||||
$$);
|
||||
result
|
||||
|
@ -132,7 +132,7 @@ WHERE logicalrelid = 'tenant_2.test_table'::regclass AND
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -144,7 +144,7 @@ SELECT result FROM run_command_on_workers($$
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
$$);
|
||||
result
|
||||
|
@ -159,7 +159,7 @@ CREATE TABLE tenant_1.test_table(a int, b text);
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -171,7 +171,7 @@ SELECT result FROM run_command_on_workers($$
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
$$);
|
||||
result
|
||||
|
@ -181,7 +181,7 @@ $$);
|
|||
(2 rows)
|
||||
|
||||
-- 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');
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -465,7 +465,7 @@ SELECT COUNT(*) = 5
|
|||
FROM pg_dist_partition
|
||||
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
||||
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'
|
||||
);
|
||||
?column?
|
||||
|
@ -499,10 +499,10 @@ ERROR: tenant tables cannot inherit or be inherited
|
|||
CREATE TABLE tenant_5.tbl_2(a int, b text);
|
||||
CREATE SCHEMA "CiTuS.TeeN_108";
|
||||
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 colocationid AS citus_teen_colocationid 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_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -521,7 +521,7 @@ SELECT :citus_teen_colocationid > 0;
|
|||
-- (on workers) verify that the same colocation id is used on workers too
|
||||
SELECT format(
|
||||
'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
|
||||
colocationid = %s;
|
||||
$$);',
|
||||
|
@ -571,10 +571,10 @@ WHERE logicalrelid::regclass::text LIKE 'tenant_5.%';
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT schemaid AS tenant_4_schemaid FROM pg_dist_tenant_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 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_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -585,14 +585,14 @@ $$);
|
|||
|
||||
SET client_min_messages TO WARNING;
|
||||
-- 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.
|
||||
ALTER SCHEMA tenant_4 RENAME TO "tenant\'_4";
|
||||
DROP SCHEMA "tenant\'_4", "CiTuS.TeeN_108" CASCADE;
|
||||
SET client_min_messages TO NOTICE;
|
||||
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_4_schemaid;
|
||||
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_4_schemaid;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -604,7 +604,7 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_4_colocat
|
|||
t
|
||||
(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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -617,9 +617,9 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :citus_teen_coloc
|
|||
(1 row)
|
||||
|
||||
-- (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 COUNT(*)=0 FROM pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
||||
$$);
|
||||
result
|
||||
|
@ -629,7 +629,7 @@ $$);
|
|||
(2 rows)
|
||||
|
||||
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)
|
||||
$$);
|
||||
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
|
||||
-- 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
|
||||
);
|
||||
schemaid | colocationid
|
||||
|
@ -706,13 +706,13 @@ SELECT * FROM pg_dist_tenant_schema WHERE colocationid = (
|
|||
(0 rows)
|
||||
|
||||
-- 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
|
||||
-- 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;
|
||||
CREATE TABLE tenant_5.tbl_4(a int, b text);
|
||||
-- (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';
|
||||
?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
|
||||
SELECT format(
|
||||
'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'';
|
||||
$$);',
|
||||
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
||||
|
@ -733,12 +733,12 @@ SELECT format(
|
|||
t
|
||||
(2 rows)
|
||||
|
||||
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_tenant_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 schemaid AS tenant_2_schemaid FROM pg_dist_tenant_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 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_schema WHERE schemaid::regnamespace::text = 'tenant_1' \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_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -748,7 +748,7 @@ $$);
|
|||
(2 rows)
|
||||
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -788,9 +788,9 @@ DROP OWNED BY test_non_super_user CASCADE;
|
|||
DROP ROLE test_non_super_user;
|
||||
SET client_min_messages TO NOTICE;
|
||||
-- (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.
|
||||
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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -803,10 +803,10 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_1_coloc
|
|||
(1 row)
|
||||
|
||||
-- (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.
|
||||
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)
|
||||
$$);
|
||||
result
|
||||
|
@ -847,29 +847,29 @@ $$);
|
|||
|
||||
SET citus.enable_schema_based_sharding TO ON;
|
||||
SET client_min_messages TO NOTICE;
|
||||
-- show that all schemaid values are unique and non-null in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IS NULL;
|
||||
-- show that all schemaid values are unique and non-null in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IS NULL;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_tenant_schema);
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_schema);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- show that all colocationid values are unique and non-null in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE colocationid IS NULL;
|
||||
-- show that all colocationid values are unique and non-null in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE colocationid IS NULL;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_tenant_schema);
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_schema);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
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);
|
||||
-- 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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -889,7 +889,7 @@ BEGIN;
|
|||
CREATE SCHEMA public;
|
||||
-- Show that we don't consider public schema as a tenant schema,
|
||||
-- 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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -898,7 +898,7 @@ BEGIN;
|
|||
ROLLBACK;
|
||||
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
||||
-- 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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -913,7 +913,7 @@ BEGIN;
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -936,7 +936,7 @@ BEGIN;
|
|||
CREATE TABLE tenant_8.tbl_1(a int, b text);
|
||||
CREATE TABLE tenant_8.tbl_2(a int, b text);
|
||||
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?
|
||||
---------------------------------------------------------------------
|
||||
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
|
||||
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;
|
||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_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 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_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -1017,9 +1017,9 @@ $$);
|
|||
|
||||
DROP SCHEMA tenant_9;
|
||||
-- (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.
|
||||
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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -1032,10 +1032,10 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocat
|
|||
(1 row)
|
||||
|
||||
-- (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.
|
||||
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)
|
||||
$$);
|
||||
result
|
||||
|
@ -1147,10 +1147,10 @@ SET citus.shard_count TO 32;
|
|||
SET citus.shard_replication_factor TO 1;
|
||||
SET client_min_messages TO NOTICE;
|
||||
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 colocationid AS tenant_9_colocationid 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_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -1162,8 +1162,8 @@ $$);
|
|||
DROP OWNED BY test_other_super_user;
|
||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
||||
-- pg_dist_schema and pg_dist_colocation.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
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
|
||||
-- (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 COUNT(*)=0 FROM pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||
$$);
|
||||
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);
|
||||
DROP TABLE tenant_10.tbl_2;
|
||||
CREATE SCHEMA tenant_11;
|
||||
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_tenant_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 schemaid AS tenant_11_schemaid FROM pg_dist_tenant_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 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_schema WHERE schemaid::regnamespace::text = 'tenant_10' \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_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -1249,7 +1249,7 @@ $$);
|
|||
(2 rows)
|
||||
|
||||
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'
|
||||
$$);
|
||||
result
|
||||
|
@ -1259,7 +1259,7 @@ $$);
|
|||
(2 rows)
|
||||
|
||||
-- (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?
|
||||
---------------------------------------------------------------------
|
||||
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.
|
||||
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)
|
||||
$$);
|
||||
result
|
||||
|
@ -1298,8 +1298,8 @@ SET client_min_messages TO WARNING;
|
|||
DROP SCHEMA tenant_10, tenant_11 CASCADE;
|
||||
SET client_min_messages TO NOTICE;
|
||||
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
||||
-- deletes the associated pg_dist_tenant_schema entry.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||
-- deletes the associated pg_dist_schema entry.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -1312,9 +1312,9 @@ SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid IN (:tenant_10_colo
|
|||
(1 row)
|
||||
|
||||
-- (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 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)
|
||||
$$);
|
||||
result
|
||||
|
|
|
@ -160,8 +160,8 @@ ERROR: relation "single_node_nullkey_c1_90630532" is a shard relation
|
|||
SET citus.enable_schema_based_sharding TO ON;
|
||||
CREATE SCHEMA tenant_1;
|
||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
|
|
@ -160,8 +160,8 @@ ERROR: relation "single_node_nullkey_c1_90630532" is a shard relation
|
|||
SET citus.enable_schema_based_sharding TO ON;
|
||||
CREATE SCHEMA tenant_1;
|
||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||
SELECT COUNT(*)=1 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
|
|
@ -311,8 +311,8 @@ ORDER BY 1;
|
|||
table pg_dist_placement
|
||||
table pg_dist_poolinfo
|
||||
table pg_dist_rebalance_strategy
|
||||
table pg_dist_schema
|
||||
table pg_dist_shard
|
||||
table pg_dist_tenant_schema
|
||||
table pg_dist_transaction
|
||||
type citus.distribution_type
|
||||
type citus.shard_transfer_mode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ALTER SCHEMA "tenant\'_1" RENAME TO tenant_1;
|
||||
ALTER SCHEMA "tenant\'_2" RENAME TO tenant_2;
|
||||
-- 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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -10,7 +10,7 @@ WHERE schemaid::regnamespace::text = 'tenant_1';
|
|||
|
||||
-- verify the same 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';
|
||||
$$);
|
||||
result
|
||||
|
@ -23,7 +23,7 @@ $$);
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -35,7 +35,7 @@ SELECT result FROM run_command_on_workers($$
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
$$);
|
||||
result
|
||||
|
@ -61,7 +61,7 @@ SELECT colocationid = (
|
|||
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
||||
partmethod = 'n' AND repmodel = 's'
|
||||
)
|
||||
FROM pg_dist_tenant_schema
|
||||
FROM pg_dist_schema
|
||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -73,7 +73,7 @@ SELECT colocationid = (
|
|||
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
||||
partmethod = 'n' AND repmodel = 's'
|
||||
)
|
||||
FROM pg_dist_tenant_schema
|
||||
FROM pg_dist_schema
|
||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -87,7 +87,7 @@ ALTER SCHEMA tenant_2 RENAME TO "tenant\'_2";
|
|||
SET citus.enable_schema_based_sharding TO ON;
|
||||
CREATE SCHEMA tenant_3;
|
||||
-- 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?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
|
|
@ -41,7 +41,7 @@ step "s1-schema-undistribute"
|
|||
|
||||
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"
|
||||
|
|
|
@ -199,11 +199,11 @@ SET role dummyregular;
|
|||
SELECT citus_schema_distribute('tenant1');
|
||||
|
||||
-- show the schema is a tenant schema now
|
||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_tenant_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
|
||||
SELECT colocationid AS tenant1_colocid FROM pg_dist_schema schemaid \gset
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
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');
|
||||
|
||||
-- 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
|
||||
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 $$);
|
||||
|
@ -227,10 +227,10 @@ SET role dummysuper;
|
|||
SELECT citus_schema_distribute('tenant1');
|
||||
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
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');
|
||||
|
||||
-- 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 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;
|
||||
|
||||
-- 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 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;
|
||||
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
AS verify_tenant_query \gset
|
||||
|
@ -323,7 +323,7 @@ SET client_min_messages TO WARNING;
|
|||
SELECT citus_schema_undistribute('tenant1');
|
||||
|
||||
-- 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 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"');
|
||||
|
||||
-- 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 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"%'')' ||
|
||||
'$$'
|
||||
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"');
|
||||
|
||||
-- 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 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');
|
||||
|
||||
-- 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 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%'')' ||
|
||||
'$$'
|
||||
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');
|
||||
|
||||
-- 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 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');
|
||||
|
||||
-- show the schema is a tenant schema now
|
||||
SELECT colocationid AS empty_tenant_colocid FROM pg_dist_tenant_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 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_schema USING(colocationid) $$);
|
||||
|
||||
SELECT citus_schema_undistribute('empty_tenant');
|
||||
|
||||
-- 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 || '$$'
|
||||
AS verify_empty_tenant_query \gset
|
||||
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 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';
|
||||
|
||||
-- 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;
|
||||
|
||||
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);
|
||||
|
||||
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');
|
||||
SET citus.enable_schema_based_sharding TO ON;
|
||||
|
||||
-- show that regular_schema doesn't show up in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||
-- show that regular_schema doesn't show up in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid::regnamespace::text = 'regular_schema';
|
||||
|
||||
-- empty tenant
|
||||
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;
|
||||
|
||||
-- (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');
|
||||
|
||||
-- (on workers) verify that colocation id is set for empty tenants too
|
||||
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');
|
||||
$$);
|
||||
|
||||
|
@ -92,7 +92,7 @@ WHERE logicalrelid = 'tenant_2.test_table'::regclass AND
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
|
||||
-- (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 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';
|
||||
$$);
|
||||
|
||||
|
@ -111,7 +111,7 @@ CREATE TABLE tenant_1.test_table(a int, b text);
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
|
||||
-- (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 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';
|
||||
$$);
|
||||
|
||||
-- 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');
|
||||
|
||||
-- verify that we don't allow creating tenant tables via CREATE SCHEMA command
|
||||
|
@ -322,7 +322,7 @@ SELECT COUNT(*) = 5
|
|||
FROM pg_dist_partition
|
||||
WHERE logicalrelid::text LIKE 'tenant_5.test_table_like_%' AND
|
||||
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'
|
||||
);
|
||||
|
||||
|
@ -347,11 +347,11 @@ CREATE TABLE tenant_5.tbl_2(a int, b text);
|
|||
CREATE SCHEMA "CiTuS.TeeN_108";
|
||||
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 colocationid AS citus_teen_colocationid 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_schema WHERE schemaid::regnamespace::text = 'citus_teen_proper' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
|
@ -361,7 +361,7 @@ SELECT :citus_teen_colocationid > 0;
|
|||
-- (on workers) verify that the same colocation id is used on workers too
|
||||
SELECT format(
|
||||
'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
|
||||
colocationid = %s;
|
||||
$$);',
|
||||
|
@ -394,18 +394,18 @@ WHERE logicalrelid::regclass::text LIKE 'tenant_4.%';
|
|||
SELECT COUNT(DISTINCT(colocationid))=1 FROM pg_dist_partition
|
||||
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 colocationid AS tenant_4_colocationid 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_schema WHERE schemaid::regnamespace::text = 'tenant_4' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
SET client_min_messages TO WARNING;
|
||||
|
||||
-- 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.
|
||||
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;
|
||||
|
||||
-- (on coordinator) Verify that dropping a tenant schema deletes the associated
|
||||
-- pg_dist_tenant_schema entry and pg_dist_colocation too.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_4_schemaid;
|
||||
-- pg_dist_schema entry and pg_dist_colocation too.
|
||||
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_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;
|
||||
|
||||
-- (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 COUNT(*)=0 FROM pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||
WHERE schemaid = (SELECT schemaid FROM tenant_4_schemaid)
|
||||
$$);
|
||||
|
||||
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)
|
||||
$$);
|
||||
|
||||
|
@ -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
|
||||
-- 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
|
||||
);
|
||||
|
||||
-- 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
|
||||
|
||||
-- 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);
|
||||
|
||||
-- (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';
|
||||
|
||||
-- (on workers) verify that tenant_5 is still associated with the same colocation id
|
||||
SELECT format(
|
||||
'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'';
|
||||
$$);',
|
||||
:tenant_5_old_colocationid) AS verify_workers_query \gset
|
||||
|
||||
:verify_workers_query
|
||||
|
||||
SELECT schemaid AS tenant_1_schemaid FROM pg_dist_tenant_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 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_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 colocationid AS tenant_2_colocationid 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_schema WHERE schemaid::regnamespace::text = 'tenant_2' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
|
@ -537,16 +537,16 @@ DROP ROLE test_non_super_user;
|
|||
SET client_min_messages TO NOTICE;
|
||||
|
||||
-- (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.
|
||||
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);
|
||||
|
||||
-- (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.
|
||||
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)
|
||||
$$);
|
||||
|
||||
|
@ -569,20 +569,20 @@ $$);
|
|||
SET citus.enable_schema_based_sharding TO ON;
|
||||
SET client_min_messages TO NOTICE;
|
||||
|
||||
-- show that all schemaid values are unique and non-null in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IS NULL;
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_tenant_schema);
|
||||
-- show that all schemaid values are unique and non-null in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid IS NULL;
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||
(SELECT COUNT(DISTINCT(schemaid)) FROM pg_dist_schema);
|
||||
|
||||
-- show that all colocationid values are unique and non-null in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE colocationid IS NULL;
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_tenant_schema) =
|
||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_tenant_schema);
|
||||
-- show that all colocationid values are unique and non-null in pg_dist_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE colocationid IS NULL;
|
||||
SELECT (SELECT COUNT(*) FROM pg_dist_schema) =
|
||||
(SELECT COUNT(DISTINCT(colocationid)) FROM pg_dist_schema);
|
||||
|
||||
CREATE TABLE public.cannot_be_a_tenant_table(a int, b text);
|
||||
|
||||
-- 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;
|
||||
|
||||
|
@ -592,13 +592,13 @@ BEGIN;
|
|||
|
||||
-- Show that we don't consider public schema as a tenant schema,
|
||||
-- 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;
|
||||
|
||||
CREATE TEMPORARY TABLE temp_table(a int, b text);
|
||||
|
||||
-- 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;
|
||||
|
||||
|
@ -611,7 +611,7 @@ BEGIN;
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
|
||||
-- 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);
|
||||
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.%';
|
||||
|
||||
-- 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;
|
||||
|
||||
SELECT schemaid AS tenant_9_schemaid FROM pg_dist_tenant_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 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_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
DROP SCHEMA tenant_9;
|
||||
|
||||
-- (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.
|
||||
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;
|
||||
|
||||
-- (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.
|
||||
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)
|
||||
$$);
|
||||
|
||||
|
@ -776,11 +776,11 @@ SET citus.shard_replication_factor TO 1;
|
|||
SET client_min_messages TO NOTICE;
|
||||
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 colocationid AS tenant_9_colocationid 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_schema WHERE schemaid::regnamespace::text = 'tenant_9' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
|
@ -788,15 +788,15 @@ DROP OWNED BY test_other_super_user;
|
|||
|
||||
-- (on coordinator) Make sure that dropping an empty tenant schema
|
||||
-- (via DROP OWNED BY) doesn't leave any dangling entries in
|
||||
-- pg_dist_tenant_schema and pg_dist_colocation.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid = :tenant_9_schemaid;
|
||||
-- pg_dist_schema and pg_dist_colocation.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema WHERE schemaid = :tenant_9_schemaid;
|
||||
SELECT COUNT(*)=0 FROM pg_dist_colocation WHERE colocationid = :tenant_9_colocationid;
|
||||
|
||||
-- (on workers) Make sure that dropping an empty tenant schema
|
||||
-- (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 COUNT(*)=0 FROM pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=0 FROM pg_dist_schema
|
||||
WHERE schemaid = (SELECT schemaid FROM tenant_9_schemaid)
|
||||
$$);
|
||||
|
||||
|
@ -841,29 +841,29 @@ DROP TABLE tenant_10.tbl_2;
|
|||
|
||||
CREATE SCHEMA tenant_11;
|
||||
|
||||
SELECT schemaid AS tenant_10_schemaid FROM pg_dist_tenant_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 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_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 colocationid AS tenant_11_colocationid 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_schema WHERE schemaid::regnamespace::text = 'tenant_11' \gset
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
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'
|
||||
$$);
|
||||
|
||||
-- (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);
|
||||
|
||||
-- (on workers) Verify metadata for tenant schemas that are created via non-super-user.
|
||||
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)
|
||||
$$);
|
||||
|
||||
|
@ -880,14 +880,14 @@ DROP SCHEMA tenant_10, tenant_11 CASCADE;
|
|||
SET client_min_messages TO NOTICE;
|
||||
|
||||
-- (on coordinator) Verify that dropping a tenant schema via non-super-user
|
||||
-- deletes the associated pg_dist_tenant_schema entry.
|
||||
SELECT COUNT(*)=0 FROM pg_dist_tenant_schema WHERE schemaid IN (:tenant_10_schemaid, :tenant_11_schemaid);
|
||||
-- deletes the associated pg_dist_schema entry.
|
||||
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);
|
||||
|
||||
-- (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 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)
|
||||
$$);
|
||||
|
||||
|
|
|
@ -104,8 +104,8 @@ SET citus.enable_schema_based_sharding TO ON;
|
|||
CREATE SCHEMA tenant_1;
|
||||
CREATE TABLE tenant_1.tbl_1 (a int);
|
||||
|
||||
-- verify that we recorded tenant_1 in pg_dist_tenant_schema
|
||||
SELECT COUNT(*)=1 FROM pg_dist_tenant_schema WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
-- verify that we recorded tenant_1 in pg_dist_schema
|
||||
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
|
||||
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;
|
||||
|
||||
-- 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';
|
||||
|
||||
-- verify the same 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';
|
||||
$$);
|
||||
|
||||
|
@ -15,7 +15,7 @@ $$);
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
|
||||
-- verify the same on workers
|
||||
|
@ -23,7 +23,7 @@ SELECT result FROM run_command_on_workers($$
|
|||
SELECT colocationid = (
|
||||
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';
|
||||
$$);
|
||||
|
||||
|
@ -41,7 +41,7 @@ SELECT colocationid = (
|
|||
WHERE logicalrelid = 'tenant_1.tbl_1'::regclass AND
|
||||
partmethod = 'n' AND repmodel = 's'
|
||||
)
|
||||
FROM pg_dist_tenant_schema
|
||||
FROM pg_dist_schema
|
||||
WHERE schemaid::regnamespace::text = 'tenant_1';
|
||||
|
||||
SELECT colocationid = (
|
||||
|
@ -49,7 +49,7 @@ SELECT colocationid = (
|
|||
WHERE logicalrelid = 'tenant_2.tbl_1'::regclass AND
|
||||
partmethod = 'n' AND repmodel = 's'
|
||||
)
|
||||
FROM pg_dist_tenant_schema
|
||||
FROM pg_dist_schema
|
||||
WHERE schemaid::regnamespace::text = 'tenant_2';
|
||||
|
||||
-- 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;
|
||||
|
||||
-- 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 SCHEMA tenant_3 CASCADE;
|
||||
|
|
Loading…
Reference in New Issue