Merge pull request #2599 from citusdata/fix_fk_from_partition_to_reference

Fix partitioned table operations involving foreign key to reference table
pull/2598/head
Murat Tuncer 2019-01-28 17:01:43 +03:00 committed by GitHub
commit 913cac2391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -1185,6 +1185,26 @@ SetupExecutionModeForAlterTable(Oid relationId, AlterTableCmd *command)
{
executeSequentially = true;
}
/*
* Postgres performs additional selects when creating constraints
* on partitioned tables. We need to set execution mode to
* sequential for the select query so that ddl connections
* we open does not fail due to previous select.
*/
if (executeSequentially && PartitionedTable(relationId))
{
SetLocalMultiShardModifyModeToSequential();
}
}
}
else if (alterTableType == AT_DetachPartition)
{
/* check if there are foreign constraints to reference tables */
if (HasForeignKeyToReferenceTable(relationId))
{
executeSequentially = true;
SetLocalMultiShardModifyModeToSequential();
}
}