From 0953983d268fef7bc3b0514eccfbc734679d1b0d Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 30 Aug 2024 09:16:41 +0800 Subject: [PATCH] fix: validate to_iso8601 parameters --- source/libs/function/src/builtins.c | 8 ++++++-- tests/system-test/2-query/To_iso8601.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index a93ae8e574..bff7d6804b 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -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"); } diff --git a/tests/system-test/2-query/To_iso8601.py b/tests/system-test/2-query/To_iso8601.py index 24865ada88..89924a009e 100644 --- a/tests/system-test/2-query/To_iso8601.py +++ b/tests/system-test/2-query/To_iso8601.py @@ -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")