From 04e0600907201707df4cfcf18ed9420d3eccbede Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 18 Jul 2019 18:40:32 +0800 Subject: [PATCH] Fix the issue #108, limit does not have effects on the results --- src/client/src/tscAsync.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 51c93778ba..ef90b184a0 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -112,19 +112,19 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf // sequentially retrieve data from remain vnodes first, query vnode specified by vnodeIdx if (numOfRows == 0 && tscProjectionQueryOnMetric(pSql)) { // vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx - assert(pSql->cmd.vnodeIdx >= 1); + assert(pCmd->vnodeIdx >= 1); /* reach the maximum number of output rows, abort */ - if (pSql->cmd.defaultVal[0] > 0 && pRes->numOfTotal >= pCmd->defaultVal[0]) { + if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) { (*pSql->fetchFp)(param, tres, 0); return; } /* update the limit value according to current retrieval results */ - pCmd->limit.limit = pSql->cmd.defaultVal[0] - pRes->numOfTotal; + pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal; - if ((++(pSql->cmd.vnodeIdx)) <= pSql->cmd.pMetricMeta->numOfVnodes) { - pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first. + if ((++(pSql->cmd.vnodeIdx)) <= pCmd->pMetricMeta->numOfVnodes) { + pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first. pRes->row = 0; pRes->numOfRows = 0; @@ -134,8 +134,7 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf tscProcessSql(pSql); return; } - } else { - /* localreducer has handle this situation */ + } else { // localreducer has handle this situation if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC) { pRes->numOfTotal += pRes->numOfRows; } @@ -268,19 +267,19 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) { /* * vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx till all vnode have been retrieved */ - assert(pSql->cmd.vnodeIdx >= 1); + assert(pCmd->vnodeIdx >= 1); /* reach the maximum number of output rows, abort */ - if (pSql->cmd.defaultVal[0] > 0 && pRes->numOfTotal >= pCmd->defaultVal[0]) { + if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) { (*pSql->fetchFp)(pSql->param, pSql, NULL); return; } /* update the limit value according to current retrieval results */ - pCmd->limit.limit = pSql->cmd.defaultVal[0] - pRes->numOfTotal; + pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal; - if ((++pSql->cmd.vnodeIdx) <= pSql->cmd.pMetricMeta->numOfVnodes) { - pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first. + if ((++pCmd->vnodeIdx) <= pCmd->pMetricMeta->numOfVnodes) { + pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first. pRes->row = 0; pRes->numOfRows = 0; -- GitLab