Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0970d1e4
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
0970d1e4
编写于
4月 22, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(tools): refact shell codes
上级
c92b3ce2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
13 deletion
+24
-13
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+16
-12
tools/shell/src/shellUtil.c
tools/shell/src/shellUtil.c
+8
-1
未找到文件。
tools/shell/src/shellEngine.c
浏览文件 @
0970d1e4
...
...
@@ -541,7 +541,7 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres) {
uint64_t
resShowMaxNum
=
UINT64_MAX
;
if
(
shell
.
args
.
commands
==
NULL
&&
shell
.
args
.
file
[
0
]
==
0
)
{
if
(
shell
.
args
.
commands
==
NULL
&&
shell
.
args
.
file
==
0
)
{
resShowMaxNum
=
SHELL_DEFAULT_RES_SHOW_NUM
;
}
...
...
@@ -675,7 +675,7 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres) {
uint64_t
resShowMaxNum
=
UINT64_MAX
;
if
(
shell
.
args
.
commands
==
NULL
&&
shell
.
args
.
file
[
0
]
==
0
)
{
if
(
shell
.
args
.
commands
==
NULL
&&
shell
.
args
.
file
==
NULL
)
{
resShowMaxNum
=
SHELL_DEFAULT_RES_SHOW_NUM
;
}
...
...
@@ -809,6 +809,10 @@ void shellSourceFile(const char *file) {
}
void
shellGetGrantInfo
()
{
char
sinfo
[
1024
]
=
{
0
};
tstrncpy
(
sinfo
,
taos_get_server_info
(
shell
.
conn
),
sizeof
(
sinfo
));
strtok
(
sinfo
,
"
\n
"
);
char
sql
[]
=
"show grants"
;
TAOS_RES
*
tres
=
taos_query
(
shell
.
conn
,
sql
);
...
...
@@ -816,9 +820,9 @@ void shellGetGrantInfo() {
int32_t
code
=
taos_errno
(
tres
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_OPS_NOT_SUPPORT
)
{
fprintf
(
stdout
,
"Server is Community Edition,
version is %s
\n\n
"
,
taos_get_server_info
(
shell
.
conn
)
);
fprintf
(
stdout
,
"Server is Community Edition,
%s
\n\n
"
,
sinfo
);
}
else
{
fprintf
(
stderr
,
"Failed to check Server Edition, Reason:
%d
:%s
\n\n
"
,
taos_errno
(
shell
.
conn
),
fprintf
(
stderr
,
"Failed to check Server Edition, Reason:
0x%04x
:%s
\n\n
"
,
taos_errno
(
shell
.
conn
),
taos_errstr
(
shell
.
conn
));
}
return
;
...
...
@@ -850,11 +854,9 @@ void shellGetGrantInfo() {
memcpy
(
expired
,
row
[
2
],
fields
[
2
].
bytes
);
if
(
strcmp
(
expiretime
,
"unlimited"
)
==
0
)
{
fprintf
(
stdout
,
"Server is Enterprise %s Edition, version is %s and will never expire.
\n
"
,
serverVersion
,
taos_get_server_info
(
shell
.
conn
));
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will never expire.
\n
"
,
serverVersion
,
sinfo
);
}
else
{
fprintf
(
stdout
,
"Server is Enterprise %s Edition, version is %s and will expire at %s.
\n
"
,
serverVersion
,
taos_get_server_info
(
shell
.
conn
),
expiretime
);
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will expire at %s.
\n
"
,
serverVersion
,
sinfo
,
expiretime
);
}
atomic_store_64
(
&
shell
.
result
,
0
);
...
...
@@ -878,7 +880,8 @@ void *shellCancelHandler(void *arg) {
taosResetTerminalMode
();
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
// shellExit();
shellWriteHistory
();
shellExit
();
}
return
NULL
;
...
...
@@ -907,7 +910,8 @@ void *shellThreadLoop(void *arg) {
}
while
(
shellRunCommand
(
command
)
==
0
);
taosMemoryFreeClear
(
command
);
// shellExit();
shellWriteHistory
();
shellExit
();
taosThreadCleanupPop
(
1
);
return
NULL
;
...
...
@@ -929,7 +933,7 @@ int32_t shellExecute() {
return
-
1
;
}
if
(
pArgs
->
commands
!=
NULL
||
pArgs
->
file
[
0
]
!=
0
)
{
if
(
pArgs
->
commands
!=
NULL
||
pArgs
->
file
!=
NULL
)
{
if
(
pArgs
->
commands
!=
NULL
)
{
printf
(
"%s%s
\n
"
,
shell
.
info
.
promptHeader
,
pArgs
->
commands
);
char
*
cmd
=
strdup
(
pArgs
->
commands
);
...
...
@@ -937,7 +941,7 @@ int32_t shellExecute() {
taosMemoryFree
(
cmd
);
}
if
(
pArgs
->
file
[
0
]
!=
0
)
{
if
(
pArgs
->
file
!=
NULL
)
{
shellSourceFile
(
pArgs
->
file
);
}
...
...
tools/shell/src/shellUtil.c
浏览文件 @
0970d1e4
...
...
@@ -115,4 +115,11 @@ void shellCheckServerStatus() {
}
while
(
1
);
}
void
shellExit
()
{
exit
(
EXIT_FAILURE
);
}
\ No newline at end of file
void
shellExit
()
{
if
(
shell
.
conn
!=
NULL
)
{
taos_close
(
shell
.
conn
);
shell
.
conn
=
NULL
;
}
taos_cleanup
();
exit
(
EXIT_FAILURE
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录