From a721d0d23e19c4e38ae6ca2a7a1b773eb725d2ea Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 12 Sep 2019 15:30:48 +0800 Subject: [PATCH] fix the issue #504 --- src/client/src/tscSql.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index d1436df448..594164da6b 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -457,7 +457,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { // projection query on metric, pipeline retrieve data from vnode list, instead // of two-stage mergevnodeProcessMsgFromShell free qhandle nRows = taos_fetch_block_impl(res, rows); - if (*rows == NULL && tscProjectionQueryOnMetric(pSql)) { + while (*rows == NULL && tscProjectionQueryOnMetric(pSql)) { /* reach the maximum number of output rows, abort */ if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) { return 0; @@ -465,6 +465,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { /* update the limit value according to current retrieval results */ pCmd->limit.limit = pSql->cmd.globalLimit - pRes->numOfTotal; + pCmd->limit.offset = pRes->offset; if ((++pSql->cmd.vnodeIdx) <= pSql->cmd.pMetricMeta->numOfVnodes) { pSql->cmd.command = TSDB_SQL_SELECT; @@ -472,6 +473,11 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { tscProcessSql(pSql); nRows = taos_fetch_block_impl(res, rows); } + + // check!!! + if (*rows != NULL || pCmd->vnodeIdx >= pCmd->pMetricMeta->numOfVnodes) { + break; + } } return nRows; -- GitLab