未验证 提交 b2001183 编写于 作者: H Haojun Liao 提交者: GitHub

Merge pull request #10424 from taosdata/fix/TS-1215-D

[TS-1215]<fix>(query): memcpy with real length of data on DESC
......@@ -3058,12 +3058,18 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
char *pData = GET_INPUT_DATA_LIST(pCtx);
if (pCtx->order == TSDB_ORDER_ASC) {
// ASC
int32_t numOfRows = (pCtx->param[0].i64 == 1)? 1:pCtx->size;
memcpy(pCtx->pOutput, pData, (size_t) numOfRows * pCtx->inputBytes);
} else {
// DESC
for(int32_t i = 0; i < pCtx->size; ++i) {
memcpy(pCtx->pOutput + (pCtx->size - 1 - i) * pCtx->inputBytes, pData + i * pCtx->inputBytes,
pCtx->inputBytes);
char* dst = pCtx->pOutput + (pCtx->size - 1 - i) * pCtx->inputBytes;
char* src = pData + i * pCtx->inputBytes;
if (IS_VAR_DATA_TYPE(pCtx->inputType))
varDataCopy(dst, src);
else
memcpy(dst, src, pCtx->inputBytes);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册