提交 493e2676 编写于 作者: G Ganlin Zhao

[TD-12945]<fix>(query): taos shell crash when constant comparison cause crash

上级 5b3692db
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册