Fix the issue #108, limit does not have effects on the results

This commit is contained in:
slguan 2019-07-18 18:40:32 +08:00
parent 6917618198
commit 04e0600907
1 changed files with 11 additions and 12 deletions

View File

@ -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 // sequentially retrieve data from remain vnodes first, query vnode specified by vnodeIdx
if (numOfRows == 0 && tscProjectionQueryOnMetric(pSql)) { if (numOfRows == 0 && tscProjectionQueryOnMetric(pSql)) {
// vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx // 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 */ /* 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); (*pSql->fetchFp)(param, tres, 0);
return; return;
} }
/* update the limit value according to current retrieval results */ /* 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) { if ((++(pSql->cmd.vnodeIdx)) <= pCmd->pMetricMeta->numOfVnodes) {
pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first. pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first.
pRes->row = 0; pRes->row = 0;
pRes->numOfRows = 0; pRes->numOfRows = 0;
@ -134,8 +134,7 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
tscProcessSql(pSql); tscProcessSql(pSql);
return; return;
} }
} else { } else { // localreducer has handle this situation
/* localreducer has handle this situation */
if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC) { if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC) {
pRes->numOfTotal += pRes->numOfRows; 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 * 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 */ /* 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); (*pSql->fetchFp)(pSql->param, pSql, NULL);
return; return;
} }
/* update the limit value according to current retrieval results */ /* 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) { if ((++pCmd->vnodeIdx) <= pCmd->pMetricMeta->numOfVnodes) {
pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first. pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first.
pRes->row = 0; pRes->row = 0;
pRes->numOfRows = 0; pRes->numOfRows = 0;