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

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

* [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
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 daa52050
...@@ -693,7 +693,11 @@ static void printHelp() { ...@@ -693,7 +693,11 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-p", indent, printf("%s%s%s%s\n", indent, "-p", indent,
"The TCP/IP port number to use for the connection. Default is 0."); "The TCP/IP port number to use for the connection. Default is 0.");
printf("%s%s%s%s\n", indent, "-I", indent, printf("%s%s%s%s\n", indent, "-I", indent,
#if STMT_IFACE_ENABLED == 1
"The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."); "The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'.");
#else
"The interface (taosc, rest) taosdemo uses. Default is 'taosc'.");
#endif
printf("%s%s%s%s\n", indent, "-d", indent, printf("%s%s%s%s\n", indent, "-d", indent,
"Destination database. Default is 'test'."); "Destination database. Default is 'test'.");
printf("%s%s%s%s\n", indent, "-a", indent, printf("%s%s%s%s\n", indent, "-a", indent,
...@@ -793,8 +797,10 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -793,8 +797,10 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->iface = TAOSC_IFACE; arguments->iface = TAOSC_IFACE;
} else if (0 == strcasecmp(argv[i], "rest")) { } else if (0 == strcasecmp(argv[i], "rest")) {
arguments->iface = REST_IFACE; arguments->iface = REST_IFACE;
#if STMT_IFACE_ENABLED == 1
} else if (0 == strcasecmp(argv[i], "stmt")) { } else if (0 == strcasecmp(argv[i], "stmt")) {
arguments->iface = STMT_IFACE; arguments->iface = STMT_IFACE;
#endif
} else { } else {
errorPrint("%s", "\n\t-I need a valid string following!\n"); errorPrint("%s", "\n\t-I need a valid string following!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -3912,8 +3918,10 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { ...@@ -3912,8 +3918,10 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].iface= TAOSC_IFACE; g_Dbs.db[i].superTbls[j].iface= TAOSC_IFACE;
} else if (0 == strcasecmp(stbIface->valuestring, "rest")) { } else if (0 == strcasecmp(stbIface->valuestring, "rest")) {
g_Dbs.db[i].superTbls[j].iface= REST_IFACE; g_Dbs.db[i].superTbls[j].iface= REST_IFACE;
#if STMT_IFACE_ENABLED == 1
} else if (0 == strcasecmp(stbIface->valuestring, "stmt")) { } else if (0 == strcasecmp(stbIface->valuestring, "stmt")) {
g_Dbs.db[i].superTbls[j].iface= STMT_IFACE; g_Dbs.db[i].superTbls[j].iface= STMT_IFACE;
#endif
} else { } else {
errorPrint("%s() LN%d, failed to read json, insert_mode %s not recognized\n", errorPrint("%s() LN%d, failed to read json, insert_mode %s not recognized\n",
__func__, __LINE__, stbIface->valuestring); __func__, __LINE__, stbIface->valuestring);
...@@ -4933,6 +4941,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) ...@@ -4933,6 +4941,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
} }
break; break;
#if STMT_IFACE_ENABLED == 1
case STMT_IFACE: case STMT_IFACE:
debugPrint("%s() LN%d, stmt=%p", __func__, __LINE__, pThreadInfo->stmt); debugPrint("%s() LN%d, stmt=%p", __func__, __LINE__, pThreadInfo->stmt);
if (0 != taos_stmt_execute(pThreadInfo->stmt)) { if (0 != taos_stmt_execute(pThreadInfo->stmt)) {
...@@ -4942,6 +4951,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) ...@@ -4942,6 +4951,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
} }
affectedRows = k; affectedRows = k;
break; break;
#endif
default: default:
errorPrint("%s() LN%d: unknown insert mode: %d\n", errorPrint("%s() LN%d: unknown insert mode: %d\n",
...@@ -5506,6 +5516,7 @@ static int32_t prepareStmtWithoutStb( ...@@ -5506,6 +5516,7 @@ static int32_t prepareStmtWithoutStb(
} }
} }
free(bindArray);
return k; return k;
} }
...@@ -5586,6 +5597,7 @@ static int32_t prepareStbStmt(SSuperTable *stbInfo, ...@@ -5586,6 +5597,7 @@ static int32_t prepareStbStmt(SSuperTable *stbInfo,
} }
} }
free(bindArray);
return k; return k;
} }
#endif #endif
...@@ -6407,6 +6419,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -6407,6 +6419,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
exit(-1); exit(-1);
} }
#if STMT_IFACE_ENABLED == 1
if ((g_args.iface == STMT_IFACE) if ((g_args.iface == STMT_IFACE)
|| ((superTblInfo) && (superTblInfo->iface == STMT_IFACE))) { || ((superTblInfo) && (superTblInfo->iface == STMT_IFACE))) {
...@@ -6446,6 +6459,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -6446,6 +6459,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
exit(-1); exit(-1);
} }
} }
#endif
} else { } else {
pThreadInfo->taos = NULL; pThreadInfo->taos = NULL;
} }
...@@ -6486,9 +6500,11 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -6486,9 +6500,11 @@ static void startMultiThreadInsertData(int threads, char* db_name,
tsem_destroy(&(pThreadInfo->lock_sem)); tsem_destroy(&(pThreadInfo->lock_sem));
#if STMT_IFACE_ENABLED == 1
if (pThreadInfo->stmt) { if (pThreadInfo->stmt) {
taos_stmt_close(pThreadInfo->stmt); taos_stmt_close(pThreadInfo->stmt);
} }
#endif
tsem_destroy(&(pThreadInfo->lock_sem)); tsem_destroy(&(pThreadInfo->lock_sem));
taos_close(pThreadInfo->taos); taos_close(pThreadInfo->taos);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册