From dfd3402797ee52e0a2bdae2884d44cc6b4747372 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Wed, 26 Feb 2020 17:43:08 +0800 Subject: [PATCH] fix invalid write when assign the ip address at the client side. --- src/client/src/tscAsync.c | 18 +++++++++++++++--- src/client/src/tscServer.c | 4 +++- src/client/src/tscUtil.c | 3 +++ src/system/detail/src/vnodeQueryProcess.c | 6 ------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index f4e0788f56..9a85fbf8f6 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -283,8 +283,15 @@ void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRows) { return; } - for (int i = 0; i < pCmd->numOfCols; ++i) - pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pRes->bytes[i] * pRes->row; + for (int i = 0; i < pCmd->numOfCols; ++i){ + SSqlExpr* pExpr = pQueryInfo->fieldsInfo.pSqlExpr[i]; + if (pExpr != NULL) { + pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pExpr->resBytes * pRes->row; + } else { + //todo add + } + } + pRes->row++; (*pSql->fetchFp)(pSql->param, pSql, pSql->res.tsrow); @@ -298,7 +305,12 @@ void tscProcessFetchRow(SSchedMsg *pMsg) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); for (int i = 0; i < pCmd->numOfCols; ++i) { - pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pRes->bytes[i] * pRes->row; + SSqlExpr* pExpr = pQueryInfo->fieldsInfo.pSqlExpr[i]; + if (pExpr != NULL) { + pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i) + pExpr->resBytes * pRes->row; + } else { + //todo add + } } pRes->row++; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index ca6c5ad236..9599d280ea 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -231,7 +231,7 @@ void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) { SSqlCmd * pCmd = &pSql->cmd; SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, pCmd->clauseIndex, 0); - + if (UTIL_METER_IS_SUPERTABLE(pMeterMetaInfo)) { // multiple vnode query SVnodeSidList *vnodeList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, pMeterMetaInfo->vnodeIndex); if (vnodeList != NULL) { @@ -254,6 +254,8 @@ void tscGetConnToVnode(SSqlObj *pSql, uint8_t *pCode) { while (pSql->retry < pSql->maxRetry) { (pSql->retry)++; + pSql->index = pSql->index%TSDB_VNODES_SUPPORT; + char ipstr[40] = {0}; if (pVPeersDesc[pSql->index].ip == 0) { /* diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 6dcf27b1d7..fd6210ee56 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -203,6 +203,9 @@ SMeterSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx) { tscError("illegal sidIdx:%d, reset to 0, sidIdx range:%d-%d", idx, 0, sidRange); idx = 0; } + + assert(pSidList->pSidExtInfoList[idx] >= 0); + return (SMeterSidExtInfo*)(pSidList->pSidExtInfoList[idx] + (char*)pSidList); } diff --git a/src/system/detail/src/vnodeQueryProcess.c b/src/system/detail/src/vnodeQueryProcess.c index c52a27713e..213e837f0c 100644 --- a/src/system/detail/src/vnodeQueryProcess.c +++ b/src/system/detail/src/vnodeQueryProcess.c @@ -947,12 +947,6 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) { dTrace("QInfo:%p main scan completed, elapsed time: %lldms, supplementary scan start, order:%d", pQInfo, et - st, pQuery->order.order ^ 1); - // failed to save all intermediate results into disk, abort further query processing - // if (doCloseAllOpenedResults(pSupporter) != TSDB_CODE_SUCCESS) { - // dError("QInfo:%p failed to save intermediate results, abort further query processing", pQInfo); - // return; - // } - if (pQuery->intervalTime > 0) { for (int32_t i = 0; i < pSupporter->numOfMeters; ++i) { SMeterQueryInfo *pMeterQueryInfo = pSupporter->pMeterDataInfo[i].pMeterQInfo; -- GitLab