From fd09c267a967f1096bd9c7d20fa150eff1d08c1e Mon Sep 17 00:00:00 2001 From: Mario Peng <48949600+Pengrongkun@users.noreply.github.com> Date: Wed, 19 Mar 2025 10:09:00 +0800 Subject: [PATCH] fix(stmt2):fix init db is NULL problem (#30256) * fix: stmt2 interlace mode db is NULL * fix: add test and fix one interlace no pk error --- source/client/src/clientStmt2.c | 3 +++ source/client/test/stmt2Test.cpp | 3 ++- source/common/src/tdataformat.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/client/src/clientStmt2.c b/source/client/src/clientStmt2.c index 994be0c2bd..cfd302d895 100644 --- a/source/client/src/clientStmt2.c +++ b/source/client/src/clientStmt2.c @@ -889,6 +889,9 @@ static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) { if (pStmt->exec.pRequest->pDb == NULL) { return terrno; } + if (pStmt->sql.stbInterlaceMode) { + pStmt->sql.siInfo.dbname = pStmt->db; + } return TSDB_CODE_SUCCESS; } diff --git a/source/client/test/stmt2Test.cpp b/source/client/test/stmt2Test.cpp index c7ae20b096..cc54cd55d3 100644 --- a/source/client/test/stmt2Test.cpp +++ b/source/client/test/stmt2Test.cpp @@ -1167,6 +1167,7 @@ TEST(stmt2Case, stmt2_insert_non_statndard) { } // TD-33419 +// TD-34075 TEST(stmt2Case, stmt2_insert_db) { TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0); ASSERT_NE(taos, nullptr); @@ -1177,7 +1178,7 @@ TEST(stmt2Case, stmt2_insert_db) { "INSERT INTO `stmt2_testdb_12`.`stb1` (ts,int_tag,tbname) VALUES " "(1591060627000,1,'tb1')(1591060627000,2,'tb2')"); - TAOS_STMT2_OPTION option = {0, false, false, NULL, NULL}; + TAOS_STMT2_OPTION option = {0, true, true, NULL, NULL}; TAOS_STMT2* stmt = taos_stmt2_init(taos, &option); ASSERT_NE(stmt, nullptr); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index ada69fd350..7b27840bae 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -3295,6 +3295,10 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte for (int32_t iInfo = 0; iInfo < numOfInfos; iInfo++) { if (infos[iInfo].bind->is_null && infos[iInfo].bind->is_null[iRow]) { if (infos[iInfo].bind->is_null[iRow] == 1) { + if(iInfo == 0) { + code = TSDB_CODE_PAR_PRIMARY_KEY_IS_NULL; + goto _exit; + } colVal = COL_VAL_NULL(infos[iInfo].columnId, infos[iInfo].type); } else { colVal = COL_VAL_NONE(infos[iInfo].columnId, infos[iInfo].type);