From 566a9462b85a97532ac73ca848de77c227efd2c3 Mon Sep 17 00:00:00 2001 From: Metin Doslu Date: Mon, 21 Mar 2016 10:05:59 -0700 Subject: [PATCH] Send binary footers to all shards --- src/backend/distributed/commands/multi_copy.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index d84865889..7fa8fe80f 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -154,6 +154,8 @@ CitusCopyFrom(CopyStmt *copyStatement, char *completionTag) char partitionMethod = '\0'; Var *partitionColumn = NULL; HTAB *shardConnectionHash = NULL; + HASH_SEQ_STATUS status; + ShardConnections *shardConnections = NULL; List *connectionList = NIL; MemoryContext tupleContext = NULL; CopyState copyState = NULL; @@ -170,7 +172,6 @@ CitusCopyFrom(CopyStmt *copyStatement, char *completionTag) int shardCount = 0; uint64 processedRowCount = 0; ErrorContextCallback errorCallback; - ShardConnections *shardConnections = NULL; CopyOutState copyOutState = NULL; FmgrInfo *columnOutputFunctions = NULL; @@ -379,10 +380,16 @@ CitusCopyFrom(CopyStmt *copyStatement, char *completionTag) MemoryContextReset(tupleContext); } - if (shardConnections != NULL) + /* send binary footers to all shards */ + hash_seq_init(&status, shardConnectionHash); + + shardConnections = (ShardConnections *) hash_seq_search(&status); + while (shardConnections != NULL) { CopySendBinaryFooters(copyOutState); SendCopyDataToPlacements(copyOutState->fe_msgbuf, shardConnections); + + shardConnections = (ShardConnections *) hash_seq_search(&status); } connectionList = ConnectionList(shardConnectionHash);