From a32ee46d139acb92046a43d9885b659f1cb51a2c Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 1 May 2020 23:21:36 +0800 Subject: [PATCH] [td-168] --- src/client/src/tscUtil.c | 9 ++++++++- src/tsdb/src/tsdbRead.c | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index dd654cdbd9..f3f72d40d9 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2126,6 +2126,13 @@ char* tscGetResultColumnChr(SSqlRes* pRes, SQueryInfo* pQueryInfo, int32_t colum SFieldInfo* pFieldInfo = &pQueryInfo->fieldsInfo; SFieldSupInfo* pInfo = tscFieldInfoGetSupp(pFieldInfo, column); - return ((char*) pRes->data) + pInfo->pSqlExpr->offset * pRes->numOfRows; + int32_t type = pInfo->pSqlExpr->resType; + char* pData = ((char*) pRes->data) + pInfo->pSqlExpr->offset * pRes->numOfRows; + + if (type != TSDB_DATA_TYPE_NCHAR && type != TSDB_DATA_TYPE_BINARY) { + return pData; + } else { + return pData + sizeof(int16_t); // head is the length of binary/nchar data + } } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 1e0d8e1609..fde15129ca 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -595,6 +595,10 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf } int32_t start = MIN(cur->pos, endPos); + +// if (start > 0) { +// tdPopDataColsPoints(pQueryHandle->rhelper.pDataCols[0], start); +// } // move the data block in the front to data block if needed int32_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle); @@ -604,12 +608,20 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf for (int32_t j = 0; j < numOfCols; ++j) { SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, j); + int32_t bytes = pCol->info.bytes; if (pCol->info.colId == colId) { - memmove(pCol->pData, &pQueryHandle->rhelper.pDataCols[0]->cols[i], - sizeof(SDataCol) + pQueryHandle->rhelper.pDataCols[0]->cols[i].len); - - tdPopDataColsPoints(pCol->pData, start); + if (pCol->info.type != TSDB_DATA_TYPE_BINARY && pCol->info.type != TSDB_DATA_TYPE_NCHAR) { + memmove(pCol->pData, pQueryHandle->rhelper.pDataCols[0]->cols[i].pData + bytes * start, + bytes * pQueryHandle->realNumOfRows); + } else { + SDataCol* src = &pQueryHandle->rhelper.pDataCols[0]->cols[i]; + + for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) { + char* p = tdGetColDataOfRow(src, k); + memcpy(pCol->pData + k * bytes, p, *(int16_t*) p + sizeof(int16_t)); // todo refactor + } + } break; } }