From bebd9225cc9026643ddb9ee9fefc4652cea87cb4 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 25 Aug 2022 11:49:01 +0800 Subject: [PATCH] fix: fix explain buffer issue --- source/common/src/tmsg.c | 9 ++++++++- source/libs/nodes/src/nodesToSQLFuncs.c | 12 +++++++++++- source/util/test/hashTest.cpp | 2 -- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index b3c0363e44..1d96131f11 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5123,8 +5123,15 @@ int tDecodeSVCreateTbRsp(SDecoder *pCoder, SVCreateTbRsp *pRsp) { } void tFreeSVCreateTbRsp(void* param) { + if (NULL == param) { + return; + } + SVCreateTbRsp* pRsp = (SVCreateTbRsp*)param; - taosMemoryFree(pRsp->pMeta); + if (pRsp->pMeta) { + taosMemoryFree(pRsp->pMeta->pSchemas); + taosMemoryFree(pRsp->pMeta); + } } // TDMT_VND_DROP_TABLE ================= diff --git a/source/libs/nodes/src/nodesToSQLFuncs.c b/source/libs/nodes/src/nodesToSQLFuncs.c index e521c57c3d..9325d02886 100644 --- a/source/libs/nodes/src/nodesToSQLFuncs.c +++ b/source/libs/nodes/src/nodesToSQLFuncs.c @@ -135,7 +135,12 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - *len += snprintf(buf + *len, bufSize - *len, "%s", t); + int32_t tlen = strlen(t); + if (tlen > 32) { + *len += snprintf(buf + *len, bufSize - *len, "%.*s...%s", 32, t, t + tlen - 1); + } else { + *len += snprintf(buf + *len, bufSize - *len, "%s", t); + } taosMemoryFree(t); return TSDB_CODE_SUCCESS; @@ -199,12 +204,17 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { SNodeListNode *pListNode = (SNodeListNode *)pNode; SNode *node = NULL; bool first = true; + int32_t num = 0; *len += snprintf(buf + *len, bufSize - *len, "("); FOREACH(node, pListNode->pNodeList) { if (!first) { *len += snprintf(buf + *len, bufSize - *len, ", "); + if (++num >= 10) { + *len += snprintf(buf + *len, bufSize - *len, "..."); + break; + } } NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); first = false; diff --git a/source/util/test/hashTest.cpp b/source/util/test/hashTest.cpp index 135db8192a..97e67ea36e 100644 --- a/source/util/test/hashTest.cpp +++ b/source/util/test/hashTest.cpp @@ -313,14 +313,12 @@ void perfTest() { SArray *slArray = taosArrayInit(100000000, 9); for (int64_t i = 0; i < 1000; ++i) { int32_t num = taosArrayGetSize(sArray[i]); - printf("%d ", num); SArray* pArray = sArray[i]; for (int64_t m = 0; m < num; ++m) { char* p = (char*)taosArrayGet(pArray, m); ASSERT(taosArrayPush(slArray, p)); } } - printf("\n"); int64_t start100mS = taosGetTimestampMs(); int64_t start100mSCt = taosHashGetCompTimes(hash100m); int32_t num = taosArrayGetSize(slArray);