Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bdfe4c60
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bdfe4c60
编写于
6月 19, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]fix error in global variables.
上级
4855d16d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
39 deletion
+40
-39
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+25
-18
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+0
-9
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+15
-12
未找到文件。
src/kit/shell/src/shellEngine.c
浏览文件 @
bdfe4c60
...
...
@@ -276,6 +276,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
st
=
taosGetTimestampUs
();
TAOS_RES
*
pSql
=
taos_query
(
con
,
command
);
result
=
pSql
;
// set it into the global variable
if
(
taos_errno
(
pSql
))
{
taos_error
(
pSql
);
return
;
...
...
@@ -284,7 +286,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
if
(
regex_match
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
fprintf
(
stdout
,
"Database changed.
\n\n
"
);
fflush
(
stdout
);
result
=
NULL
;
taos_free_result
(
pSql
);
return
;
}
...
...
@@ -294,6 +297,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
int
error_no
=
0
;
int
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
if
(
numOfRows
<
0
)
{
result
=
NULL
;
taos_free_result
(
pSql
);
return
;
}
...
...
@@ -315,7 +319,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
if
(
fname
!=
NULL
)
{
wordfree
(
&
full_path
);
}
result
=
NULL
;
taos_free_result
(
pSql
);
}
...
...
@@ -419,8 +424,8 @@ static void dumpFieldToFile(FILE* fp, const char* val, TAOS_FIELD* field, int32_
}
}
static
int
dumpResultToFile
(
const
char
*
fname
,
TAOS_RES
*
result
)
{
TAOS_ROW
row
=
taos_fetch_row
(
result
);
static
int
dumpResultToFile
(
const
char
*
fname
,
TAOS_RES
*
tres
)
{
TAOS_ROW
row
=
taos_fetch_row
(
tres
);
if
(
row
==
NULL
)
{
return
0
;
}
...
...
@@ -441,9 +446,9 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
wordfree
(
&
full_path
);
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int
precision
=
taos_result_precision
(
result
);
int
num_fields
=
taos_num_fields
(
tres
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
tres
);
int
precision
=
taos_result_precision
(
tres
);
for
(
int
col
=
0
;
col
<
num_fields
;
col
++
)
{
if
(
col
>
0
)
{
...
...
@@ -455,7 +460,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
int
numOfRows
=
0
;
do
{
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
if
(
i
>
0
)
{
fputc
(
','
,
fp
);
...
...
@@ -465,10 +470,13 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
fputc
(
'\n'
,
fp
);
numOfRows
++
;
row
=
taos_fetch_row
(
result
);
row
=
taos_fetch_row
(
tres
);
}
while
(
row
!=
NULL
);
result
=
NULL
;
taos_free_result
(
tres
);
fclose
(
fp
);
return
numOfRows
;
}
...
...
@@ -769,8 +777,7 @@ void write_history() {
void
taos_error
(
TAOS_RES
*
tres
)
{
fprintf
(
stderr
,
"
\n
DB error: %s
\n
"
,
taos_errstr
(
tres
));
/* free local resouce: allocated memory/metric-meta refcnt */
result
=
NULL
;
taos_free_result
(
tres
);
}
...
...
@@ -845,9 +852,9 @@ void shellGetGrantInfo(void *con) {
char
sql
[]
=
"show grants"
;
result
=
taos_query
(
con
,
sql
);
TAOS_RES
*
tres
=
taos_query
(
con
,
sql
);
int
code
=
taos_errno
(
result
);
int
code
=
taos_errno
(
tres
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_COM_OPS_NOT_SUPPORT
)
{
fprintf
(
stdout
,
"Server is Community Edition, version is %s
\n\n
"
,
taos_get_server_info
(
con
));
...
...
@@ -857,18 +864,18 @@ void shellGetGrantInfo(void *con) {
return
;
}
int
num_fields
=
taos_field_count
(
result
);
int
num_fields
=
taos_field_count
(
tres
);
if
(
num_fields
==
0
)
{
fprintf
(
stderr
,
"
\n
Invalid grant information.
\n
"
);
exit
(
0
);
}
else
{
if
(
result
==
NULL
)
{
if
(
tres
==
NULL
)
{
fprintf
(
stderr
,
"
\n
Grant information is null.
\n
"
);
exit
(
0
);
}
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
TAOS_ROW
row
=
taos_fetch_row
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
tres
);
TAOS_ROW
row
=
taos_fetch_row
(
tres
);
if
(
row
==
NULL
)
{
fprintf
(
stderr
,
"
\n
Failed to get grant information from server. Abort.
\n
"
);
exit
(
0
);
...
...
@@ -888,8 +895,8 @@ void shellGetGrantInfo(void *con) {
fprintf
(
stdout
,
"Server is Enterprise %s Edition, version is %s and will expire at %s.
\n
"
,
serverVersion
,
taos_get_server_info
(
con
),
expiretime
);
}
taos_free_result
(
result
);
result
=
NULL
;
taos_free_result
(
tres
);
}
fprintf
(
stdout
,
"
\n
"
);
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
bdfe4c60
...
...
@@ -15,7 +15,6 @@
#include "os.h"
#include "shell.h"
#include "tsclient.h"
pthread_t
pid
;
...
...
@@ -23,14 +22,6 @@ pthread_t pid;
void
interruptHandler
(
int
signum
)
{
#ifdef LINUX
taos_stop_query
(
result
);
if
(
result
!=
NULL
)
{
/*
* we need to free result in async model, in order to avoid free
* results while the master thread is waiting for server response.
*/
tscQueueAsyncFreeResult
(
result
);
}
result
=
NULL
;
#else
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
bdfe4c60
...
...
@@ -293,7 +293,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
static
struct
argp
argp
=
{
options
,
parse_opt
,
args_doc
,
doc
};
TAOS
*
taos
=
NULL
;
TAOS_RES
*
result
=
NULL
;
char
*
command
=
NULL
;
char
*
lcommand
=
NULL
;
char
*
buffer
=
NULL
;
...
...
@@ -463,10 +462,10 @@ int taosDumpOut(SDumpArguments *arguments) {
taosDumpCharset
(
fp
);
sprintf
(
command
,
"show databases"
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
fprintf
(
stderr
,
"failed to run command: %s, reason: %s
\n
"
,
command
,
taos_errstr
(
result
));
taos_free_result
(
result
);
goto
_exit_failure
;
}
...
...
@@ -613,7 +612,7 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
fprintf
(
fp
,
"USE %s
\n\n
"
,
dbInfo
->
name
);
sprintf
(
command
,
"show tables"
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
...
...
@@ -717,7 +716,7 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
sprintf
(
command
,
"select %s from %s limit 1"
,
tableDes
->
cols
[
counter
].
field
,
tableDes
->
name
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
...
...
@@ -795,7 +794,7 @@ int taosGetTableDes(char *table, STableDef *tableDes) {
sprintf
(
command
,
"describe %s"
,
table
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
...
...
@@ -875,7 +874,7 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
tstrncpy
(
tableRecord
.
metric
,
metric
,
TSDB_TABLE_NAME_LEN
);
sprintf
(
command
,
"select tbname from %s"
,
metric
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
...
...
@@ -928,7 +927,7 @@ 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
);
result
=
taos_query
(
taos
,
command
);
TAOS_RES
*
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
));
...
...
@@ -1177,9 +1176,13 @@ int taosDumpIn(SDumpArguments *arguments) {
tcommand
=
command
;
}
taosReplaceCtrlChar
(
tcommand
);
if
(
taos_query
(
taos
,
tcommand
)
==
NULL
)
TAOS_RES
*
result
=
taos_query
(
taos
,
tcommand
);
if
(
taos_errno
(
result
)
!=
0
){
fprintf
(
stderr
,
"linenu: %"
PRId64
" failed to run command %s reason:%s
\n
continue...
\n
"
,
linenu
,
command
,
taos_errstr
(
taos
));
taos_errstr
(
result
));
taos_free_result
(
result
);
}
pstr
=
command
;
pstr
[
0
]
=
'\0'
;
...
...
@@ -1225,12 +1228,12 @@ int taosDumpIn(SDumpArguments *arguments) {
tcommand
=
command
;
}
taosReplaceCtrlChar
(
tcommand
);
result
=
taos_query
(
taos
,
tcommand
);
TAOS_RES
*
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_errstr
(
result
));
}
taos_free_result
(
result
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录