From 0b91c2cfc6c5741338db5a2144b2d838d02d564f Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Sun, 9 May 2021 17:23:10 +0800 Subject: [PATCH] fix bug --- src/client/src/tscPrepare.c | 6 +-- tests/script/api/batchprepare.c | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index d33bdbb588..77ab9e84c3 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1374,9 +1374,6 @@ int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) { int taos_stmt_close(TAOS_STMT* stmt) { STscStmt* pStmt = (STscStmt*)stmt; if (!pStmt->isInsert) { - taosHashCleanup(pStmt->mtb.pTableHash); - taosHashCleanup(pStmt->mtb.pTableBlockHashList); - SNormalStmt* normal = &pStmt->normal; if (normal->params != NULL) { for (uint16_t i = 0; i < normal->numParams; i++) { @@ -1386,6 +1383,9 @@ int taos_stmt_close(TAOS_STMT* stmt) { } free(normal->parts); free(normal->sql); + } else { + taosHashCleanup(pStmt->mtb.pTableHash); + taosHashCleanup(pStmt->mtb.pTableBlockHashList); } taos_free_result(pStmt->pSql); diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 9b204c2f4a..5303b53329 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -548,6 +548,12 @@ int stmt_funcb1(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -700,6 +706,12 @@ int stmt_funcb2(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -857,6 +869,12 @@ int stmt_funcb3(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1010,6 +1028,12 @@ int stmt_funcb4(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1157,6 +1181,12 @@ int stmt_funcb5(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1236,6 +1266,11 @@ int stmt_funcb_ssz1(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(no_null); + return 0; } @@ -1388,6 +1423,12 @@ int stmt_funcb_s1(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1544,6 +1585,12 @@ int stmt_funcb_sc1(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1698,6 +1745,12 @@ int stmt_funcb_sc2(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1849,6 +1902,12 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + return 0; } @@ -1934,6 +1993,10 @@ int sql_perf1(TAOS *taos) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + return 0; } @@ -1983,6 +2046,10 @@ int sql_perf_s1(TAOS *taos) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + for (int i = 0; i < 360000; i++) { + free(sql[i]); + } + return 0; } @@ -2024,6 +2091,10 @@ int sql_s_perf1(TAOS *taos) { unsigned long long endtime = getCurrentTime(); printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + return 0; } -- GitLab