diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index ae36bff81dcd2f8a9825fe0c599f9c70acb58c3b..ce88ba5befd2bf6641c102fa32a245a58b796fed 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1116,7 +1116,7 @@ static int printfInsertMeta() { if (g_Dbs.db[i].superTbls[j].childTblLimit > 0) { printf(" childTblLimit: \033[33m%d\033[0m\n", g_Dbs.db[i].superTbls[j].childTblLimit); } - if (g_Dbs.db[i].superTbls[j].childTblOffset > 0) { + if (g_Dbs.db[i].superTbls[j].childTblOffset >= 0) { printf(" childTblOffset: \033[33m%d\033[0m\n", g_Dbs.db[i].superTbls[j].childTblOffset); } printf(" insertRows: \033[33m%"PRId64"\033[0m\n", g_Dbs.db[i].superTbls[j].insertRows); @@ -2103,6 +2103,12 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, if (TBL_ALREADY_EXISTS == superTbls->childTblExists) { //get all child table name use cmd: select tbname from superTblName; + int childTblCount = 10000; + superTbls->childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN); + if (superTbls->childTblName == NULL) { + fprintf(stderr, "alloc memory failed!"); + return -1; + } getAllChildNameOfSuperTable(taos, dbName, superTbls->sTblName, &superTbls->childTblName, @@ -2680,6 +2686,7 @@ static int readSampleFromCsvFileToMem( return -1; } + assert(superTblInfo->sampleDataBuf); memset(superTblInfo->sampleDataBuf, 0, MAX_SAMPLES_ONCE_FROM_FILE * superTblInfo->lenOfOneRow); while (1) { @@ -3938,6 +3945,7 @@ static int getRowDataFromSample(char* dataBuf, int maxLen, int64_t timestamp, int ret = readSampleFromCsvFileToMem(superTblInfo); if (0 != ret) { tmfree(superTblInfo->sampleDataBuf); + superTblInfo->sampleDataBuf = NULL; return -1; } *sampleUsePos = 0; @@ -4324,15 +4332,15 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) { return -1; } + superTblInfo->sampleDataBuf = sampleDataBuf; int ret = readSampleFromCsvFileToMem(superTblInfo); if (0 != ret) { tmfree(sampleDataBuf); + superTblInfo->sampleDataBuf = NULL; return -1; } } - superTblInfo->sampleDataBuf = sampleDataBuf; - return 0; } @@ -4571,6 +4579,7 @@ static void* syncWrite(void *sarg) { if (superTblInfo->numberOfTblInOneSql > 0) { syncWriteForNumberOfTblInOneSql(winfo, superTblInfo->sampleDataBuf); tmfree(superTblInfo->sampleDataBuf); + superTblInfo->sampleDataBuf = NULL; return NULL; } } @@ -4659,8 +4668,10 @@ static void* syncWrite(void *sarg) { free_and_statistics_2: tmfree(buffer); - if (superTblInfo) + if (superTblInfo) { tmfree(superTblInfo->sampleDataBuf); + superTblInfo->sampleDataBuf = NULL; + } printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n", winfo->threadID, @@ -4759,13 +4770,18 @@ static void startMultiThreadInsertData(int threads, char* db_name, memset(infos, 0, threads * sizeof(threadInfo)); int ntables = 0; - if (superTblInfo) - if (superTblInfo->childTblOffset) + if (superTblInfo) { + + if ((superTblInfo->childTblOffset >= 0) + && (superTblInfo->childTblLimit > 0)) { + ntables = superTblInfo->childTblLimit; - else + } else { ntables = superTblInfo->childTblCount; - else + } + } else { ntables = g_args.num_of_tables; + } int a = ntables / threads; if (a < 1) { @@ -4821,7 +4837,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, int last; - if ((superTblInfo) && (superTblInfo->childTblOffset)) + if ((superTblInfo) && (superTblInfo->childTblOffset >= 0)) last = superTblInfo->childTblOffset; else last = 0; diff --git a/tests/pytest/tools/insert-tblimit-tboffset0.json b/tests/pytest/tools/insert-tblimit-tboffset0.json new file mode 100644 index 0000000000000000000000000000000000000000..302744cab933297d8455aed9c45210385f1ec56f --- /dev/null +++ b/tests/pytest/tools/insert-tblimit-tboffset0.json @@ -0,0 +1,60 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 365, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 20, + "childtable_offset": 0, + "multi_thread_write_one_tbl": "no", + "number_of_tbl_in_one_sql": 0, + "rows_per_tbl": 100, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +}