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

Feature/sangshuduo/td 4068 taosdemo stmt (#6299)

* merge with develop branch.

change query/tests/CMakeLists.txt to allow unused function and variable.

* refactor data generating.

* refactor.

* refactor.

* refactor.

* refactor.

* refactor

* add prepare stmt function.

* refactor get rand timestamp.

* fix windows compile error.

* copy logic of generate data for stmt.

* insert data basically works now.

* fix windows compile issue.

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

stb batch insert works.

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

normal table insert works.

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

interlace write works.

* add compile macro to make taosdemo same with master branch.

* fix clang compile error.

* fix memory leak.

* add more macro.

* fix rest segfault.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 a7e1c348
...@@ -2910,8 +2910,8 @@ static void* createTable(void *sarg) ...@@ -2910,8 +2910,8 @@ static void* createTable(void *sarg)
int buff_len; int buff_len;
buff_len = BUFFER_SIZE / 8; buff_len = BUFFER_SIZE / 8;
char *buffer = calloc(buff_len, 1); pThreadInfo->buffer = calloc(buff_len, 1);
if (buffer == NULL) { if (pThreadInfo->buffer == NULL) {
errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__); errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__);
exit(-1); exit(-1);
} }
...@@ -2926,7 +2926,7 @@ static void* createTable(void *sarg) ...@@ -2926,7 +2926,7 @@ static void* createTable(void *sarg)
for (uint64_t i = pThreadInfo->start_table_from; for (uint64_t i = pThreadInfo->start_table_from;
i <= pThreadInfo->end_table_to; i++) { i <= pThreadInfo->end_table_to; i++) {
if (0 == g_Dbs.use_metric) { if (0 == g_Dbs.use_metric) {
snprintf(buffer, buff_len, snprintf(pThreadInfo->buffer, buff_len,
"create table if not exists %s.%s%"PRIu64" %s;", "create table if not exists %s.%s%"PRIu64" %s;",
pThreadInfo->db_name, pThreadInfo->db_name,
g_args.tb_prefix, i, g_args.tb_prefix, i,
...@@ -2935,13 +2935,13 @@ static void* createTable(void *sarg) ...@@ -2935,13 +2935,13 @@ static void* createTable(void *sarg)
if (superTblInfo == NULL) { if (superTblInfo == NULL) {
errorPrint("%s() LN%d, use metric, but super table info is NULL\n", errorPrint("%s() LN%d, use metric, but super table info is NULL\n",
__func__, __LINE__); __func__, __LINE__);
free(buffer); free(pThreadInfo->buffer);
exit(-1); exit(-1);
} else { } else {
if (0 == len) { if (0 == len) {
batchNum = 0; batchNum = 0;
memset(buffer, 0, buff_len); memset(pThreadInfo->buffer, 0, buff_len);
len += snprintf(buffer + len, len += snprintf(pThreadInfo->buffer + len,
buff_len - len, "create table "); buff_len - len, "create table ");
} }
char* tagsValBuf = NULL; char* tagsValBuf = NULL;
...@@ -2953,10 +2953,10 @@ static void* createTable(void *sarg) ...@@ -2953,10 +2953,10 @@ static void* createTable(void *sarg)
i % superTblInfo->tagSampleCount); i % superTblInfo->tagSampleCount);
} }
if (NULL == tagsValBuf) { if (NULL == tagsValBuf) {
free(buffer); free(pThreadInfo->buffer);
return NULL; return NULL;
} }
len += snprintf(buffer + len, len += snprintf(pThreadInfo->buffer + len,
buff_len - len, buff_len - len,
"if not exists %s.%s%"PRIu64" using %s.%s tags %s ", "if not exists %s.%s%"PRIu64" using %s.%s tags %s ",
pThreadInfo->db_name, superTblInfo->childTblPrefix, pThreadInfo->db_name, superTblInfo->childTblPrefix,
...@@ -2973,9 +2973,10 @@ static void* createTable(void *sarg) ...@@ -2973,9 +2973,10 @@ static void* createTable(void *sarg)
} }
len = 0; len = 0;
if (0 != queryDbExec(pThreadInfo->taos, buffer, NO_INSERT_TYPE, false)){ if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer,
errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); NO_INSERT_TYPE, false)){
free(buffer); errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer);
free(pThreadInfo->buffer);
return NULL; return NULL;
} }
...@@ -2988,12 +2989,13 @@ static void* createTable(void *sarg) ...@@ -2988,12 +2989,13 @@ static void* createTable(void *sarg)
} }
if (0 != len) { if (0 != len) {
if (0 != queryDbExec(pThreadInfo->taos, buffer, NO_INSERT_TYPE, false)) { if (0 != queryDbExec(pThreadInfo->taos, pThreadInfo->buffer,
errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); NO_INSERT_TYPE, false)) {
errorPrint( "queryDbExec() failed. buffer:\n%s\n", pThreadInfo->buffer);
} }
} }
free(buffer); free(pThreadInfo->buffer);
return NULL; return NULL;
} }
...@@ -4932,7 +4934,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) ...@@ -4932,7 +4934,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
case REST_IFACE: case REST_IFACE:
if (0 != postProceSql(g_Dbs.host, &g_Dbs.serv_addr, g_Dbs.port, if (0 != postProceSql(g_Dbs.host, &g_Dbs.serv_addr, g_Dbs.port,
pThreadInfo->buffer, NULL /* not set result file */)) { pThreadInfo->buffer, pThreadInfo)) {
affectedRows = -1; affectedRows = -1;
printf("========restful return fail, threadID[%d]\n", printf("========restful return fail, threadID[%d]\n",
pThreadInfo->threadID); pThreadInfo->threadID);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册