fix(query): fix to_ISO8601 function crash when processing constant
illegal inputs TD-15211
This commit is contained in:
parent
b2ff536050
commit
b556d1fa62
|
@ -1267,6 +1267,29 @@ static bool validateMinuteRange(int8_t hour, int8_t minute, char sign) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool validateTimestampDigits(const SValueNode* pVal) {
|
||||||
|
if (IS_INTEGER_TYPE(pVal->node.resType.type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t tsVal = pVal->datum.i;
|
||||||
|
char fraction[20] = {0};
|
||||||
|
NUM_TO_STRING(pVal->node.resType.type, &tsVal, sizeof(fraction), fraction);
|
||||||
|
int32_t tsDigits = (int32_t)strlen(fraction);
|
||||||
|
|
||||||
|
if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS ||
|
||||||
|
tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS ||
|
||||||
|
tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool validateTimezoneFormat(const SValueNode* pVal) {
|
static bool validateTimezoneFormat(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;
|
||||||
|
@ -1379,6 +1402,15 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QUERY_NODE_VALUE == nodeType(nodesListGetNode(pFunc->pParameterList, 0))) {
|
||||||
|
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
|
||||||
|
if (!validateTimestampDigits(pValue)) {
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = 0, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// param1
|
// param1
|
||||||
if (numOfParams == 2) {
|
if (numOfParams == 2) {
|
||||||
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1);
|
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1);
|
||||||
|
|
Loading…
Reference in New Issue