提交 5bba58b4 编写于 作者: G Ganlin Zhao

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

上级 5b88295e
......@@ -4658,6 +4658,7 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr,
int32_t rightType = SQLEXPR_TYPE_UNASSIGNED;
const char* msg1 = "arithmetic expression composed with columns from different tables";
const char* msg2 = "arithmetic expression composed with functions/columns of different types";
const char* msg3 = "comparison/logical expression involving string operands is not supported";
int32_t leftHeight = 0;
int32_t ret = validateSQLExprItem(pCmd, pExpr->pLeft, pQueryInfo, pList, &leftType, &uidLeft, &leftHeight);
if (ret != TSDB_CODE_SUCCESS) {
......@@ -4690,6 +4691,17 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr,
} else if (leftType == SQLEXPR_TYPE_SCALAR || rightType == SQLEXPR_TYPE_SCALAR){
*type = SQLEXPR_TYPE_SCALAR;
}
// comparison/logical operations
if (pExpr->tokenId == TK_EQ || pExpr->tokenId == TK_NE ||
pExpr->tokenId == TK_GT || pExpr->tokenId == TK_GE ||
pExpr->tokenId == TK_LT || pExpr->tokenId == TK_LE ||
pExpr->tokenId == TK_AND || pExpr->tokenId == TK_OR) {
if ((leftType == SQLEXPR_TYPE_VALUE && pExpr->pLeft->tokenId == TK_STRING) ||
(rightType == SQLEXPR_TYPE_VALUE && pExpr->pRight->tokenId == TK_STRING)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
}
}
return TSDB_CODE_SUCCESS;
}
......@@ -4743,6 +4755,9 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr,
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
if (pExpr->tokenId == TK_STRING) {
}
if (pExpr->type == SQL_NODE_VALUE) {
*type = SQLEXPR_TYPE_VALUE;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册