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
This commit is contained in:
Mario Peng 2025-03-19 10:09:00 +08:00 committed by GitHub
parent fd813aa62d
commit fd09c267a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);