提交 810be533 编写于 作者: G Ganlin Zhao

fix(query): fix state operator check

上级 3bcd669f
...@@ -1132,9 +1132,9 @@ static bool validateStateOper(const SValueNode* pVal) { ...@@ -1132,9 +1132,9 @@ static bool validateStateOper(const SValueNode* pVal) {
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) { if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
return false; return false;
} }
return (0 == strcasecmp(varDataVal(pVal->datum.p), "GT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "GE") || return (0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
0 == strcasecmp(varDataVal(pVal->datum.p), "LT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "LE") || 0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
0 == strcasecmp(varDataVal(pVal->datum.p), "EQ") || 0 == strcasecmp(varDataVal(pVal->datum.p), "NE")); 0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
} }
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
......
...@@ -4416,17 +4416,17 @@ bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { ...@@ -4416,17 +4416,17 @@ bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
static int8_t getStateOpType(char* opStr) { static int8_t getStateOpType(char* opStr) {
int8_t opType; int8_t opType;
if (strcasecmp(opStr, "LT") == 0) { if (strncasecmp(opStr, "LT", 2) == 0) {
opType = STATE_OPER_LT; opType = STATE_OPER_LT;
} else if (strcasecmp(opStr, "GT") == 0) { } else if (strncasecmp(opStr, "GT", 2) == 0) {
opType = STATE_OPER_GT; opType = STATE_OPER_GT;
} else if (strcasecmp(opStr, "LE") == 0) { } else if (strncasecmp(opStr, "LE", 2) == 0) {
opType = STATE_OPER_LE; opType = STATE_OPER_LE;
} else if (strcasecmp(opStr, "GE") == 0) { } else if (strncasecmp(opStr, "GE", 2) == 0) {
opType = STATE_OPER_GE; opType = STATE_OPER_GE;
} else if (strcasecmp(opStr, "NE") == 0) { } else if (strncasecmp(opStr, "NE", 2) == 0) {
opType = STATE_OPER_NE; opType = STATE_OPER_NE;
} else if (strcasecmp(opStr, "EQ") == 0) { } else if (strncasecmp(opStr, "EQ", 2) == 0) {
opType = STATE_OPER_EQ; opType = STATE_OPER_EQ;
} else { } else {
opType = STATE_OPER_INVALID; opType = STATE_OPER_INVALID;
......
...@@ -2470,17 +2470,17 @@ typedef enum { ...@@ -2470,17 +2470,17 @@ typedef enum {
static int8_t getStateOpType(char* opStr) { static int8_t getStateOpType(char* opStr) {
int8_t opType; int8_t opType;
if (strcasecmp(opStr, "LT") == 0) { if (strncasecmp(opStr, "LT", 2) == 0) {
opType = STATE_OPER_LT; opType = STATE_OPER_LT;
} else if (strcasecmp(opStr, "GT") == 0) { } else if (strncasecmp(opStr, "GT", 2) == 0) {
opType = STATE_OPER_GT; opType = STATE_OPER_GT;
} else if (strcasecmp(opStr, "LE") == 0) { } else if (strncasecmp(opStr, "LE", 2) == 0) {
opType = STATE_OPER_LE; opType = STATE_OPER_LE;
} else if (strcasecmp(opStr, "GE") == 0) { } else if (strncasecmp(opStr, "GE", 2) == 0) {
opType = STATE_OPER_GE; opType = STATE_OPER_GE;
} else if (strcasecmp(opStr, "NE") == 0) { } else if (strncasecmp(opStr, "NE", 2) == 0) {
opType = STATE_OPER_NE; opType = STATE_OPER_NE;
} else if (strcasecmp(opStr, "EQ") == 0) { } else if (strncasecmp(opStr, "EQ", 2) == 0) {
opType = STATE_OPER_EQ; opType = STATE_OPER_EQ;
} else { } else {
opType = STATE_OPER_INVALID; opType = STATE_OPER_INVALID;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册