Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
881afc61
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
881afc61
编写于
3月 04, 2021
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3164]<fix>replace sub table name erro
上级
19a61df6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
38 addition
and
36 deletion
+38
-36
src/kit/taosdemo/insert.json
src/kit/taosdemo/insert.json
+11
-10
src/kit/taosdemo/query.json
src/kit/taosdemo/query.json
+6
-5
src/kit/taosdemo/subscribe.json
src/kit/taosdemo/subscribe.json
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+20
-20
未找到文件。
src/kit/taosdemo/insert.json
浏览文件 @
881afc61
...
...
@@ -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"
,
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"db"
,
"drop"
:
"
no
"
,
"name"
:
"db
x
"
,
"drop"
:
"
yes
"
,
"replica"
:
1
,
"days"
:
2
,
"days"
:
10
,
"cache"
:
16
,
"blocks"
:
8
,
"precision"
:
"ms"
,
...
...
@@ -23,6 +23,7 @@
"maxRows"
:
4096
,
"comp"
:
2
,
"walLevel"
:
1
,
"cachelast"
:
0
,
"quorum"
:
1
,
"fsync"
:
3000
,
"update"
:
0
...
...
@@ -30,20 +31,20 @@
"super_tables"
:
[{
"name"
:
"stb"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
1
,
"childtable_count"
:
1
00
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rate"
:
0
,
"insert_rows"
:
1000
00
,
"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"
:
1
0
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
"sample_file"
:
"./sample.csv"
,
...
...
src/kit/taosdemo/query.json
浏览文件 @
881afc61
...
...
@@ -6,13 +6,14 @@
"user"
:
"root"
,
"password"
:
"taosdata"
,
"confirm_parameter_prompt"
:
"yes"
,
"databases"
:
"db
01
"
,
"databases"
:
"db
x
"
,
"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"
:
"stb
01"
,
"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"
}]
}
}
src/kit/taosdemo/subscribe.json
浏览文件 @
881afc61
...
...
@@ -5,7 +5,7 @@
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"databases"
:
"db"
,
"databases"
:
"db
x
"
,
"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"
}]
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
881afc61
...
...
@@ -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
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录