From 7f53d257ba9183b22f3a9b1441ca92d8606690ea Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 24 Jan 2022 09:01:09 +0800 Subject: [PATCH] (query):fix bugs of substr --- src/common/src/texpr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 9f0cf8ca49..e54ffd5f49 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -1610,7 +1610,7 @@ void vectorSubstrFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t num continue; } - int16_t strBytes = varDataLen(pInputs[0].data); + int16_t strBytes = varDataLen(inputData); int32_t resultStartBytes = 0; if (subPosChar > 0) { int32_t subPosBytes = (pInputs[0].type == TSDB_DATA_TYPE_BINARY) ? subPosChar-1 : (subPosChar-1) * TSDB_NCHAR_SIZE; @@ -1629,7 +1629,7 @@ void vectorSubstrFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t num varDataSetLen(outputData, resultLenBytes); if (resultLenBytes > 0) { - memcpy(varDataVal(outputData), varDataVal(inputData), resultLenBytes); + memcpy(varDataVal(outputData), varDataVal(inputData) + resultStartBytes, resultLenBytes); } } } -- GitLab