diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index ea6ad8a48d7a9c4b5e992dffe8329735a0f47512..83a6a975631100356d378296ebacb8f801e86573 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1658,7 +1658,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pRes->qId = 0; pRes->numOfRows = 0; - strcpy(pSql->sqlstr, sql); + strntolower(pSql->sqlstr, sql, sqlLen); tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr); if (tscIsInsertData(pSql->sqlstr)) { @@ -1850,6 +1850,18 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags pCmd->insertParam.pTableBlockHashList = hashList; } + int32_t sqlLen = (int32_t)strlen(pStmt->pSql->sqlstr); + char* sqlstr = pStmt->pSql->sqlstr; + pStmt->pSql->sqlstr = calloc(1, sqlLen + 1); + if (pSql->sqlstr == NULL) { + tscError("0x%"PRIx64" failed to malloc sql string buffer", pSql->self); + free(tname.z); + STMT_RET(TSDB_CODE_TSC_OUT_OF_MEMORY); + } + + strntolower(pStmt->pSql->sqlstr, sqlstr, sqlLen); + free(sqlstr); + code = tsParseSql(pStmt->pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { // wait for the callback function to post the semaphore