From 071ebdc52d237fd3a828e8b369a3d04c29d3453d Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 28 Aug 2021 11:24:05 +0800 Subject: [PATCH] [TD-6167] optimize sqlobj ref --- src/client/src/tscPrepare.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 3b13f6435d..fbb73e4f38 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1522,6 +1522,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { pSql->isBind = true; pStmt->pSql = pSql; pStmt->last = STMT_INIT; + registerSqlObj(pSql); return pStmt; } @@ -1575,8 +1576,6 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->cmd.insertParam.numOfParams = 0; pSql->cmd.batchSize = 0; - registerSqlObj(pSql); - int32_t ret = stmtParseInsertTbTags(pSql, pStmt); if (ret != TSDB_CODE_SUCCESS) { STMT_RET(ret); @@ -1815,6 +1814,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { } taos_free_result(pStmt->pSql); + taosReleaseRef(tscObjRef, pStmt->pSql->self); tfree(pStmt); STMT_RET(TSDB_CODE_SUCCESS); } @@ -1962,12 +1962,9 @@ int taos_stmt_execute(TAOS_STMT* stmt) { if (sql == NULL) { ret = TSDB_CODE_TSC_OUT_OF_MEMORY; } else { - if (pStmt->pSql != NULL) { - tscFreeSqlObj(pStmt->pSql); - pStmt->pSql = NULL; - } - + taosReleaseRef(tscObjRef, pStmt->pSql->self); pStmt->pSql = taos_query((TAOS*)pStmt->taos, sql); + taosAcquireRef(tscObjRef, pStmt->pSql->self); ret = taos_errno(pStmt->pSql); free(sql); } -- GitLab