From 622016c08ecc5f173f742953e22a991e2fddf68a Mon Sep 17 00:00:00 2001 From: EmelSimsek Date: Tue, 19 Mar 2024 14:30:56 +0300 Subject: [PATCH] Refactor --- .../utils/multi_partitioning_utils.c | 52 +++---------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/src/backend/distributed/utils/multi_partitioning_utils.c b/src/backend/distributed/utils/multi_partitioning_utils.c index 88a99241c..b435056f2 100644 --- a/src/backend/distributed/utils/multi_partitioning_utils.c +++ b/src/backend/distributed/utils/multi_partitioning_utils.c @@ -736,51 +736,15 @@ WorkerFixPartitionShardIndexNamesCommandListForPartitionIndex(Oid partitionIndex partitionSchemaName, partitionName); - List *partitionShardIntervalList = LoadShardIntervalList(partitionId); - ShardInterval *partitionShardInterval = NULL; - foreach_ptr(partitionShardInterval, partitionShardIntervalList) - { - /* - * Prepare commands for each shard of current partition - * to fix the index name that corresponds to the - * current parent index name - */ - uint64 partitionShardId = partitionShardInterval->shardId; - - List *activePlacementList = ActiveShardPlacementList(partitionShardId); - - if ((list_length(activePlacementList) > 0) && (list_length(shardPlacements) > 0)) - { - ShardPlacement *left = (ShardPlacement *) linitial(activePlacementList); - ShardPlacement *right = (ShardPlacement *) linitial(shardPlacements); - - if (left->nodeId != right->nodeId) - { - continue; - } - } - - /* get qualified partition shard name */ - char *partitionShardName = pstrdup(partitionName); - AppendShardIdToName(&partitionShardName, partitionShardId); - char *qualifiedPartitionShardName = quote_qualified_identifier( - partitionSchemaName, - partitionShardName); - - /* generate the new correct index name */ - char *newPartitionShardIndexName = pstrdup(partitionIndexName); - AppendShardIdToName(&newPartitionShardIndexName, partitionShardId); - - /* create worker_fix_partition_shard_index_names command */ - StringInfo shardQueryString = makeStringInfo(); - appendStringInfo(shardQueryString, - "SELECT worker_fix_partition_shard_index_names(%s::regclass, %s, %s)", - quote_literal_cstr(qualifiedParentShardIndexName), - quote_literal_cstr(partitionIndexName), - quote_literal_cstr(qualifiedPartitionName)); - commandList = lappend(commandList, shardQueryString->data); - } + /* create worker_fix_partition_shard_index_names command */ + StringInfo shardQueryString = makeStringInfo(); + appendStringInfo(shardQueryString, + "SELECT worker_fix_partition_shard_index_names(%s::regclass, %s, %s)", + quote_literal_cstr(qualifiedParentShardIndexName), + quote_literal_cstr(partitionIndexName), + quote_literal_cstr(qualifiedPartitionName)); + commandList = lappend(commandList, shardQueryString->data); return commandList; }