mirror of https://github.com/citusdata/citus.git
Prevent citus local table creation from a catalog table (#4158)
parent
e7079d1384
commit
4118560b75
|
@ -202,6 +202,8 @@ ErrorIfUnsupportedCreateCitusLocalTable(Relation relation)
|
||||||
"not exist")));
|
"not exist")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorIfTableIsACatalogTable(relation);
|
||||||
|
|
||||||
Oid relationId = relation->rd_id;
|
Oid relationId = relation->rd_id;
|
||||||
|
|
||||||
ErrorIfCoordinatorNotAddedAsWorkerNode();
|
ErrorIfCoordinatorNotAddedAsWorkerNode();
|
||||||
|
|
|
@ -683,12 +683,7 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
TupleDesc relationDesc = RelationGetDescr(relation);
|
TupleDesc relationDesc = RelationGetDescr(relation);
|
||||||
char *relationName = RelationGetRelationName(relation);
|
char *relationName = RelationGetRelationName(relation);
|
||||||
|
|
||||||
if (relation->rd_rel->relnamespace == PG_CATALOG_NAMESPACE)
|
ErrorIfTableIsACatalogTable(relation);
|
||||||
{
|
|
||||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("cannot distribute catalog tables")));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!RelationUsesHeapAccessMethodOrNone(relation))
|
if (!RelationUsesHeapAccessMethodOrNone(relation))
|
||||||
{
|
{
|
||||||
|
@ -834,6 +829,23 @@ EnsureRelationCanBeDistributed(Oid relationId, Var *distributionColumn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ErrorIfTableIsACatalogTable is a helper function to error out for citus
|
||||||
|
* table creation from a catalog table.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ErrorIfTableIsACatalogTable(Relation relation)
|
||||||
|
{
|
||||||
|
if (relation->rd_rel->relnamespace != PG_CATALOG_NAMESPACE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|
errmsg("cannot create a citus table from a catalog table")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EnsureTableCanBeColocatedWith checks whether a given replication model and
|
* EnsureTableCanBeColocatedWith checks whether a given replication model and
|
||||||
* distribution column type is suitable to distribute a table to be colocated
|
* distribution column type is suitable to distribute a table to be colocated
|
||||||
|
|
|
@ -153,6 +153,7 @@ extern void EnsureHashDistributedTable(Oid relationId);
|
||||||
extern void EnsureSequenceOwner(Oid sequenceOid);
|
extern void EnsureSequenceOwner(Oid sequenceOid);
|
||||||
extern void EnsureFunctionOwner(Oid functionId);
|
extern void EnsureFunctionOwner(Oid functionId);
|
||||||
extern void EnsureSuperUser(void);
|
extern void EnsureSuperUser(void);
|
||||||
|
extern void ErrorIfTableIsACatalogTable(Relation relation);
|
||||||
extern void EnsureTableNotDistributed(Oid relationId);
|
extern void EnsureTableNotDistributed(Oid relationId);
|
||||||
extern void EnsureReplicationSettings(Oid relationId, char replicationModel);
|
extern void EnsureReplicationSettings(Oid relationId, char replicationModel);
|
||||||
extern bool RegularTable(Oid relationId);
|
extern bool RegularTable(Oid relationId);
|
||||||
|
|
|
@ -654,6 +654,9 @@ FROM (SELECT tableName FROM pg_catalog.pg_tables WHERE tablename LIKE 'citus_loc
|
||||||
f | t
|
f | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- cannot create a citus local table from a catalog table
|
||||||
|
SELECT create_citus_local_table('pg_class');
|
||||||
|
ERROR: cannot create a citus table from a catalog table
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA citus_local_tables_test_schema, "CiTUS!LocalTables" CASCADE;
|
DROP SCHEMA citus_local_tables_test_schema, "CiTUS!LocalTables" CASCADE;
|
||||||
NOTICE: drop cascades to 18 other objects
|
NOTICE: drop cascades to 18 other objects
|
||||||
|
|
|
@ -319,6 +319,6 @@ DROP TABLE data_load_test1, data_load_test2;
|
||||||
END;
|
END;
|
||||||
-- distributing catalog tables is not supported
|
-- distributing catalog tables is not supported
|
||||||
SELECT create_distributed_table('pg_class', 'relname');
|
SELECT create_distributed_table('pg_class', 'relname');
|
||||||
ERROR: cannot distribute catalog tables
|
ERROR: cannot create a citus table from a catalog table
|
||||||
SELECT create_reference_table('pg_class');
|
SELECT create_reference_table('pg_class');
|
||||||
ERROR: cannot distribute catalog tables
|
ERROR: cannot create a citus table from a catalog table
|
||||||
|
|
|
@ -442,5 +442,8 @@ SELECT relation_is_a_known_shard('citus_local_table_4');
|
||||||
SELECT citus_table_is_visible(tableName::regclass::oid), relation_is_a_known_shard(tableName::regclass)
|
SELECT citus_table_is_visible(tableName::regclass::oid), relation_is_a_known_shard(tableName::regclass)
|
||||||
FROM (SELECT tableName FROM pg_catalog.pg_tables WHERE tablename LIKE 'citus_local_table_4_%') as tableName;
|
FROM (SELECT tableName FROM pg_catalog.pg_tables WHERE tablename LIKE 'citus_local_table_4_%') as tableName;
|
||||||
|
|
||||||
|
-- cannot create a citus local table from a catalog table
|
||||||
|
SELECT create_citus_local_table('pg_class');
|
||||||
|
|
||||||
-- cleanup at exit
|
-- cleanup at exit
|
||||||
DROP SCHEMA citus_local_tables_test_schema, "CiTUS!LocalTables" CASCADE;
|
DROP SCHEMA citus_local_tables_test_schema, "CiTUS!LocalTables" CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue