diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 17f9f27abcb4c6f30171f8349c3afbd9e0f3e158..f17afa0f780f14f2ec6a140b01858677803f2969 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1345,12 +1345,15 @@ int tsParseSql(SSqlObj *pSql, bool initial) { } // make a backup as tsParseInsertSql may modify the string -// char* sqlstr = strdup(pSql->sqlstr); + char* sqlstr = strdup(pSql->sqlstr); ret = tsParseInsertSql(pSql); - if (/*(sqlstr == NULL) || */(pSql->parseRetry >= 1) || + if ((sqlstr == NULL) || (pSql->parseRetry >= 1) || (ret != TSDB_CODE_TSC_SQL_SYNTAX_ERROR && ret != TSDB_CODE_TSC_INVALID_SQL)) { + free(sqlstr); } else { tscResetSqlCmd(pCmd, true); + free(pSql->sqlstr); + pSql->sqlstr = sqlstr; pSql->parseRetry++; if ((ret = tsInsertInitialCheck(pSql)) == TSDB_CODE_SUCCESS) { ret = tsParseInsertSql(pSql);