Merge pull request #24622 from taosdata/fix/xsren/TD-28457/stateCountFuncArgsCheck

fix: statecount function checkou arg full equal
This commit is contained in:
dapan1121 2024-01-25 16:51:39 +08:00 committed by GitHub
commit dc9d5e5a08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -1305,10 +1305,13 @@ static bool validateStateOper(const SValueNode* pVal) {
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
return false;
}
return (
0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
if (strlen(varDataVal(pVal->datum.p)) == 2) {
return (
0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) ||
0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) ||
0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2));
}
return false;
}
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {

View File

@ -103,6 +103,10 @@ class TDTestCase:
f"select statecount(c1 ,'GT',1) , min(c1) from {dbname}.t1",
f"select statecount(c1 ,'GT',1) , spread(c1) from {dbname}.t1",
f"select statecount(c1 ,'GT',1) , diff(c1) from {dbname}.t1",
f"select statecount(c1 ,'GTA',1) , diff(c1) from {dbname}.t1",
f"select statecount(c1 ,'EQA',1) , diff(c1) from {dbname}.t1",
f"select statecount(c1 ,'',1) , diff(c1) from {dbname}.t1",
f"select statecount(c1 ,'E',1) , diff(c1) from {dbname}.t1",
]
for error_sql in error_sql_lists:
tdSql.error(error_sql)