Undistributed removed sequences while undistributing table

velioglu/wo_seq_test_1
Burak Velioglu 2021-12-22 20:26:02 +03:00
parent 81a6cb47d6
commit 6705f0c612
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
1 changed files with 12 additions and 3 deletions

View File

@ -195,7 +195,7 @@ static void CreateDistributedTableLike(TableConversionState *con);
static void CreateCitusTableLike(TableConversionState *con); static void CreateCitusTableLike(TableConversionState *con);
static List * GetViewCreationCommandsOfTable(Oid relationId); static List * GetViewCreationCommandsOfTable(Oid relationId);
static void ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands, static void ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands,
bool suppressNoticeMessages); bool suppressNoticeMessages, char conversionType);
static bool HasAnyGeneratedStoredColumns(Oid relationId); static bool HasAnyGeneratedStoredColumns(Oid relationId);
static List * GetNonGeneratedStoredColumnNameList(Oid relationId); static List * GetNonGeneratedStoredColumnNameList(Oid relationId);
static void CheckAlterDistributedTableConversionParameters(TableConversionState *con); static void CheckAlterDistributedTableConversionParameters(TableConversionState *con);
@ -741,7 +741,7 @@ ConvertTable(TableConversionState *con)
} }
ReplaceTable(con->relationId, con->newRelationId, justBeforeDropCommands, ReplaceTable(con->relationId, con->newRelationId, justBeforeDropCommands,
con->suppressNoticeMessages); con->suppressNoticeMessages, con->conversionType);
TableDDLCommand *tableConstructionCommand = NULL; TableDDLCommand *tableConstructionCommand = NULL;
foreach_ptr(tableConstructionCommand, postLoadCommands) foreach_ptr(tableConstructionCommand, postLoadCommands)
@ -1296,7 +1296,7 @@ GetViewCreationCommandsOfTable(Oid relationId)
*/ */
void void
ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands, ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands,
bool suppressNoticeMessages) bool suppressNoticeMessages, char conversionType)
{ {
char *sourceName = get_rel_name(sourceId); char *sourceName = get_rel_name(sourceId);
char *targetName = get_rel_name(targetId); char *targetName = get_rel_name(targetId);
@ -1354,6 +1354,15 @@ ReplaceTable(Oid sourceId, Oid targetId, List *justBeforeDropCommands,
changeDependencyFor(RelationRelationId, sequenceOid, changeDependencyFor(RelationRelationId, sequenceOid,
RelationRelationId, sourceId, targetId); RelationRelationId, sourceId, targetId);
// Changing the dependency for sequence will prevent PG to have
// sequence within drop trigger
if (conversionType == UNDISTRIBUTE_TABLE)
{
ObjectAddress sequenceAddress = { 0 };
ObjectAddressSet(sequenceAddress, RelationRelationId, sequenceOid);
UnmarkObjectDistributed(&sequenceAddress);
}
/* /*
* Skip if we cannot sync metadata for target table. * Skip if we cannot sync metadata for target table.
* Checking only for the target table is sufficient since we will * Checking only for the target table is sufficient since we will