Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
95986f9d
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95986f9d
编写于
6月 08, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD_543] fix coverity scan, cid:267715
上级
922706ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
19 deletion
+18
-19
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+18
-19
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
95986f9d
...
...
@@ -43,6 +43,7 @@ extern char configDir[];
#define MAX_DATA_SIZE 1024
#define MAX_NUM_DATATYPE 8
#define OPT_ABORT 1
/* –abort */
#define STRING_LEN 512
/* The options we understand. */
static
struct
argp_option
options
[]
=
{
...
...
@@ -380,10 +381,11 @@ int main(int argc, char *argv[]) {
bool
insert_only
=
arguments
.
insert_only
;
char
**
data_type
=
arguments
.
datatype
;
int
count_data_type
=
0
;
char
dataString
[
512
];
char
dataString
[
STRING_LEN
];
bool
do_aggreFunc
=
true
;
memset
(
dataString
,
0
,
512
);
memset
(
dataString
,
0
,
STRING_LEN
);
int
len
=
0
;
if
(
strcasecmp
(
data_type
[
0
],
"BINARY"
)
==
0
||
strcasecmp
(
data_type
[
0
],
"BOOL"
)
==
0
)
{
do_aggreFunc
=
false
;
...
...
@@ -392,8 +394,8 @@ int main(int argc, char *argv[]) {
if
(
strcasecmp
(
data_type
[
count_data_type
],
""
)
==
0
)
{
break
;
}
strcat
(
dataString
,
data_type
[
count_data_type
]);
strcat
(
dataString
,
" "
);
len
+=
snprintf
(
dataString
+
len
,
STRING_LEN
-
len
,
"%s "
,
data_type
[
count_data_type
]
);
}
FILE
*
fp
=
fopen
(
arguments
.
output_file
,
"a"
);
...
...
@@ -473,32 +475,29 @@ int main(int argc, char *argv[]) {
sprintf
(
command
,
"create database %s;"
,
db_name
);
taos_query
(
taos
,
command
);
char
cols
[
512
]
=
"
\0
"
;
char
cols
[
STRING_LEN
]
=
"
\0
"
;
int
colIndex
=
0
;
len
=
0
;
for
(;
colIndex
<
ncols_per_record
-
1
;
colIndex
++
)
{
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
)
{
sprintf
(
command
,
",f%d %s"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
strcat
(
cols
,
command
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
}
else
{
sprintf
(
command
,
",f%d %s(%d)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
strcat
(
cols
,
command
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
}
}
if
(
strcasecmp
(
data_type
[
colIndex
%
count_data_type
],
"BINARY"
)
!=
0
)
{
sprintf
(
command
,
",f%d %s)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s)"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
]);
}
else
{
sprintf
(
command
,
",f%d %s(%d))"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
len
+=
snprintf
(
cols
+
len
,
STRING_LEN
-
len
,
",f%d %s(%d))"
,
colIndex
+
1
,
data_type
[
colIndex
%
count_data_type
],
len_of_binary
);
}
strcat
(
cols
,
command
);
if
(
!
use_metric
)
{
/* Create all the tables; */
printf
(
"Creating %d table(s)......
\n
"
,
ntables
);
for
(
int
i
=
0
;
i
<
ntables
;
i
++
)
{
s
printf
(
command
,
"create table %s.%s%d (ts timestamp%s;"
,
db_name
,
tb_prefix
,
i
,
cols
);
s
nprintf
(
command
,
BUFFER_SIZE
,
"create table %s.%s%d (ts timestamp%s;"
,
db_name
,
tb_prefix
,
i
,
cols
);
queryDB
(
taos
,
command
);
}
...
...
@@ -508,7 +507,7 @@ int main(int argc, char *argv[]) {
}
else
{
/* Create metric table */
printf
(
"Creating meters super table...
\n
"
);
s
printf
(
command
,
"create table %s.meters (ts timestamp%s tags (areaid int, loc binary(10))"
,
db_name
,
cols
);
s
nprintf
(
command
,
BUFFER_SIZE
,
"create table %s.meters (ts timestamp%s tags (areaid int, loc binary(10))"
,
db_name
,
cols
);
queryDB
(
taos
,
command
);
printf
(
"meters created!
\n
"
);
...
...
@@ -522,10 +521,10 @@ int main(int argc, char *argv[]) {
j
=
i
%
10
;
}
if
(
j
%
2
==
0
)
{
sprintf
(
command
,
"create table %s.%s%d using %s.meters tags (%d,
\"
%s
\"
);"
,
db_name
,
tb_prefix
,
i
,
db_name
,
j
,
"shanghai"
);
}
else
{
sprintf
(
command
,
"create table %s.%s%d using %s.meters tags (%d,
\"
%s
\"
);"
,
db_name
,
tb_prefix
,
i
,
db_name
,
j
,
"beijing"
);
}
snprintf
(
command
,
BUFFER_SIZE
,
"create table %s.%s%d using %s.meters tags (%d,
\"
%s
\"
);"
,
db_name
,
tb_prefix
,
i
,
db_name
,
j
,
"shanghai"
);
}
else
{
snprintf
(
command
,
BUFFER_SIZE
,
"create table %s.%s%d using %s.meters tags (%d,
\"
%s
\"
);"
,
db_name
,
tb_prefix
,
i
,
db_name
,
j
,
"beijing"
);
}
queryDB
(
taos
,
command
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录