mirror of https://github.com/citusdata/citus.git
Dont auto-undistribute user-added citus local tables - Refactor
parent
f4297f774a
commit
2cfac21382
|
@ -95,7 +95,7 @@ static void IncrementUtilityHookCountersIfNecessary(Node *parsetree);
|
|||
static void PostStandardProcessUtility(Node *parsetree);
|
||||
static void DecrementUtilityHookCountersIfNecessary(Node *parsetree);
|
||||
static bool IsDropSchemaOrDB(Node *parsetree);
|
||||
static bool ShouldUndistributeCitusLocalTables(void);
|
||||
static bool ShouldCheckUndistributeCitusLocalTables(void);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -271,7 +271,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
* can happen due to various kinds of drop commands, we immediately
|
||||
* undistribute them at the end of the command.
|
||||
*/
|
||||
if (ShouldUndistributeCitusLocalTables())
|
||||
if (ShouldCheckUndistributeCitusLocalTables())
|
||||
{
|
||||
UndistributeDisconnectedCitusLocalTables();
|
||||
}
|
||||
|
@ -687,7 +687,8 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
|
|||
/*
|
||||
* UndistributeDisconnectedCitusLocalTables undistributes citus local tables that
|
||||
* are not connected to any reference tables via their individual foreign key
|
||||
* subgraphs.
|
||||
* subgraphs. Note that this function undistributes only the auto-converted tables,
|
||||
* i.e the ones that are converted by Citus by cascading through foreign keys.
|
||||
*/
|
||||
void
|
||||
UndistributeDisconnectedCitusLocalTables(void)
|
||||
|
@ -720,7 +721,7 @@ UndistributeDisconnectedCitusLocalTables(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ConnectedToReferenceTableViaFKey(citusLocalTableId))
|
||||
if (!ShouldUndistributeCitusLocalTable(citusLocalTableId))
|
||||
{
|
||||
/* still connected to a reference table, skip it */
|
||||
UnlockRelationOid(citusLocalTableId, lockMode);
|
||||
|
@ -751,11 +752,11 @@ UndistributeDisconnectedCitusLocalTables(void)
|
|||
|
||||
|
||||
/*
|
||||
* ShouldUndistributeCitusLocalTables returns true if we might need to check
|
||||
* citus local tables for their connectivity to reference tables.
|
||||
* ShouldCheckUndistributeCitusLocalTables returns true if we might need to check
|
||||
* citus local tables for undistributing automatically.
|
||||
*/
|
||||
static bool
|
||||
ShouldUndistributeCitusLocalTables(void)
|
||||
ShouldCheckUndistributeCitusLocalTables(void)
|
||||
{
|
||||
if (!ConstraintDropped)
|
||||
{
|
||||
|
|
|
@ -139,11 +139,12 @@ GetForeignKeyConnectedRelationIdList(Oid relationId)
|
|||
|
||||
|
||||
/*
|
||||
* ConnectedToReferenceTableViaFKey returns true if given relationId is
|
||||
* connected to a reference table via its foreign key subgraph.
|
||||
* ShouldUndistributeCitusLocalTable returns true if given relationId needs
|
||||
* to be undistributed. Here we do not undistribute table if it's converted by the user,
|
||||
* or connected to a table converted by the user, or a reference table, via foreign keys.
|
||||
*/
|
||||
bool
|
||||
ConnectedToReferenceTableViaFKey(Oid relationId)
|
||||
ShouldUndistributeCitusLocalTable(Oid relationId)
|
||||
{
|
||||
/*
|
||||
* As we will operate on foreign key connected relations, here we
|
||||
|
@ -152,7 +153,16 @@ ConnectedToReferenceTableViaFKey(Oid relationId)
|
|||
InvalidateForeignKeyGraph();
|
||||
|
||||
List *fkeyConnectedRelations = GetForeignKeyConnectedRelationIdList(relationId);
|
||||
return RelationIdListHasReferenceTable(fkeyConnectedRelations);
|
||||
Oid relationOid = InvalidOid;
|
||||
foreach_oid(relationOid, fkeyConnectedRelations)
|
||||
{
|
||||
if (IsCitusTableType(relationOid, REFERENCE_TABLE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "nodes/primnodes.h"
|
||||
|
||||
extern List * GetForeignKeyConnectedRelationIdList(Oid relationId);
|
||||
extern bool ConnectedToReferenceTableViaFKey(Oid relationId);
|
||||
extern bool ShouldUndistributeCitusLocalTable(Oid relationId);
|
||||
extern List * ReferencedRelationIdList(Oid relationId);
|
||||
extern List * ReferencingRelationIdList(Oid relationId);
|
||||
extern void SetForeignConstraintRelationshipGraphInvalid(void);
|
||||
|
|
Loading…
Reference in New Issue