Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
855bf501
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
未验证
提交
855bf501
编写于
5月 23, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
5月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2012 from taosdata/hotfix/taos-tools
Hotfix/taos tools
上级
0c210728
357b0e75
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
7 deletion
+79
-7
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+27
-6
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+52
-1
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
855bf501
...
...
@@ -362,6 +362,26 @@ int main(int argc, char *argv[]) {
time_t
tTime
=
time
(
NULL
);
struct
tm
tm
=
*
localtime
(
&
tTime
);
printf
(
"###################################################################
\n
"
);
printf
(
"# Server IP: %s:%hu
\n
"
,
ip_addr
==
NULL
?
"localhost"
:
ip_addr
,
port
);
printf
(
"# User: %s
\n
"
,
user
);
printf
(
"# Password: %s
\n
"
,
pass
);
printf
(
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
printf
(
"# Datatype of Columns: %s
\n
"
,
dataString
);
printf
(
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
printf
(
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
printf
(
"# Number of Connections: %d
\n
"
,
nconnections
);
printf
(
"# Number of Tables: %d
\n
"
,
ntables
);
printf
(
"# Number of Data per Table: %d
\n
"
,
nrecords_per_table
);
printf
(
"# Records/Request: %d
\n
"
,
nrecords_per_request
);
printf
(
"# Database name: %s
\n
"
,
db_name
);
printf
(
"# Table prefix: %s
\n
"
,
tb_prefix
);
printf
(
"# Test time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
printf
(
"###################################################################
\n\n
"
);
printf
(
"Press enter key to continue"
);
getchar
();
fprintf
(
fp
,
"###################################################################
\n
"
);
fprintf
(
fp
,
"# Server IP: %s:%hu
\n
"
,
ip_addr
==
NULL
?
"localhost"
:
ip_addr
,
port
);
...
...
@@ -858,15 +878,16 @@ void generateData(char *res, char **data_type, int num_of_cols, int64_t timestam
pstr
+=
sprintf
(
pstr
,
")"
);
}
static
const
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"
;
void
rand_string
(
char
*
str
,
int
size
)
{
memset
(
str
,
0
,
size
);
const
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"
;
char
*
sptr
=
str
;
if
(
size
)
{
str
[
0
]
=
0
;
if
(
size
>
0
)
{
--
size
;
for
(
size_t
n
=
0
;
n
<
size
;
n
++
)
{
int
n
;
for
(
n
=
0
;
n
<
size
;
n
++
)
{
int
key
=
rand
()
%
(
int
)(
sizeof
charset
-
1
);
s
ptr
+=
sprintf
(
sptr
,
"%c"
,
charset
[
key
])
;
s
tr
[
n
]
=
charset
[
key
]
;
}
str
[
n
]
=
0
;
}
}
src/kit/taosdump/taosdump.c
浏览文件 @
855bf501
...
...
@@ -533,7 +533,7 @@ int taosDumpOut(SDumpArguments *arguments) {
}
}
taos_free_result
(
result
);
//
taos_free_result(result);
if
(
count
==
0
)
{
fprintf
(
stderr
,
"No databases valid to dump
\n
"
);
...
...
@@ -722,6 +722,57 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
count_temp
=
counter
;
for
(;
counter
<
numOfCols
;
counter
++
)
{
TAOS_ROW
row
=
NULL
;
sprintf
(
command
,
"select %s from %s limit 1"
,
tableDes
->
cols
[
counter
].
field
,
tableDes
->
name
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
return
;
}
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
row
=
taos_fetch_row
(
result
);
switch
(
fields
[
0
].
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%d"
,
((((
int
)(
*
((
char
*
)
row
[
0
])))
==
1
)
?
1
:
0
));
break
;
case
TSDB_DATA_TYPE_TINYINT
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%d"
,
(
int
)(
*
((
char
*
)
row
[
0
])));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%d"
,
(
int
)(
*
((
short
*
)
row
[
0
])));
break
;
case
TSDB_DATA_TYPE_INT
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%d"
,
*
((
int
*
)
row
[
0
]));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%"
PRId64
""
,
*
((
int64_t
*
)
row
[
0
]));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%f"
,
GET_FLOAT_VAL
(
row
[
0
]));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%f"
,
GET_DOUBLE_VAL
(
row
[
0
]));
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
sprintf
(
tableDes
->
cols
[
counter
].
note
,
"%"
PRId64
""
,
*
(
int64_t
*
)
row
[
0
]);
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
default:
strncpy
(
tableDes
->
cols
[
counter
].
note
,
(
char
*
)
row
[
0
],
fields
[
0
].
bytes
);
break
;
}
taos_free_result
(
result
);
if
(
counter
!=
count_temp
)
{
if
(
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"binary"
)
==
0
||
strcasecmp
(
tableDes
->
cols
[
counter
].
type
,
"nchar"
)
==
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录