Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a375df2b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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看板
提交
a375df2b
编写于
6月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/query' of
https://github.com/taosdata/TDengine
into feature/query
上级
c4e08bbf
2d6d09ad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
85 deletion
+75
-85
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+28
-23
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+47
-62
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
a375df2b
...
...
@@ -708,27 +708,24 @@ void *readTable(void *sarg) {
sprintf
(
command
,
"select %s from %s%d where ts>= %"
PRId64
,
aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
double
t
=
getCurrentTime
();
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"Failed to query
\n
"
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
TAOS_RES
*
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"Failed to retreive results:%s
\n
"
,
taos_errstr
(
taos
)
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to query:%s
\n
"
,
taos_errstr
(
taos
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
1
);
exit
(
EXIT_FAILURE
);
}
while
(
taos_fetch_row
(
result
)
!=
NULL
)
{
while
(
taos_fetch_row
(
pSql
)
!=
NULL
)
{
count
++
;
}
t
=
getCurrentTime
()
-
t
;
totalT
+=
t
;
taos_free_result
(
result
);
taos_free_result
(
pSql
);
}
fprintf
(
fp
,
"|%10s | %10d | %12.2f | %10.2f |
\n
"
,
...
...
@@ -779,20 +776,18 @@ void *readMetric(void *sarg) {
fprintf
(
fp
,
"%s
\n
"
,
command
);
double
t
=
getCurrentTime
();
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"Failed to query
\n
"
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
TAOS_RES
*
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"Failed to retreive results:%s
\n
"
,
taos_errstr
(
taos
));
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to query:%s
\n
"
,
taos_errstr
(
taos
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
1
);
}
int
count
=
0
;
while
(
taos_fetch_row
(
result
)
!=
NULL
)
{
while
(
taos_fetch_row
(
pSql
)
!=
NULL
)
{
count
++
;
}
t
=
getCurrentTime
()
-
t
;
...
...
@@ -800,7 +795,7 @@ void *readMetric(void *sarg) {
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
num_of_tables
*
num_of_DPT
/
t
,
t
*
1000
);
printf
(
"select %10s took %.6f second(s)
\n\n
"
,
aggreFunc
[
j
],
t
);
taos_free_result
(
result
);
taos_free_result
(
pSql
);
}
fprintf
(
fp
,
"
\n
"
);
}
...
...
@@ -811,10 +806,19 @@ void *readMetric(void *sarg) {
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
=
5
;
while
(
i
>
0
)
{
if
(
taos_query
(
taos
,
command
)
==
0
)
break
;
TAOS_RES
*
pSql
=
NULL
;
int32_t
code
=
-
1
;
while
(
i
>
0
&&
code
!=
0
)
{
pSql
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
pSql
);
taos_free_result
(
pSql
);
pSql
=
NULL
;
if
(
code
==
0
)
{
break
;
}
i
--
;
}
if
(
i
==
0
)
{
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
taos
));
taos_close
(
taos
);
...
...
@@ -947,6 +951,7 @@ void callBack(void *param, TAOS_RES *res, int code) {
break
;
}
}
tb_info
->
timestamp
=
tmp_time
;
taos_query_a
(
tb_info
->
taos
,
buffer
,
callBack
,
tb_info
);
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
a375df2b
...
...
@@ -372,14 +372,12 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo) {
memset
(
pTableRecordInfo
,
0
,
sizeof
(
STableRecordInfo
));
sprintf
(
command
,
"show tables like %s"
,
table
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
-
1
;
}
TAOS_RES
*
result
=
taos_query
(
taos
,
command
);
\
int32_t
code
=
taos_errno
(
result
);
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
...
...
@@ -400,14 +398,12 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo) {
if
(
isSet
)
return
0
;
sprintf
(
command
,
"show stables like %s"
,
table
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
-
1
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
result
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
...
...
@@ -467,14 +463,11 @@ int taosDumpOut(SDumpArguments *arguments) {
taosDumpCharset
(
fp
);
sprintf
(
command
,
"show databases"
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command: %s, reason: %s
\n
"
,
command
,
taos_errstr
(
taos
));
goto
_exit_failure
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
taos_free_result
(
result
);
goto
_exit_failure
;
}
...
...
@@ -612,7 +605,7 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
taosDumpCreateDbClause
(
dbInfo
,
arguments
->
with_property
,
fp
);
sprintf
(
command
,
"use %s"
,
dbInfo
->
name
);
if
(
taos_
query
(
taos
,
command
)
!=
0
)
{
if
(
taos_
errno
(
taos_query
(
taos
,
command
)
)
!=
0
)
{
fprintf
(
stderr
,
"invalid database %s
\n
"
,
dbInfo
->
name
);
return
-
1
;
}
...
...
@@ -620,14 +613,11 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
fprintf
(
fp
,
"USE %s
\n\n
"
,
dbInfo
->
name
);
sprintf
(
command
,
"show tables"
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
-
1
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
...
...
@@ -725,14 +715,11 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
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
"
);
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
return
;
}
...
...
@@ -806,14 +793,12 @@ int taosGetTableDes(char *table, STableDef *tableDes) {
int
count
=
0
;
sprintf
(
command
,
"describe %s"
,
table
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
-
1
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
...
...
@@ -889,14 +874,11 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
strcpy
(
tableRecord
.
metric
,
metric
);
sprintf
(
command
,
"select tbname from %s"
,
metric
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s
\n
"
,
command
);
return
-
1
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, error: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
...
...
@@ -942,18 +924,16 @@ int taosDumpTableData(FILE *fp, char *tbname, SDumpArguments *arguments) {
sprintf
(
command
,
"select * from %s where _c0 >= %"
PRId64
" and _c0 <= %"
PRId64
" order by _c0 asc"
,
tbname
,
arguments
->
start_time
,
arguments
->
end_time
);
if
(
taos_query
(
taos
,
command
)
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, reason: %s
\n
"
,
command
,
taos_errstr
(
taos
));
return
-
1
;
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
fprintf
(
stderr
,
"failed to use result
\n
"
);
result
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"failed to run command %s, reason: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
return
-
1
;
}
numFields
=
taos_field_count
(
taos
);
numFields
=
taos_field_count
(
result
);
assert
(
numFields
>
0
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
tbuf
=
(
char
*
)
malloc
(
COMMAND_SIZE
);
...
...
@@ -1242,9 +1222,14 @@ int taosDumpIn(SDumpArguments *arguments) {
tcommand
=
command
;
}
taosReplaceCtrlChar
(
tcommand
);
if
(
taos_query
(
taos
,
tcommand
)
!=
0
)
result
=
taos_query
(
taos
,
tcommand
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"linenu:%"
PRId64
" failed to run command %s reason: %s
\n
continue...
\n
"
,
linenu
,
command
,
taos_errstr
(
taos
));
}
taos_free_result
(
result
);
}
pstr
=
command
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录