From cccd035cbb1dfd29237172202d1c609a0e711f33 Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Mon, 25 Oct 2021 17:21:23 +0300 Subject: [PATCH] Check autoConverted for the input relation only --- .../utils/foreign_key_relationship.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/backend/distributed/utils/foreign_key_relationship.c b/src/backend/distributed/utils/foreign_key_relationship.c index a63840d5f..8ae0dd7f2 100644 --- a/src/backend/distributed/utils/foreign_key_relationship.c +++ b/src/backend/distributed/utils/foreign_key_relationship.c @@ -146,6 +146,16 @@ GetForeignKeyConnectedRelationIdList(Oid relationId) bool ShouldUndistributeCitusLocalTable(Oid relationId) { + CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(relationId); + if (!cacheEntry->autoConverted) + { + /* + * The relation is not added to metadata automatically, + * we shouldn't undistribute it. + */ + return false; + } + /* * As we will operate on foreign key connected relations, here we * invalidate foreign key graph so that we act on fresh graph. @@ -171,15 +181,6 @@ ShouldUndistributeCitusLocalTable(Oid relationId) */ return false; } - CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(relationOid); - if (!cacheEntry->autoConverted) - { - /* - * The relation is connected to a (or, is a) Citus Local Table created - * by the user. We shouldn't undistribute it. - */ - return false; - } } return true;