Merge pull request #29205 from taosdata/fix/main/TD-33219

fix:[TD-33219]
This commit is contained in:
Shengliang Guan 2024-12-19 18:24:21 +08:00 committed by GitHub
commit 7c9a60f713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 11 deletions

View File

@ -2201,6 +2201,11 @@ int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col
if (code) {
goto out;
}
} else {
code = stmtSetTbTags2(stmt, NULL);
if (code) {
return code;
}
}
if (bindv->bind_cols && bindv->bind_cols[i]) {

View File

@ -1012,10 +1012,10 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
}
SBoundColInfo* tags_info = (SBoundColInfo*)pStmt->bInfo.boundTags;
if (tags_info->numOfBound <= 0 || tags_info->numOfCols <= 0) {
tscWarn("no tags or cols bound in sql, will not bound tags");
return TSDB_CODE_SUCCESS;
}
// if (tags_info->numOfBound <= 0 || tags_info->numOfCols <= 0) {
// tscWarn("no tags or cols bound in sql, will not bound tags");
// return TSDB_CODE_SUCCESS;
// }
STableDataCxt** pDataBlock =
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));

View File

@ -5,9 +5,9 @@
#include <unistd.h>
#include "taos.h"
int CTB_NUMS = 1000;
int ROW_NUMS = 10;
int CYC_NUMS = 5;
int CTB_NUMS = 2;
int ROW_NUMS = 2;
int CYC_NUMS = 2;
void do_query(TAOS* taos, const char* sql) {
TAOS_RES* result = taos_query(taos, sql);
@ -57,7 +57,7 @@ void do_stmt(TAOS* taos, const char* sql) {
return;
}
int fieldNum = 0;
TAOS_FIELD_STB* pFields = NULL;
TAOS_FIELD_ALL* pFields = NULL;
// code = taos_stmt2_get_stb_fields(stmt, &fieldNum, &pFields);
// if (code != 0) {
// printf("failed get col,ErrCode: 0x%x, ErrMessage: %s.\n", code, taos_stmt2_error(stmt));
@ -74,7 +74,7 @@ void do_stmt(TAOS* taos, const char* sql) {
for (int i = 0; i < CTB_NUMS; i++) {
tbs[i] = (char*)malloc(sizeof(char) * 20);
sprintf(tbs[i], "ctb_%d", i);
createCtb(taos, tbs[i]);
// createCtb(taos, tbs[i]);
}
for (int r = 0; r < CYC_NUMS; r++) {
// col params
@ -138,7 +138,24 @@ void do_stmt(TAOS* taos, const char* sql) {
end = clock();
cpu_time_used = ((double)(end - start)) / CLOCKS_PER_SEC;
printf("stmt2-exec [%s] insert Time used: %f seconds\n", sql, cpu_time_used);
for (int i = 0; i < CTB_NUMS; i++) {
free(tags[i]);
free(paramv[i]);
free(ts[i]);
free(b[i]);
}
free(ts);
free(b);
free(ts_len);
free(b_len);
free(paramv);
free(tags);
}
for (int i = 0; i < CTB_NUMS; i++) {
free(tbs[i]);
}
free(tbs);
// taos_stmt2_free_fields(stmt, pFields);
taos_stmt2_close(stmt);
@ -200,10 +217,9 @@ int main() {
exit(1);
}
sleep(3);
do_stmt(taos, "insert into db.stb(tbname,ts,b,t1,t2) values(?,?,?,?,?)");
// do_stmt(taos, "insert into db.? using db.stb tags(?,?)values(?,?)");
do_taosc(taos);
// do_taosc(taos);
taos_close(taos);
taos_cleanup();
}