pull/6029/head
Nitish Upreti 2022-06-27 22:24:23 -07:00
parent 928fa56558
commit 529f1bc8e3
2 changed files with 37 additions and 22 deletions

View File

@ -231,7 +231,8 @@ ShardCopyDestReceiverStartup(DestReceiver *dest, int operation, TupleDesc
/* define how tuples will be serialised */
CopyOutState copyOutState = (CopyOutState) palloc0(sizeof(CopyOutStateData));
copyOutState->binary = EnableBinaryProtocol && CanUseBinaryCopyFormat(inputTupleDescriptor);
copyOutState->binary = EnableBinaryProtocol && CanUseBinaryCopyFormat(
inputTupleDescriptor);
copyOutState->null_print = (char *) nullPrintCharacter;
copyOutState->null_print_client = (char *) nullPrintCharacter;
copyOutState->fe_msgbuf = makeStringInfo();

View File

@ -31,12 +31,16 @@ typedef struct SplitCopyInfo
static void ParseSplitCopyInfoDatum(Datum splitCopyInfoDatum,
SplitCopyInfo **splitCopyInfo);
static DestReceiver** CreateShardCopyDestReceivers(EState *estate, ShardInterval *shardIntervalToSplitCopy, List *splitCopyInfoList);
static DestReceiver* CreatePartitionedSplitCopyDestReceiver(
EState *executor,
ShardInterval *shardIntervalToSplitCopy,
static DestReceiver ** CreateShardCopyDestReceivers(EState *estate,
ShardInterval *
shardIntervalToSplitCopy,
List *splitCopyInfoList);
static void BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray, ArrayType **maxValueArray);
static DestReceiver * CreatePartitionedSplitCopyDestReceiver(EState *executor,
ShardInterval *
shardIntervalToSplitCopy,
List *splitCopyInfoList);
static void BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray,
ArrayType **maxValueArray);
/*
* worker_split_copy(source_shard_id bigint, splitCopyInfo citus.split_copy_info[])
@ -145,7 +149,8 @@ ParseSplitCopyInfoDatum(Datum splitCopyInfoDatum, SplitCopyInfo **splitCopyInfo)
/* Build 'min/max' hash range arrays for PartitionedResultDestReceiver */
static void
BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray, ArrayType **maxValueArray)
BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray,
ArrayType **maxValueArray)
{
int partitionCount = list_length(splitCopyInfoList);
@ -167,8 +172,10 @@ BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray, Array
index++;
}
*minValueArray = CreateArrayFromDatums(minValues, minValueNulls, partitionCount, TEXTOID);
*maxValueArray = CreateArrayFromDatums(maxValues, maxValueNulls, partitionCount, TEXTOID);
*minValueArray = CreateArrayFromDatums(minValues, minValueNulls, partitionCount,
TEXTOID);
*maxValueArray = CreateArrayFromDatums(maxValues, maxValueNulls, partitionCount,
TEXTOID);
}
@ -178,9 +185,11 @@ BuildMinMaxRangeArrays(List *splitCopyInfoList, ArrayType **minValueArray, Array
* that fall under its min/max range, to specified destination shard.
*/
static DestReceiver **
CreateShardCopyDestReceivers(EState *estate, ShardInterval *shardIntervalToSplitCopy, List *splitCopyInfoList)
CreateShardCopyDestReceivers(EState *estate, ShardInterval *shardIntervalToSplitCopy,
List *splitCopyInfoList)
{
DestReceiver **shardCopyDests = palloc0(splitCopyInfoList->length * sizeof(DestReceiver *));
DestReceiver **shardCopyDests = palloc0(splitCopyInfoList->length *
sizeof(DestReceiver *));
SplitCopyInfo *splitCopyInfo = NULL;
int index = 0;
@ -188,7 +197,8 @@ CreateShardCopyDestReceivers(EState *estate, ShardInterval *shardIntervalToSplit
foreach_ptr(splitCopyInfo, splitCopyInfoList)
{
char *destinationShardSchemaName = get_namespace_name(get_rel_namespace(
shardIntervalToSplitCopy->relationId));
shardIntervalToSplitCopy
->relationId));
char *destinationShardNameCopy = pstrdup(sourceShardNamePrefix);
AppendShardIdToName(&destinationShardNameCopy, splitCopyInfo->destinationShardId);
@ -207,7 +217,9 @@ CreateShardCopyDestReceivers(EState *estate, ShardInterval *shardIntervalToSplit
/* Create PartitionedSplitCopyDestReceiver along with underlying ShardCopyDestReceivers */
static DestReceiver *
CreatePartitionedSplitCopyDestReceiver(EState *estate, ShardInterval *shardIntervalToSplitCopy, List *splitCopyInfoList)
CreatePartitionedSplitCopyDestReceiver(EState *estate,
ShardInterval *shardIntervalToSplitCopy,
List *splitCopyInfoList)
{
/* Create underlying ShardCopyDestReceivers */
DestReceiver **shardCopyDestReceivers = CreateShardCopyDestReceivers(
@ -219,8 +231,10 @@ CreatePartitionedSplitCopyDestReceiver(EState *estate, ShardInterval *shardInter
ArrayType *minValuesArray = NULL;
ArrayType *maxValuesArray = NULL;
BuildMinMaxRangeArrays(splitCopyInfoList, &minValuesArray, &maxValuesArray);
char partitionMethod = PartitionMethodViaCatalog(shardIntervalToSplitCopy->relationId);
CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(shardIntervalToSplitCopy->relationId);
char partitionMethod = PartitionMethodViaCatalog(
shardIntervalToSplitCopy->relationId);
CitusTableCacheEntry *cacheEntry = GetCitusTableCacheEntry(
shardIntervalToSplitCopy->relationId);
Var *partitionColumn = cacheEntry->partitionColumn;
CitusTableCacheEntry *shardSearchInfo =