未验证 提交 10956b4a 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Feature/sangshuduo/td 4068 taosdemo stmt for master (#7020)

* [TD-4068]<feature>: taosdemo support stmt.

for easy merge purpose. disabled in master.

* fix clang compile error.

* fix memory leak, add more macros. change sqlcount to int

* fix rest segfault.

* add stmt_errstr() for reason print.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 2d20b425
...@@ -5134,8 +5134,8 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) ...@@ -5134,8 +5134,8 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
debugPrint("%s() LN%d, stmt=%p", debugPrint("%s() LN%d, stmt=%p",
__func__, __LINE__, pThreadInfo->stmt); __func__, __LINE__, pThreadInfo->stmt);
if (0 != taos_stmt_execute(pThreadInfo->stmt)) { if (0 != taos_stmt_execute(pThreadInfo->stmt)) {
errorPrint("%s() LN%d, failied to execute insert statement\n", errorPrint("%s() LN%d, failied to execute insert statement. reason: %s\n",
__func__, __LINE__); __func__, __LINE__, taos_stmt_errstr(pThreadInfo->stmt));
exit(-1); exit(-1);
} }
affectedRows = k; affectedRows = k;
...@@ -5698,7 +5698,7 @@ static int32_t prepareStmtWithoutStb( ...@@ -5698,7 +5698,7 @@ static int32_t prepareStmtWithoutStb(
int ret = taos_stmt_set_tbname(stmt, tableName); int ret = taos_stmt_set_tbname(stmt, tableName);
if (ret != 0) { if (ret != 0) {
errorPrint("failed to execute taos_stmt_set_tbname(%s). return 0x%x. reason: %s\n", errorPrint("failed to execute taos_stmt_set_tbname(%s). return 0x%x. reason: %s\n",
tableName, ret, taos_errstr(NULL)); tableName, ret, taos_stmt_errstr(stmt));
return ret; return ret;
} }
...@@ -5751,9 +5751,17 @@ static int32_t prepareStmtWithoutStb( ...@@ -5751,9 +5751,17 @@ static int32_t prepareStmtWithoutStb(
return -1; return -1;
} }
} }
taos_stmt_bind_param(stmt, (TAOS_BIND *)bindArray); if (0 != taos_stmt_bind_param(stmt, (TAOS_BIND *)bindArray)) {
errorPrint("%s() LN%d, stmt_bind_param() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
break;
}
// if msg > 3MB, break // if msg > 3MB, break
taos_stmt_add_batch(stmt); if (0 != taos_stmt_add_batch(stmt)) {
errorPrint("%s() LN%d, stmt_add_batch() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
break;
}
k++; k++;
recordFrom ++; recordFrom ++;
...@@ -5929,14 +5937,19 @@ static int32_t prepareStbStmt( ...@@ -5929,14 +5937,19 @@ static int32_t prepareStbStmt(
tmfree(tagsValBuf); tmfree(tagsValBuf);
tmfree(tagsArray); tmfree(tagsArray);
if (0 != ret) {
errorPrint("%s() LN%d, stmt_set_tbname_tags() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
return -1;
}
} else { } else {
ret = taos_stmt_set_tbname(stmt, tableName); ret = taos_stmt_set_tbname(stmt, tableName);
if (0 != ret) {
errorPrint("%s() LN%d, stmt_set_tbname() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
return -1;
} }
if (ret != 0) {
errorPrint("failed to execute taos_stmt_set_tbname(%s). return 0x%x. reason: %s\n",
tableName, ret, taos_errstr(NULL));
return ret;
} }
char *bindArray = calloc(1, sizeof(TAOS_BIND) * (stbInfo->columnCount + 1)); char *bindArray = calloc(1, sizeof(TAOS_BIND) * (stbInfo->columnCount + 1));
...@@ -5954,9 +5967,19 @@ static int32_t prepareStbStmt( ...@@ -5954,9 +5967,19 @@ static int32_t prepareStbStmt(
free(bindArray); free(bindArray);
return -1; return -1;
} }
taos_stmt_bind_param(stmt, (TAOS_BIND *)bindArray); ret = taos_stmt_bind_param(stmt, (TAOS_BIND *)bindArray);
if (0 != ret) {
errorPrint("%s() LN%d, stmt_bind_param() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
return -1;
}
// if msg > 3MB, break // if msg > 3MB, break
taos_stmt_add_batch(stmt); ret = taos_stmt_add_batch(stmt);
if (0 != ret) {
errorPrint("%s() LN%d, stmt_add_batch() failed! reason: %s\n",
__func__, __LINE__, taos_stmt_errstr(stmt));
return -1;
}
k++; k++;
recordFrom ++; recordFrom ++;
...@@ -6904,7 +6927,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -6904,7 +6927,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int ret = taos_stmt_prepare(pThreadInfo->stmt, buffer, 0); int ret = taos_stmt_prepare(pThreadInfo->stmt, buffer, 0);
if (ret != 0){ if (ret != 0){
errorPrint("failed to execute taos_stmt_prepare. return 0x%x. reason: %s\n", errorPrint("failed to execute taos_stmt_prepare. return 0x%x. reason: %s\n",
ret, taos_errstr(NULL)); ret, taos_stmt_errstr(pThreadInfo->stmt));
free(pids); free(pids);
free(infos); free(infos);
exit(-1); exit(-1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册