Merge pull request #27557 from taosdata/fix/TS-5340

fix: validate to_iso8601 parameters
This commit is contained in:
Pan Wei 2024-08-30 13:36:25 +08:00 committed by GitHub
commit e1079f3704
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -2426,8 +2426,12 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
// param1
if (numOfParams == 2) {
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1);
SNode* pNode = (SNode*)nodesListGetNode(pFunc->pParameterList, 1);
if (QUERY_NODE_VALUE != nodeType(pNode)) {
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "Not supported timzone format");
}
SValueNode* pValue = (SValueNode*)pNode;
if (!validateTimezoneFormat(pValue)) {
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "Invalid timzone format");
}

View File

@ -146,6 +146,7 @@ class TDTestCase:
err_param = [1.5,'a','c2']
for i in err_param:
tdSql.error(f"select to_iso8601({i}) from db.ntb")
tdSql.error(f"select to_iso8601(ts, timezone()) from db.stb")
tdSql.query("select to_iso8601(now) from db.stb")
tdSql.checkRows(3)
tdSql.query("select to_iso8601(now()) from db.stb")