Fix the bug by adding comma before the values

pull/5382/head
Halil Ozan Akgul 2021-10-15 18:42:23 +03:00
parent b576e69260
commit e3446692f3
1 changed files with 11 additions and 10 deletions

View File

@ -923,6 +923,7 @@ ShardListInsertCommand(List *shardIntervalList)
"shardlength, groupid, placementid) AS (VALUES "); "shardlength, groupid, placementid) AS (VALUES ");
ShardInterval *shardInterval = NULL; ShardInterval *shardInterval = NULL;
bool isFirstValue = true;
foreach_ptr(shardInterval, shardIntervalList) foreach_ptr(shardInterval, shardIntervalList)
{ {
uint64 shardId = shardInterval->shardId; uint64 shardId = shardInterval->shardId;
@ -931,6 +932,16 @@ ShardListInsertCommand(List *shardIntervalList)
ShardPlacement *placement = NULL; ShardPlacement *placement = NULL;
foreach_ptr(placement, shardPlacementList) foreach_ptr(placement, shardPlacementList)
{ {
if (!isFirstValue)
{
/*
* As long as this is not the first placement of the first shard,
* append the comma.
*/
appendStringInfo(insertPlacementCommand, ", ");
}
isFirstValue = false;
appendStringInfo(insertPlacementCommand, appendStringInfo(insertPlacementCommand,
"(%ld, %d, %ld, %d, %ld)", "(%ld, %d, %ld, %d, %ld)",
shardId, shardId,
@ -938,16 +949,6 @@ ShardListInsertCommand(List *shardIntervalList)
placement->shardLength, placement->shardLength,
placement->groupId, placement->groupId,
placement->placementId); placement->placementId);
if (!(llast(shardPlacementList) == placement &&
llast(shardIntervalList) == shardInterval))
{
/*
* As long as this is not the last placement of the last shard,
* append the comma.
*/
appendStringInfo(insertPlacementCommand, ", ");
}
} }
} }