提交 881afc61 编写于 作者: H Hui Li

[TD-3164]<fix>replace sub table name erro

上级 19a61df6
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
"user": "root", "user": "root",
"password": "taosdata", "password": "taosdata",
"thread_count": 4, "thread_count": 4,
"thread_count_create_tbl": 1, "thread_count_create_tbl": 4,
"result_file": "./insert_res.txt", "result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no", "confirm_parameter_prompt": "no",
"databases": [{ "databases": [{
"dbinfo": { "dbinfo": {
"name": "db", "name": "dbx",
"drop": "no", "drop": "yes",
"replica": 1, "replica": 1,
"days": 2, "days": 10,
"cache": 16, "cache": 16,
"blocks": 8, "blocks": 8,
"precision": "ms", "precision": "ms",
...@@ -23,27 +23,28 @@ ...@@ -23,27 +23,28 @@
"maxRows": 4096, "maxRows": 4096,
"comp":2, "comp":2,
"walLevel":1, "walLevel":1,
"cachelast":0,
"quorum":1, "quorum":1,
"fsync":3000, "fsync":3000,
"update": 0 "update": 0
}, },
"super_tables": [{ "super_tables": [{
"name": "stb", "name": "stb",
"child_table_exists":"no", "child_table_exists":"no",
"childtable_count": 1, "childtable_count": 100,
"childtable_prefix": "stb_", "childtable_prefix": "stb_",
"auto_create_table": "no", "auto_create_table": "no",
"data_source": "rand", "data_source": "rand",
"insert_mode": "taosc", "insert_mode": "taosc",
"insert_rate": 0, "insert_rate": 0,
"insert_rows": 100000, "insert_rows": 1000,
"multi_thread_write_one_tbl": "no", "multi_thread_write_one_tbl": "no",
"number_of_tbl_in_one_sql": 1, "number_of_tbl_in_one_sql": 0,
"rows_per_tbl": 100, "rows_per_tbl": 100,
"max_sql_len": 1024000, "max_sql_len": 1024000,
"disorder_ratio": 0, "disorder_ratio": 0,
"disorder_range": 1000, "disorder_range": 1000,
"timestamp_step": 10, "timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000", "start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv", "sample_format": "csv",
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
......
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
"user": "root", "user": "root",
"password": "taosdata", "password": "taosdata",
"confirm_parameter_prompt": "yes", "confirm_parameter_prompt": "yes",
"databases": "db01", "databases": "dbx",
"specified_table_query": "specified_table_query":
{"query_interval":1, "concurrent":1, {"query_interval":1, "concurrent":4,
"sqls": [{"sql": "select count(*) from stb01", "result": "./query_res0.txt"}] "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": "super_table_query":
{"stblname": "stb01", "query_interval":1, "threads":1, {"stblname": "stb", "query_interval":1, "threads":4,
"sqls": [{"sql": "select count(*) from xxxx", "result": "./query_res1.txt"}] "sqls": [{"sql": "select last_row(*) from xxxx", "result": "./query_res2.txt"}]
} }
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"port": 6030, "port": 6030,
"user": "root", "user": "root",
"password": "taosdata", "password": "taosdata",
"databases": "db", "databases": "dbx",
"specified_table_query": "specified_table_query":
{"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes", {"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes",
"sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}] "sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}]
......
...@@ -257,14 +257,14 @@ typedef struct SColumn_S { ...@@ -257,14 +257,14 @@ typedef struct SColumn_S {
} StrColumn; } StrColumn;
typedef struct SSuperTable_S { typedef struct SSuperTable_S {
char sTblName[MAX_TB_NAME_SIZE]; char sTblName[MAX_TB_NAME_SIZE+1];
int childTblCount; int childTblCount;
bool superTblExists; // 0: no, 1: yes bool superTblExists; // 0: no, 1: yes
bool childTblExists; // 0: no, 1: yes bool childTblExists; // 0: no, 1: yes
int batchCreateTableNum; // 0: no batch, > 0: batch table number in one sql int batchCreateTableNum; // 0: no batch, > 0: batch table number in one sql
int8_t autoCreateTable; // 0: create sub table, 1: auto create sub table int8_t autoCreateTable; // 0: create sub table, 1: auto create sub table
char childTblPrefix[MAX_TB_NAME_SIZE]; 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 char insertMode[MAX_TB_NAME_SIZE]; // taosc, restful
int insertRate; // 0: unlimit > 0 rows/s int insertRate; // 0: unlimit > 0 rows/s
...@@ -279,8 +279,8 @@ typedef struct SSuperTable_S { ...@@ -279,8 +279,8 @@ typedef struct SSuperTable_S {
int timeStampStep; int timeStampStep;
char startTimestamp[MAX_TB_NAME_SIZE]; // char startTimestamp[MAX_TB_NAME_SIZE]; //
char sampleFormat[MAX_TB_NAME_SIZE]; // csv, json char sampleFormat[MAX_TB_NAME_SIZE]; // csv, json
char sampleFile[MAX_FILE_NAME_LEN]; char sampleFile[MAX_FILE_NAME_LEN+1];
char tagsFile[MAX_FILE_NAME_LEN]; char tagsFile[MAX_FILE_NAME_LEN+1];
int columnCount; int columnCount;
StrColumn columns[MAX_COLUMN_COUNT]; StrColumn columns[MAX_COLUMN_COUNT];
...@@ -356,12 +356,12 @@ typedef struct SDataBase_S { ...@@ -356,12 +356,12 @@ typedef struct SDataBase_S {
} SDataBase; } SDataBase;
typedef struct SDbs_S { typedef struct SDbs_S {
char cfgDir[MAX_FILE_NAME_LEN]; char cfgDir[MAX_FILE_NAME_LEN+1];
char host[MAX_DB_NAME_SIZE]; char host[MAX_DB_NAME_SIZE];
uint16_t port; uint16_t port;
char user[MAX_DB_NAME_SIZE]; char user[MAX_DB_NAME_SIZE];
char password[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 use_metric;
bool insert_only; bool insert_only;
bool do_aggreFunc; bool do_aggreFunc;
...@@ -386,13 +386,13 @@ typedef struct SuperQueryInfo_S { ...@@ -386,13 +386,13 @@ typedef struct SuperQueryInfo_S {
int subscribeInterval; // ms int subscribeInterval; // ms
int subscribeRestart; int subscribeRestart;
int subscribeKeepProgress; int subscribeKeepProgress;
char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH]; char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1];
char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN]; char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1];
TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT]; TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT];
} SuperQueryInfo; } SuperQueryInfo;
typedef struct SubQueryInfo_S { 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 rate; // 0: unlimit > 0 loop/s
int threadCnt; int threadCnt;
int subscribeMode; // 0: sync, 1: async int subscribeMode; // 0: sync, 1: async
...@@ -402,20 +402,20 @@ typedef struct SubQueryInfo_S { ...@@ -402,20 +402,20 @@ typedef struct SubQueryInfo_S {
int childTblCount; int childTblCount;
char childTblPrefix[MAX_TB_NAME_SIZE]; char childTblPrefix[MAX_TB_NAME_SIZE];
int sqlCount; int sqlCount;
char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH]; char sql[MAX_QUERY_SQL_COUNT][MAX_QUERY_SQL_LENGTH+1];
char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN]; char result[MAX_QUERY_SQL_COUNT][MAX_FILE_NAME_LEN+1];
TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT]; TAOS_SUB* tsub[MAX_QUERY_SQL_COUNT];
char* childTblName; char* childTblName;
} SubQueryInfo; } SubQueryInfo;
typedef struct SQueryMetaInfo_S { typedef struct SQueryMetaInfo_S {
char cfgDir[MAX_FILE_NAME_LEN]; char cfgDir[MAX_FILE_NAME_LEN+1];
char host[MAX_DB_NAME_SIZE]; char host[MAX_DB_NAME_SIZE];
uint16_t port; uint16_t port;
char user[MAX_DB_NAME_SIZE]; char user[MAX_DB_NAME_SIZE];
char password[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 char queryMode[MAX_TB_NAME_SIZE]; // taosc, restful
SuperQueryInfo superQueryInfo; SuperQueryInfo superQueryInfo;
...@@ -425,7 +425,7 @@ typedef struct SQueryMetaInfo_S { ...@@ -425,7 +425,7 @@ typedef struct SQueryMetaInfo_S {
typedef struct SThreadInfo_S { typedef struct SThreadInfo_S {
TAOS *taos; TAOS *taos;
int threadID; int threadID;
char db_name[MAX_DB_NAME_SIZE]; char db_name[MAX_DB_NAME_SIZE+1];
char fp[4096]; char fp[4096];
char tb_prefix[MAX_TB_NAME_SIZE]; char tb_prefix[MAX_TB_NAME_SIZE];
int start_table_id; int start_table_id;
...@@ -1767,7 +1767,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName ...@@ -1767,7 +1767,7 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName
char* pTblName = childTblName; char* pTblName = childTblName;
while ((row = taos_fetch_row(res)) != NULL) { while ((row = taos_fetch_row(res)) != NULL) {
int32_t* len = taos_fetch_lengths(res); 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); //printf("==== sub table name: %s\n", pTblName);
count++; count++;
if (count >= childTblCount - 1) { if (count >= childTblCount - 1) {
...@@ -4489,7 +4489,7 @@ void replaceSubTblName(char* inSql, char* outSql, int tblIndex) { ...@@ -4489,7 +4489,7 @@ void replaceSubTblName(char* inSql, char* outSql, int tblIndex) {
return; return;
} }
tstrncpy(outSql, inSql, pos - inSql); tstrncpy(outSql, inSql, pos - inSql + 1);
//printf("1: %s\n", outSql); //printf("1: %s\n", outSql);
strcat(outSql, subTblName); strcat(outSql, subTblName);
//printf("2: %s\n", outSql); //printf("2: %s\n", outSql);
...@@ -4510,12 +4510,12 @@ void *subQueryProcess(void *sarg) { ...@@ -4510,12 +4510,12 @@ void *subQueryProcess(void *sarg) {
st = taosGetTimestampMs(); st = taosGetTimestampMs();
for (int i = winfo->start_table_id; i <= winfo->end_table_id; i++) { 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)); 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}; char tmpFile[MAX_FILE_NAME_LEN*2] = {0};
if (g_queryInfo.subQueryInfo.result[i][0] != 0) { if (g_queryInfo.subQueryInfo.result[j][0] != 0) {
sprintf(tmpFile, "%s-%d", g_queryInfo.subQueryInfo.result[i], winfo->threadID); sprintf(tmpFile, "%s-%d", g_queryInfo.subQueryInfo.result[j], winfo->threadID);
} }
selectAndGetResult(winfo->taos, sqlstr, tmpFile); selectAndGetResult(winfo->taos, sqlstr, tmpFile);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册