From b3444b584f8cf4e18e709599e35980fb9898c025 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 21 Apr 2021 10:06:21 +0800 Subject: [PATCH] [td-3874] : enable the value of UINT64_MAX-1 to be the valid tag values. --- src/common/src/tvariant.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 7009c4d5c3..7798deaa60 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -48,8 +48,12 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { case TSDB_DATA_TYPE_INT:{ ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true); if (ret != 0) { - pVar->nType = -1; // -1 means error type - return; + // data overflow, try unsigned parse the input number + ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, false); + if (ret != 0) { + pVar->nType = -1; // -1 means error type + return; + } } break; @@ -525,6 +529,8 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result } bool code = false; + + uint64_t ui = 0; switch(type) { case TSDB_DATA_TYPE_TINYINT: code = IS_VALID_TINYINT(*result); break; @@ -535,13 +541,17 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result case TSDB_DATA_TYPE_BIGINT: code = IS_VALID_BIGINT(*result); break; case TSDB_DATA_TYPE_UTINYINT: - code = IS_VALID_UTINYINT(*result); break; + ui = *result; + code = IS_VALID_UTINYINT(ui); break; case TSDB_DATA_TYPE_USMALLINT: - code = IS_VALID_USMALLINT(*result); break; + ui = *result; + code = IS_VALID_USMALLINT(ui); break; case TSDB_DATA_TYPE_UINT: - code = IS_VALID_UINT(*result); break; + ui = *result; + code = IS_VALID_UINT(ui); break; case TSDB_DATA_TYPE_UBIGINT: - code = IS_VALID_UBIGINT(*result); break; + ui = *result; + code = IS_VALID_UBIGINT(ui); break; } return code? 0:-1; -- GitLab