From 1d77a5b0d1793d6384ab272730a8a04a53035a76 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 23 Jul 2021 14:19:19 +0800 Subject: [PATCH] [TD-5484]:nchar/binary tag length exceed limit error when alter table --- src/query/src/qSqlParser.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 874ec7b692..eb920b3e17 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -712,9 +712,8 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { } else { int32_t bytes = -(int32_t)(type->type); if (bytes > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - // we have to postpone reporting the error because it cannot be done here - // as pField->bytes is int16_t, use 'TSDB_MAX_NCHAR_LEN + 1' to avoid overflow - bytes = TSDB_MAX_NCHAR_LEN + 1; + // overflowed. set bytes to -1 so that error can be reported + bytes = -1; } else { bytes = bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; } @@ -727,8 +726,8 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { } else { int32_t bytes = -(int32_t)(type->type); if (bytes > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { - // refer comment for NCHAR above - bytes = TSDB_MAX_BINARY_LEN + 1; + // overflowed. set bytes to -1 so that error can be reported + bytes = -1; } else { bytes += VARSTR_HEADER_SIZE; } -- GitLab