Exclude reference tables

update-dist-col-for-undistributed-tables
Ahmet Gedemenli 2022-02-17 11:05:37 +03:00
parent 141dc237ce
commit 7519e628e9
1 changed files with 27 additions and 18 deletions

View File

@ -401,10 +401,15 @@ CreateDistributedTable(Oid relationId, Var *distributionColumn, char distributio
*/
List *originalForeignKeyRecreationCommands = NIL;
if (IsCitusTableType(relationId, CITUS_LOCAL_TABLE))
{
char *distributionColumnName = NULL;
if (distributionMethod != DISTRIBUTE_BY_NONE)
{
/* save the column name to update the distribution column var later */
char *distributionColumnName =
distributionColumnName =
ColumnToColumnName(relationId, nodeToString(distributionColumn));
}
/* store foreign key creation commands that relation is involved */
originalForeignKeyRecreationCommands =
@ -412,11 +417,14 @@ CreateDistributedTable(Oid relationId, Var *distributionColumn, char distributio
INCLUDE_ALL_TABLE_TYPES);
relationId = DropFKeysAndUndistributeTable(relationId);
/* exclude reference tables */
if (distributionMethod != DISTRIBUTE_BY_NONE)
{
/*
* Because we create a new table when undistributing the table, attribute numbers
* might be changed, because of the dropped columns. To make sure we have the
* correct distribution column, we need to build it again, using the original
* column name that we have saved before.
* Because we create a new table when undistributing the table, attribute
* numbers might be changed, because of the dropped columns. To make sure we
* have the correct distribution column, we need to build it again, using the
* original column name that we have saved before.
*/
Relation relation = try_relation_open(relationId, ExclusiveLock);
if (relation == NULL)
@ -430,6 +438,7 @@ CreateDistributedTable(Oid relationId, Var *distributionColumn, char distributio
distributionColumn = BuildDistributionKeyFromColumnName(relation,
distributionColumnName);
}
}
/*
* To support foreign keys between reference tables and local tables,