提交 071ebdc5 编写于 作者: wmmhello's avatar wmmhello

[TD-6167]<fix> optimize sqlobj ref

上级 1f52dfb9
...@@ -1522,6 +1522,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { ...@@ -1522,6 +1522,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
pSql->isBind = true; pSql->isBind = true;
pStmt->pSql = pSql; pStmt->pSql = pSql;
pStmt->last = STMT_INIT; pStmt->last = STMT_INIT;
registerSqlObj(pSql);
return pStmt; return pStmt;
} }
...@@ -1575,8 +1576,6 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { ...@@ -1575,8 +1576,6 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pSql->cmd.insertParam.numOfParams = 0; pSql->cmd.insertParam.numOfParams = 0;
pSql->cmd.batchSize = 0; pSql->cmd.batchSize = 0;
registerSqlObj(pSql);
int32_t ret = stmtParseInsertTbTags(pSql, pStmt); int32_t ret = stmtParseInsertTbTags(pSql, pStmt);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
STMT_RET(ret); STMT_RET(ret);
...@@ -1815,6 +1814,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { ...@@ -1815,6 +1814,7 @@ int taos_stmt_close(TAOS_STMT* stmt) {
} }
taos_free_result(pStmt->pSql); taos_free_result(pStmt->pSql);
taosReleaseRef(tscObjRef, pStmt->pSql->self);
tfree(pStmt); tfree(pStmt);
STMT_RET(TSDB_CODE_SUCCESS); STMT_RET(TSDB_CODE_SUCCESS);
} }
...@@ -1962,12 +1962,9 @@ int taos_stmt_execute(TAOS_STMT* stmt) { ...@@ -1962,12 +1962,9 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
if (sql == NULL) { if (sql == NULL) {
ret = TSDB_CODE_TSC_OUT_OF_MEMORY; ret = TSDB_CODE_TSC_OUT_OF_MEMORY;
} else { } else {
if (pStmt->pSql != NULL) { taosReleaseRef(tscObjRef, pStmt->pSql->self);
tscFreeSqlObj(pStmt->pSql);
pStmt->pSql = NULL;
}
pStmt->pSql = taos_query((TAOS*)pStmt->taos, sql); pStmt->pSql = taos_query((TAOS*)pStmt->taos, sql);
taosAcquireRef(tscObjRef, pStmt->pSql->self);
ret = taos_errno(pStmt->pSql); ret = taos_errno(pStmt->pSql);
free(sql); free(sql);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册