mirror of https://github.com/citusdata/citus.git
Exclude partitions when doing undistribute_table
parent
844b3ea4df
commit
b3b75fecbc
|
@ -32,6 +32,7 @@
|
||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
|
|
||||||
|
static List * RemovePartitionRelationIds(List *relationIdList);
|
||||||
static void EnsureSequentialModeForCitusTableCascadeFunction(List *relationIdList);
|
static void EnsureSequentialModeForCitusTableCascadeFunction(List *relationIdList);
|
||||||
static void LockRelationsWithLockMode(List *relationIdList, LOCKMODE lockMode);
|
static void LockRelationsWithLockMode(List *relationIdList, LOCKMODE lockMode);
|
||||||
static List * GetFKeyCreationCommandsForRelationIdList(List *relationIdList);
|
static List * GetFKeyCreationCommandsForRelationIdList(List *relationIdList);
|
||||||
|
@ -73,6 +74,17 @@ CascadeOperationForConnectedRelations(Oid relationId, LOCKMODE lockMode,
|
||||||
|
|
||||||
LockRelationsWithLockMode(fKeyConnectedRelationIdList, lockMode);
|
LockRelationsWithLockMode(fKeyConnectedRelationIdList, lockMode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We shouldn't cascade through foreign keys on partition tables, unless the
|
||||||
|
* operation is creating Citus Local Tables, as citus
|
||||||
|
* table functions already have their own logics to handle partition relations.
|
||||||
|
*/
|
||||||
|
if (cascadeOperationType != CASCADE_FKEY_ADD_LOCAL_TABLE_TO_METADATA)
|
||||||
|
{
|
||||||
|
fKeyConnectedRelationIdList =
|
||||||
|
RemovePartitionRelationIds(fKeyConnectedRelationIdList);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Our foreign key subgraph can have distributed tables which might already
|
* Our foreign key subgraph can have distributed tables which might already
|
||||||
* be modified in current transaction. So switch to sequential execution
|
* be modified in current transaction. So switch to sequential execution
|
||||||
|
@ -150,6 +162,30 @@ ErrorIfAnyPartitionRelationInvolvedInNonInheritedFKey(List *relationIdList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RemovePartitionRelationIds returns a list of relation id's by removing
|
||||||
|
* partition relation id's from given relationIdList.
|
||||||
|
*/
|
||||||
|
static List *
|
||||||
|
RemovePartitionRelationIds(List *relationIdList)
|
||||||
|
{
|
||||||
|
List *nonPartitionRelationIdList = NIL;
|
||||||
|
|
||||||
|
Oid relationId = InvalidOid;
|
||||||
|
foreach_oid(relationId, relationIdList)
|
||||||
|
{
|
||||||
|
if (PartitionTable(relationId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nonPartitionRelationIdList = lappend_oid(nonPartitionRelationIdList, relationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nonPartitionRelationIdList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EnsureSequentialModeForCitusTableCascadeFunction switches to sequential
|
* EnsureSequentialModeForCitusTableCascadeFunction switches to sequential
|
||||||
* execution mode if needed. If it's not possible, then errors out.
|
* execution mode if needed. If it's not possible, then errors out.
|
||||||
|
|
Loading…
Reference in New Issue