Convert DistributedTableSizeOnWorker function to new connection API

pull/1454/head
velioglu 2017-06-02 15:45:08 +03:00
parent 802ff0db2f
commit 43d2cdbd35
1 changed files with 9 additions and 3 deletions

View File

@ -190,8 +190,12 @@ DistributedTableSizeOnWorker(WorkerNode *workerNode, Oid relationId, char *sizeQ
char *workerNodeName = workerNode->workerName; char *workerNodeName = workerNode->workerName;
uint32 workerNodePort = workerNode->workerPort; uint32 workerNodePort = workerNode->workerPort;
char *tableSizeString; char *tableSizeString;
List *sizeList = NIL;
uint64 tableSize = 0; uint64 tableSize = 0;
MultiConnection *connection = NULL;
uint32 connectionFlag = FORCE_NEW_CONNECTION;
PGresult *result = NULL;
int queryResult = 0;
List *sizeList = NIL;
List *shardIntervalsOnNode = ShardIntervalsOnWorkerNode(workerNode, relationId); List *shardIntervalsOnNode = ShardIntervalsOnWorkerNode(workerNode, relationId);
@ -199,14 +203,16 @@ DistributedTableSizeOnWorker(WorkerNode *workerNode, Oid relationId, char *sizeQ
shardIntervalsOnNode, shardIntervalsOnNode,
sizeQuery); sizeQuery);
sizeList = ExecuteRemoteQuery(workerNodeName, workerNodePort, NULL, tableSizeQuery); connection = GetNodeConnection(connectionFlag, workerNodeName, workerNodePort);
queryResult = ExecuteOptionalRemoteCommand(connection, tableSizeQuery->data, &result);
if (sizeList == NIL) if (queryResult != 0)
{ {
ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("cannot get the size because of a connection error"))); errmsg("cannot get the size because of a connection error")));
} }
sizeList = ReadFirstColumnAsText(result);
tableSizeStringInfo = (StringInfo) linitial(sizeList); tableSizeStringInfo = (StringInfo) linitial(sizeList);
tableSizeString = tableSizeStringInfo->data; tableSizeString = tableSizeStringInfo->data;
tableSize = atol(tableSizeString); tableSize = atol(tableSizeString);