From 99be2d9b06b8c3be836cf53aceb79a4d17c75dc6 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 9 Sep 2020 09:46:17 +0800 Subject: [PATCH] fix td-1309 --- src/client/src/tscSQLParser.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 48980fefb6..a4ef7f410c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2739,27 +2739,31 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } } + int32_t retVal = TSDB_CODE_SUCCESS; if (pExpr->nSQLOptr == TK_LE || pExpr->nSQLOptr == TK_LT) { - tVariantDump(&pRight->val, (char*)&pColumnFilter->upperBndd, colType, false); - } else { // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd - if (colType == TSDB_DATA_TYPE_BINARY) { - pColumnFilter->pz = (int64_t)calloc(1, pRight->val.nLen + TSDB_NCHAR_SIZE); - pColumnFilter->len = pRight->val.nLen; + retVal = tVariantDump(&pRight->val, (char*)&pColumnFilter->upperBndd, colType, false); - tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); - } else if (colType == TSDB_DATA_TYPE_NCHAR) { - // pRight->val.nLen + 1 is larger than the actual nchar string length - pColumnFilter->pz = (int64_t)calloc(1, (pRight->val.nLen + 1) * TSDB_NCHAR_SIZE); + // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd + } else if (colType == TSDB_DATA_TYPE_BINARY) { + pColumnFilter->pz = (int64_t)calloc(1, pRight->val.nLen + TSDB_NCHAR_SIZE); + pColumnFilter->len = pRight->val.nLen; + retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); - tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); + } else if (colType == TSDB_DATA_TYPE_NCHAR) { + // pRight->val.nLen + 1 is larger than the actual nchar string length + pColumnFilter->pz = (int64_t)calloc(1, (pRight->val.nLen + 1) * TSDB_NCHAR_SIZE); + retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); + size_t len = twcslen((wchar_t*)pColumnFilter->pz); + pColumnFilter->len = len * TSDB_NCHAR_SIZE; - size_t len = twcslen((wchar_t*)pColumnFilter->pz); - pColumnFilter->len = len * TSDB_NCHAR_SIZE; - } else { - tVariantDump(&pRight->val, (char*)&pColumnFilter->lowerBndd, colType, false); - } + } else { + retVal = tVariantDump(&pRight->val, (char*)&pColumnFilter->lowerBndd, colType, false); } + if (retVal != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); + } + switch (pExpr->nSQLOptr) { case TK_LE: pColumnFilter->upperRelOptr = TSDB_RELATION_LESS_EQUAL; -- GitLab