diff --git a/src/kit/taosdemo/insert.json b/src/kit/taosdemo/insert.json index 56a64b7b8561877cb26b4ef2336ab8b98f26c02c..9e252772ea42ea09225b8583696bda386ed7916e 100644 --- a/src/kit/taosdemo/insert.json +++ b/src/kit/taosdemo/insert.json @@ -6,15 +6,15 @@ "user": "root", "password": "taosdata", "thread_count": 4, - "thread_count_create_tbl": 1, + "thread_count_create_tbl": 4, "result_file": "./insert_res.txt", - "confirm_parameter_prompt": "no", + "confirm_parameter_prompt": "no", "databases": [{ "dbinfo": { - "name": "db", - "drop": "no", + "name": "dbx", + "drop": "yes", "replica": 1, - "days": 2, + "days": 10, "cache": 16, "blocks": 8, "precision": "ms", @@ -23,27 +23,28 @@ "maxRows": 4096, "comp":2, "walLevel":1, + "cachelast":0, "quorum":1, "fsync":3000, "update": 0 }, "super_tables": [{ "name": "stb", - "child_table_exists":"no", - "childtable_count": 1, + "child_table_exists":"no", + "childtable_count": 100, "childtable_prefix": "stb_", "auto_create_table": "no", "data_source": "rand", "insert_mode": "taosc", "insert_rate": 0, - "insert_rows": 100000, + "insert_rows": 1000, "multi_thread_write_one_tbl": "no", - "number_of_tbl_in_one_sql": 1, + "number_of_tbl_in_one_sql": 0, "rows_per_tbl": 100, "max_sql_len": 1024000, "disorder_ratio": 0, "disorder_range": 1000, - "timestamp_step": 10, + "timestamp_step": 1, "start_timestamp": "2020-10-01 00:00:00.000", "sample_format": "csv", "sample_file": "./sample.csv", diff --git a/src/kit/taosdemo/query.json b/src/kit/taosdemo/query.json index 4a5403a55d520681569b17adbd96c69bf411a15b..33ac120bdae283f64c4419d2885a93d36a7c8093 100644 --- a/src/kit/taosdemo/query.json +++ b/src/kit/taosdemo/query.json @@ -6,13 +6,14 @@ "user": "root", "password": "taosdata", "confirm_parameter_prompt": "yes", - "databases": "db01", + "databases": "dbx", "specified_table_query": - {"query_interval":1, "concurrent":1, - "sqls": [{"sql": "select count(*) from stb01", "result": "./query_res0.txt"}] + {"query_interval":1, "concurrent":4, + "sqls": [{"sql": "select last_row(*) from stb where color='red'", "result": "./query_res0.txt"}, + {"sql": "select count(*) from stb_01", "result": "./query_res1.txt"}] }, "super_table_query": - {"stblname": "stb01", "query_interval":1, "threads":1, - "sqls": [{"sql": "select count(*) from xxxx", "result": "./query_res1.txt"}] + {"stblname": "stb", "query_interval":1, "threads":4, + "sqls": [{"sql": "select last_row(*) from xxxx", "result": "./query_res2.txt"}] } } diff --git a/src/kit/taosdemo/subscribe.json b/src/kit/taosdemo/subscribe.json index f70b1213a884af7d593b3d7366268ce03de1d239..fd33a2e2e2515ac268764c0a7f3f8356e998becd 100644 --- a/src/kit/taosdemo/subscribe.json +++ b/src/kit/taosdemo/subscribe.json @@ -5,7 +5,7 @@ "port": 6030, "user": "root", "password": "taosdata", - "databases": "db", + "databases": "dbx", "specified_table_query": {"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes", "sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}] diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 9549c724293674f816be9023c3b3adb4b5c688b0..3c039be43f0d98321b8d98cea73e456cdc3282ab 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -257,14 +257,14 @@ typedef struct SColumn_S { } StrColumn; typedef struct SSuperTable_S { - char sTblName[MAX_TB_NAME_SIZE]; + char sTblName[MAX_TB_NAME_SIZE+1]; int childTblCount; bool superTblExists; // 0: no, 1: yes bool childTblExists; // 0: no, 1: yes int batchCreateTableNum; // 0: no batch, > 0: batch table number in one sql int8_t autoCreateTable; // 0: create sub table, 1: auto create sub table char childTblPrefix[MAX_TB_NAME_SIZE]; - char dataSource[MAX_TB_NAME_SIZE]; // rand_gen or sample + char dataSource[MAX_TB_NAME_SIZE+1]; // rand_gen or sample char insertMode[MAX_TB_NAME_SIZE]; // taosc, restful int insertRate; // 0: unlimit > 0 rows/s @@ -279,8 +279,8 @@ typedef struct SSuperTable_S { int timeStampStep; char startTimestamp[MAX_TB_NAME_SIZE]; // char sampleFormat[MAX_TB_NAME_SIZE]; // csv, json - char sampleFile[MAX_FILE_NAME_LEN]; - char tagsFile[MAX_FILE_NAME_LEN]; + char sampleFile[MAX_FILE_NAME_LEN+1]; + char tagsFile[MAX_FILE_NAME_LEN+1]; int columnCount; StrColumn columns[MAX_COLUMN_COUNT]; @@ -356,12 +356,12 @@ typedef struct SDataBase_S { } SDataBase; typedef struct SDbs_S { - char cfgDir[MAX_FILE_NAME_LEN]; + char cfgDir[MAX_FILE_NAME_LEN+1]; char host[MAX_DB_NAME_SIZE]; uint16_t port; char user[MAX_DB_NAME_SIZE]; char password[MAX_DB_NAME_SIZE]; - char resultFile[MAX_FILE_NAME_LEN]; + char resultFile[MAX_FILE_NAME_LEN+1]; bool use_metric; bool insert_only; bool do_aggreFunc; @@ -386,13 +386,13 @@ typedef struct SuperQueryInfo_S { int subscribeInterval; // ms int subscribeRestart; int subscribeKeepProgress; - char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH]; - char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN]; + char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1]; + char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1]; TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT]; } SuperQueryInfo; typedef struct SubQueryInfo_S { - char sTblName[MAX_TB_NAME_SIZE]; + char sTblName[MAX_TB_NAME_SIZE+1]; int rate; // 0: unlimit > 0 loop/s int threadCnt; int subscribeMode; // 0: sync, 1: async @@ -402,20 +402,20 @@ typedef struct SubQueryInfo_S { int childTblCount; char childTblPrefix[MAX_TB_NAME_SIZE]; int sqlCount; - char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH]; - char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN]; + char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1]; + char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1]; TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT]; char* childTblName; } SubQueryInfo; typedef struct SQueryMetaInfo_S { - char cfgDir[MAX_FILE_NAME_LEN]; + char cfgDir[MAX_FILE_NAME_LEN+1]; char host[MAX_DB_NAME_SIZE]; uint16_t port; char user[MAX_DB_NAME_SIZE]; char password[MAX_DB_NAME_SIZE]; - char dbName[MAX_DB_NAME_SIZE]; + char dbName[MAX_DB_NAME_SIZE+1]; char queryMode[MAX_TB_NAME_SIZE]; // taosc, restful SuperQueryInfo superQueryInfo; @@ -425,7 +425,7 @@ typedef struct SQueryMetaInfo_S { typedef struct SThreadInfo_S { TAOS *taos; int threadID; - char db_name[MAX_DB_NAME_SIZE]; + char db_name[MAX_DB_NAME_SIZE+1]; char fp[4096]; char tb_prefix[MAX_TB_NAME_SIZE]; int start_table_id; @@ -1767,7 +1767,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName char* pTblName = childTblName; while ((row = taos_fetch_row(res)) != NULL) { int32_t* len = taos_fetch_lengths(res); - tstrncpy(pTblName, (char *)row[0], len[0]); + tstrncpy(pTblName, (char *)row[0], len[0]+1); //printf("==== sub table name: %s\n", pTblName); count++; if (count >= childTblCount - 1) { @@ -4489,7 +4489,7 @@ void replaceSubTblName(char* inSql, char* outSql, int tblIndex) { return; } - tstrncpy(outSql, inSql, pos - inSql); + tstrncpy(outSql, inSql, pos - inSql + 1); //printf("1: %s\n", outSql); strcat(outSql, subTblName); //printf("2: %s\n", outSql); @@ -4510,12 +4510,12 @@ void *subQueryProcess(void *sarg) { st = taosGetTimestampMs(); for (int i = winfo->start_table_id; i <= winfo->end_table_id; i++) { - for (int i = 0; i < g_queryInfo.subQueryInfo.sqlCount; i++) { + for (int j = 0; j < g_queryInfo.subQueryInfo.sqlCount; j++) { memset(sqlstr,0,sizeof(sqlstr)); - replaceSubTblName(g_queryInfo.subQueryInfo.sql[i], sqlstr, i); + replaceSubTblName(g_queryInfo.subQueryInfo.sql[j], sqlstr, i); char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; - if (g_queryInfo.subQueryInfo.result[i][0] != 0) { - sprintf(tmpFile, "%s-%d", g_queryInfo.subQueryInfo.result[i], winfo->threadID); + if (g_queryInfo.subQueryInfo.result[j][0] != 0) { + sprintf(tmpFile, "%s-%d", g_queryInfo.subQueryInfo.result[j], winfo->threadID); } selectAndGetResult(winfo->taos, sqlstr, tmpFile); }