diff --git a/src/backend/distributed/metadata/metadata_utility.c b/src/backend/distributed/metadata/metadata_utility.c index c5b4e0b7a..135f1434f 100644 --- a/src/backend/distributed/metadata/metadata_utility.c +++ b/src/backend/distributed/metadata/metadata_utility.c @@ -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. */ bool IsHashDistributedTable(Oid relationId) { + if (!IsCitusTable(relationId)) + { + return false; + } CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(relationId); char sourceDistributionMethod = sourceTableEntry->partitionMethod; return sourceDistributionMethod == DISTRIBUTE_BY_HASH; diff --git a/src/backend/distributed/planner/multi_logical_planner.c b/src/backend/distributed/planner/multi_logical_planner.c index b6de5b569..ed792ba43 100644 --- a/src/backend/distributed/planner/multi_logical_planner.c +++ b/src/backend/distributed/planner/multi_logical_planner.c @@ -466,8 +466,7 @@ bool IsReferenceTableRTE(Node *node) { Oid relationId = NodeTryGetRteRelid(node); - return relationId != InvalidOid && IsCitusTable(relationId) && - IsReferenceTable(relationId); + return relationId != InvalidOid && IsReferenceTable(relationId); } diff --git a/src/backend/distributed/utils/reference_table_utils.c b/src/backend/distributed/utils/reference_table_utils.c index ab9ee54cd..71eae9696 100644 --- a/src/backend/distributed/utils/reference_table_utils.c +++ b/src/backend/distributed/utils/reference_table_utils.c @@ -64,6 +64,10 @@ PG_FUNCTION_INFO_V1(replicate_reference_tables); bool IsReferenceTable(Oid relationId) { + if (!IsCitusTable(relationId)) + { + return false; + } CitusTableCacheEntry *tableEntry = GetCitusTableCacheEntry(relationId); if (tableEntry->partitionMethod != DISTRIBUTE_BY_NONE) diff --git a/src/test/regress/expected/multi_colocation_utils.out b/src/test/regress/expected/multi_colocation_utils.out index a4996fa96..cea7003e9 100644 --- a/src/test/regress/expected/multi_colocation_utils.out +++ b/src/test/regress/expected/multi_colocation_utils.out @@ -1420,7 +1420,7 @@ SELECT tables_colocated('d2', 'none'); SELECT update_distributed_table_colocation('ref', colocate_with => 'none'); ERROR: relation ref should be a hash distributed table 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 SELECT update_distributed_table_colocation('different_d1', colocate_with => 'd1'); ERROR: cannot colocate tables d1 and different_d1