Add a function to delete shard metadata from MX nodes

pull/1145/head
Metin Doslu 2017-01-19 18:18:57 +02:00
parent 93e626c896
commit 2bd8f8f12e
2 changed files with 33 additions and 1 deletions

View File

@ -513,7 +513,7 @@ TableOwnerResetCommand(Oid relationId)
/* /*
* ShardListInsertCommand generates a singe command that can be * ShardListInsertCommand generates a single command that can be
* executed to replicate shard and shard placement metadata for the * executed to replicate shard and shard placement metadata for the
* given shard intervals. The function assumes that each shard has a * given shard intervals. The function assumes that each shard has a
* single placement, and asserts this information. * single placement, and asserts this information.
@ -634,6 +634,37 @@ ShardListInsertCommand(List *shardIntervalList)
} }
/*
* ShardListDeleteCommand generates a command list that can be executed to delete
* shard and shard placement metadata for the given shard.
*/
List *
ShardDeleteCommandList(ShardInterval *shardInterval)
{
uint64 shardId = shardInterval->shardId;
List *commandList = NIL;
StringInfo deletePlacementCommand = NULL;
StringInfo deleteShardCommand = NULL;
/* create command to delete shard placements */
deletePlacementCommand = makeStringInfo();
appendStringInfo(deletePlacementCommand,
"DELETE FROM pg_dist_shard_placement WHERE shardid = %lu",
shardId);
commandList = lappend(commandList, deletePlacementCommand->data);
/* create command to delete shard */
deleteShardCommand = makeStringInfo();
appendStringInfo(deleteShardCommand,
"DELETE FROM pg_dist_shard WHERE shardid = %lu", shardId);
commandList = lappend(commandList, deleteShardCommand->data);
return commandList;
}
/* /*
* NodeDeleteCommand generate a command that can be * NodeDeleteCommand generate a command that can be
* executed to delete the metadata for a worker node. * executed to delete the metadata for a worker node.

View File

@ -28,6 +28,7 @@ extern char * DistributionDeleteCommand(char *schemaName,
extern char * TableOwnerResetCommand(Oid distributedRelationId); extern char * TableOwnerResetCommand(Oid distributedRelationId);
extern char * NodeListInsertCommand(List *workerNodeList); extern char * NodeListInsertCommand(List *workerNodeList);
extern List * ShardListInsertCommand(List *shardIntervalList); extern List * ShardListInsertCommand(List *shardIntervalList);
extern List * ShardDeleteCommandList(ShardInterval *shardInterval);
extern char * NodeDeleteCommand(uint32 nodeId); extern char * NodeDeleteCommand(uint32 nodeId);
extern char * ColocationIdUpdateCommand(Oid relationId, uint32 colocationId); extern char * ColocationIdUpdateCommand(Oid relationId, uint32 colocationId);
extern char * CreateSchemaDDLCommand(Oid schemaId); extern char * CreateSchemaDDLCommand(Oid schemaId);