From 87e8dd9e3b0e366eb597a310f229ab3e9d5f71d8 Mon Sep 17 00:00:00 2001 From: xywang Date: Mon, 7 Mar 2022 20:01:47 +0800 Subject: [PATCH] [TS-1289]: fixed error in show create stable if tag type was json --- src/tsdb/src/tsdbRead.c | 10 +++++++++- src/util/src/ttokenizer.c | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 60c7311d4c..025cafe7e9 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -4533,13 +4533,21 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { return; } + char *p = NULL; + char* str = malloc(strlen(json) + 3); + if (str) { + snprintf(str, len + 3, "'%s'", json); + } + + p = str ? str : json; int32_t length = 0; - if(!taosMbsToUcs4(json, strlen(json), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){ + if(!taosMbsToUcs4(p, strlen(p), varDataVal(tagData), bytes - VARSTR_HEADER_SIZE - CHAR_BYTES, &length)){ tsdbError("getJsonTagValueAll mbstoucs4 error! length:%d", length); } varDataSetLen(tagData, length); assert(varDataTLen(tagData) <= bytes); tfree(json); + tfree(str); } char* parseTagDatatoJson(void *p){ diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index 7cd96a8d30..93883f6451 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -573,12 +573,6 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { *tokenId = TK_ID; return i; } - case '{': { - for (i = 1; z[i] && z[i - 1] != '}'; i++) { - } - *tokenId = TK_STRING; - return i; - } case 'T': case 't': case 'F': -- GitLab