diff --git a/source/client/inc/clientSml.h b/source/client/inc/clientSml.h index 15d91641a4..311260e3fb 100644 --- a/source/client/inc/clientSml.h +++ b/source/client/inc/clientSml.h @@ -184,6 +184,7 @@ typedef struct { SSmlLineInfo *lines; // element is SSmlLineInfo bool parseJsonByLib; SArray *tagJsonArray; + SArray *valueJsonArray; // SArray *preLineTagKV; diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index f25456999b..e21fcd64b8 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -1072,6 +1072,12 @@ void smlDestroyInfo(SSmlHandle *info) { } taosArrayDestroy(info->tagJsonArray); + for (int i = 0; i < taosArrayGetSize(info->valueJsonArray); i++) { + cJSON *value = (cJSON *)taosArrayGetP(info->valueJsonArray, i); + cJSON_Delete(value); + } + taosArrayDestroy(info->valueJsonArray); + taosArrayDestroy(info->preLineTagKV); taosArrayDestroy(info->maxTagKVs); taosArrayDestroy(info->preLineColKV); @@ -1111,6 +1117,7 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) { info->dataFormat = true; info->tagJsonArray = taosArrayInit(8, POINTER_BYTES); + info->valueJsonArray = taosArrayInit(8, POINTER_BYTES); info->preLineTagKV = taosArrayInit(8, sizeof(SSmlKv)); info->maxTagKVs = taosArrayInit(8, sizeof(SSmlKv)); info->preLineColKV = taosArrayInit(8, sizeof(SSmlKv)); diff --git a/source/client/src/clientSmlJson.c b/source/client/src/clientSmlJson.c index 080ce4568f..8b97e8dc22 100644 --- a/source/client/src/clientSmlJson.c +++ b/source/client/src/clientSmlJson.c @@ -1155,15 +1155,18 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo * char tmp = elements->cols[elements->colsLen]; elements->cols[elements->colsLen] = '\0'; cJSON* valueJson = cJSON_Parse(elements->cols); + if (unlikely(valueJson == NULL)) { + uError("SML:0x%" PRIx64 " parse json cols failed:%s", info->id, elements->cols); + return TSDB_CODE_TSC_INVALID_JSON; + } + taosArrayPush(info->tagJsonArray, &valueJson); ret = smlParseValueFromJSONObj(valueJson, &kv); if (ret != TSDB_CODE_SUCCESS) { uError("SML:Failed to parse value from JSON Obj:%s", elements->cols); elements->cols[elements->colsLen] = tmp; - cJSON_Delete(valueJson); return TSDB_CODE_TSC_INVALID_VALUE; } elements->cols[elements->colsLen] = tmp; - cJSON_Delete(valueJson); }else if(smlParseValue(&kv, &info->msgBuf) != TSDB_CODE_SUCCESS){ uError("SML:cols invalidate:%s", elements->cols); return TSDB_CODE_TSC_INVALID_VALUE; @@ -1176,7 +1179,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo * cJSON* tagsJson = cJSON_Parse(elements->tags); *(elements->tags + elements->tagsLen) = tmp; if (unlikely(tagsJson == NULL)) { - uError("SML:0x%" PRIx64 " parse json failed:%s", info->id, elements->tags); + uError("SML:0x%" PRIx64 " parse json tag failed:%s", info->id, elements->tags); return TSDB_CODE_TSC_INVALID_JSON; } diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 6c71c5cea7..a1682f47b3 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -29,6 +29,7 @@ class TDSimClient: self.testCluster = False self.path = path self.cfgDict = { + "fqdn": "localhost", "numOfLogLines": "100000000", "locale": "en_US.UTF-8", "charset": "UTF-8", @@ -119,6 +120,7 @@ class TDDnode: self.asan = False self.remoteIP = "" self.cfgDict = { + "fqdn": "localhost", "monitor": "0", "maxShellConns": "30000", "locale": "en_US.UTF-8",