mirror of https://github.com/citusdata/citus.git
Add IsCitusTable check to citus table utilities (#4028)
parent
23d44eba9f
commit
bc011a6286
|
@ -1386,12 +1386,16 @@ EnsureHashDistributedTable(Oid relationId)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IsDistributedTable returns true if the given relation is
|
* IsHashDistributedTable returns true if the given relation is
|
||||||
* a distributed table.
|
* a distributed table.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
IsHashDistributedTable(Oid relationId)
|
IsHashDistributedTable(Oid relationId)
|
||||||
{
|
{
|
||||||
|
if (!IsCitusTable(relationId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(relationId);
|
CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(relationId);
|
||||||
char sourceDistributionMethod = sourceTableEntry->partitionMethod;
|
char sourceDistributionMethod = sourceTableEntry->partitionMethod;
|
||||||
return sourceDistributionMethod == DISTRIBUTE_BY_HASH;
|
return sourceDistributionMethod == DISTRIBUTE_BY_HASH;
|
||||||
|
|
|
@ -466,8 +466,7 @@ bool
|
||||||
IsReferenceTableRTE(Node *node)
|
IsReferenceTableRTE(Node *node)
|
||||||
{
|
{
|
||||||
Oid relationId = NodeTryGetRteRelid(node);
|
Oid relationId = NodeTryGetRteRelid(node);
|
||||||
return relationId != InvalidOid && IsCitusTable(relationId) &&
|
return relationId != InvalidOid && IsReferenceTable(relationId);
|
||||||
IsReferenceTable(relationId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,10 @@ PG_FUNCTION_INFO_V1(replicate_reference_tables);
|
||||||
bool
|
bool
|
||||||
IsReferenceTable(Oid relationId)
|
IsReferenceTable(Oid relationId)
|
||||||
{
|
{
|
||||||
|
if (!IsCitusTable(relationId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CitusTableCacheEntry *tableEntry = GetCitusTableCacheEntry(relationId);
|
CitusTableCacheEntry *tableEntry = GetCitusTableCacheEntry(relationId);
|
||||||
|
|
||||||
if (tableEntry->partitionMethod != DISTRIBUTE_BY_NONE)
|
if (tableEntry->partitionMethod != DISTRIBUTE_BY_NONE)
|
||||||
|
|
|
@ -1420,7 +1420,7 @@ SELECT tables_colocated('d2', 'none');
|
||||||
SELECT update_distributed_table_colocation('ref', colocate_with => 'none');
|
SELECT update_distributed_table_colocation('ref', colocate_with => 'none');
|
||||||
ERROR: relation ref should be a hash distributed table
|
ERROR: relation ref should be a hash distributed table
|
||||||
SELECT update_distributed_table_colocation('local_table', colocate_with => 'none');
|
SELECT update_distributed_table_colocation('local_table', colocate_with => 'none');
|
||||||
ERROR: relation local_table is not distributed
|
ERROR: relation local_table should be a hash distributed table
|
||||||
-- make sure that different types cannot be colocated
|
-- make sure that different types cannot be colocated
|
||||||
SELECT update_distributed_table_colocation('different_d1', colocate_with => 'd1');
|
SELECT update_distributed_table_colocation('different_d1', colocate_with => 'd1');
|
||||||
ERROR: cannot colocate tables d1 and different_d1
|
ERROR: cannot colocate tables d1 and different_d1
|
||||||
|
|
Loading…
Reference in New Issue