From 6190cb08b49b85517deb7e59089cf20551e5f512 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 1 May 2021 23:47:40 +0800 Subject: [PATCH] Hotfix/sangshuduo/td 4054 taosdump compile error for develop (#5999) * [TD-4054]: taosdump wrong column note length. * [TD-4054]: taosdump wrong column note length. reserve 2 bytes for NCHAR. --- src/kit/taosdump/taosdump.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 96a1cd16f8..0dca591b04 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -99,11 +99,13 @@ enum _describe_table_index { TSDB_MAX_DESCRIBE_METRIC }; +#define COL_NOTE_LEN 128 + typedef struct { char field[TSDB_COL_NAME_LEN + 1]; char type[16]; int length; - char note[128]; + char note[COL_NOTE_LEN]; } SColDes; typedef struct { @@ -1188,16 +1190,16 @@ int taosGetTableDes(char* dbName, char *table, STableDef *tableDes, TAOS* taosCo case TSDB_DATA_TYPE_BINARY: { memset(tableDes->cols[i].note, 0, sizeof(tableDes->cols[i].note)); tableDes->cols[i].note[0] = '\''; - char tbuf[COMMAND_SIZE]; - converStringToReadable((char *)row[0], length[0], tbuf, COMMAND_SIZE); + char tbuf[COL_NOTE_LEN]; + converStringToReadable((char *)row[0], length[0], tbuf, COL_NOTE_LEN); char* pstr = stpcpy(&(tableDes->cols[i].note[1]), tbuf); *(pstr++) = '\''; break; } case TSDB_DATA_TYPE_NCHAR: { memset(tableDes->cols[i].note, 0, sizeof(tableDes->cols[i].note)); - char tbuf[COMMAND_SIZE]; - convertNCharToReadable((char *)row[0], length[0], tbuf, COMMAND_SIZE); + char tbuf[COL_NOTE_LEN-2]; // need reserve 2 bytes for ' ' + convertNCharToReadable((char *)row[0], length[0], tbuf, COL_NOTE_LEN); sprintf(tableDes->cols[i].note, "\'%s\'", tbuf); break; } -- GitLab