From 493e267623dc51ece4b077ea54db28201c166141 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 14 Jan 2022 14:34:40 +0800 Subject: [PATCH] [TD-12945](query): taos shell crash when constant comparison cause crash --- src/query/src/qSqlParser.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 9f5f036e6c..c554652214 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -320,7 +320,8 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { if ((pLeft != NULL && pRight != NULL) && (optrType == TK_PLUS || optrType == TK_MINUS || optrType == TK_STAR || optrType == TK_DIVIDE || optrType == TK_REM || - optrType == TK_EQ || optrType == TK_NE || optrType == TK_LT || optrType == TK_GT || optrType == TK_LE || optrType == TK_GE)) { + optrType == TK_EQ || optrType == TK_NE || optrType == TK_LT || optrType == TK_GT || optrType == TK_LE || optrType == TK_GE || + optrType == TK_AND || optrType == TK_OR)) { /* * if a exprToken is noted as the TK_TIMESTAMP, the time precision is microsecond * Otherwise, the time precision is adaptive, determined by the time precision from databases. @@ -386,6 +387,14 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { pExpr->value.i64 = (pLeft->value.i64 >= pRight->value.i64) ? 1 : 0; break; } + case TK_AND: { + pExpr->value.i64 = (pLeft->value.i64 && pRight->value.i64) ? 1 : 0; + break; + } + case TK_OR: { + pExpr->value.i64 = (pLeft->value.i64 || pRight->value.i64) ? 1 : 0; + break; + } } tSqlExprDestroy(pLeft); @@ -483,6 +492,18 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { } break; } + case TK_AND: { + pExpr->tokenId = TK_INTEGER; + pExpr->value.nType = TSDB_DATA_TYPE_BIGINT; + pExpr->value.i64 = (left && right) ? 1 : 0; + break; + } + case TK_OR: { + pExpr->tokenId = TK_INTEGER; + pExpr->value.nType = TSDB_DATA_TYPE_BIGINT; + pExpr->value.i64 = (left && right) ? 1 : 0; + break; + } } tSqlExprDestroy(pLeft); -- GitLab