From c421cabd5750a011542dec92ccce70ad7190b532 Mon Sep 17 00:00:00 2001 From: Haolin Wang Date: Fri, 13 Dec 2024 17:23:21 +0800 Subject: [PATCH] fix: stmt/stmt2 shoudld not insert disordered or duplicate data --- source/client/src/clientStmt.c | 6 ++++++ source/client/src/clientStmt2.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 9cad21961488..60475c55df93 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -1557,6 +1557,12 @@ int stmtExec(TAOS_STMT* stmt) { launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL); } else { if (pStmt->sql.stbInterlaceMode) { + STableDataCxt *pTableCxt = pStmt->exec.pCurrBlock; + if (!pTableCxt->ordered || pTableCxt->duplicateTs) { + tscError("failed to insert disordered or duplicate data"); + STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR); + } + int64_t startTs = taosGetTimestampUs(); while (atomic_load_64(&pStmt->sql.siInfo.tbRemainNum)) { taosUsleep(1); diff --git a/source/client/src/clientStmt2.c b/source/client/src/clientStmt2.c index f03879f199e3..8869a4eb062e 100644 --- a/source/client/src/clientStmt2.c +++ b/source/client/src/clientStmt2.c @@ -1669,6 +1669,12 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) { if (STMT_TYPE_QUERY != pStmt->sql.type) { if (pStmt->sql.stbInterlaceMode) { + STableDataCxt *pTableCxt = pStmt->exec.pCurrBlock; + if (!pTableCxt->ordered || pTableCxt->duplicateTs) { + tscError("failed to insert disordered or duplicate data"); + STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR); + } + int64_t startTs = taosGetTimestampUs(); while (atomic_load_64(&pStmt->sql.siInfo.tbRemainNum)) { taosUsleep(1);