Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
33ac1a92
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33ac1a92
编写于
8月 07, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make taos.exe use mysql style password input.
上级
efe96a31
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
23 deletion
+47
-23
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+24
-14
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+2
-0
src/kit/shell/src/shellWindows.c
src/kit/shell/src/shellWindows.c
+20
-8
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1
-1
未找到文件。
src/kit/shell/src/shellEngine.c
浏览文件 @
33ac1a92
...
@@ -65,7 +65,15 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut
...
@@ -65,7 +65,15 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut
*/
*/
TAOS
*
shellInit
(
SShellArguments
*
_args
)
{
TAOS
*
shellInit
(
SShellArguments
*
_args
)
{
printf
(
"
\n
"
);
printf
(
"
\n
"
);
#ifndef WINDOWS
printf
(
CLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
printf
(
CLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
#else
if
(
!
_args
->
is_use_passwd
)
{
strcpy
(
tsOsName
,
"Windows"
);
printf
(
CLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
}
#endif
fflush
(
stdout
);
fflush
(
stdout
);
// set options before initializing
// set options before initializing
...
@@ -74,7 +82,9 @@ TAOS *shellInit(SShellArguments *_args) {
...
@@ -74,7 +82,9 @@ TAOS *shellInit(SShellArguments *_args) {
}
}
if
(
_args
->
is_use_passwd
)
{
if
(
_args
->
is_use_passwd
)
{
#ifndef TD_WINDOWS
if
(
_args
->
password
==
NULL
)
_args
->
password
=
getpass
(
"Enter password: "
);
if
(
_args
->
password
==
NULL
)
_args
->
password
=
getpass
(
"Enter password: "
);
#endif
}
else
{
}
else
{
_args
->
password
=
TSDB_DEFAULT_PASS
;
_args
->
password
=
TSDB_DEFAULT_PASS
;
}
}
...
@@ -170,7 +180,7 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
...
@@ -170,7 +180,7 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
system
(
"clear"
);
system
(
"clear"
);
return
0
;
return
0
;
}
}
if
(
regex_match
(
command
,
"^[
\t
]*set[
\t
]+max_binary_display_width[
\t
]+(default|[1-9][0-9]*)[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
if
(
regex_match
(
command
,
"^[
\t
]*set[
\t
]+max_binary_display_width[
\t
]+(default|[1-9][0-9]*)[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
strtok
(
command
,
"
\t
"
);
strtok
(
command
,
"
\t
"
);
strtok
(
NULL
,
"
\t
"
);
strtok
(
NULL
,
"
\t
"
);
...
@@ -182,7 +192,7 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
...
@@ -182,7 +192,7 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
}
}
return
0
;
return
0
;
}
}
if
(
regex_match
(
command
,
"^[
\t
]*source[
\t
]+[^ ]+[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
if
(
regex_match
(
command
,
"^[
\t
]*source[
\t
]+[^ ]+[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
/* If source file. */
/* If source file. */
char
*
c_ptr
=
strtok
(
command
,
" ;"
);
char
*
c_ptr
=
strtok
(
command
,
" ;"
);
...
@@ -247,7 +257,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
...
@@ -247,7 +257,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
esc
=
false
;
esc
=
false
;
continue
;
continue
;
}
}
if
(
c
==
'\\'
)
{
if
(
c
==
'\\'
)
{
esc
=
true
;
esc
=
true
;
continue
;
continue
;
...
@@ -336,8 +346,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
...
@@ -336,8 +346,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
}
}
if
(
!
tscIsUpdateQuery
(
pSql
))
{
// select and show kinds of commands
if
(
!
tscIsUpdateQuery
(
pSql
))
{
// select and show kinds of commands
int
error_no
=
0
;
int
error_no
=
0
;
int
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
int
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
if
(
numOfRows
<
0
)
{
if
(
numOfRows
<
0
)
{
atomic_store_64
(
&
result
,
0
);
atomic_store_64
(
&
result
,
0
);
...
@@ -530,7 +540,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
...
@@ -530,7 +540,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
fprintf
(
fp
,
"%s"
,
fields
[
col
].
name
);
fprintf
(
fp
,
"%s"
,
fields
[
col
].
name
);
}
}
fputc
(
'\n'
,
fp
);
fputc
(
'\n'
,
fp
);
int
numOfRows
=
0
;
int
numOfRows
=
0
;
do
{
do
{
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
...
@@ -716,7 +726,7 @@ static int verticalPrintResult(TAOS_RES* tres) {
...
@@ -716,7 +726,7 @@ static int verticalPrintResult(TAOS_RES* tres) {
int
numOfRows
=
0
;
int
numOfRows
=
0
;
int
showMore
=
1
;
int
showMore
=
1
;
do
{
do
{
if
(
numOfRows
<
resShowMaxNum
)
{
if
(
numOfRows
<
resShowMaxNum
)
{
printf
(
"*************************** %d.row ***************************
\n
"
,
numOfRows
+
1
);
printf
(
"*************************** %d.row ***************************
\n
"
,
numOfRows
+
1
);
...
@@ -851,7 +861,7 @@ static int horizontalPrintResult(TAOS_RES* tres) {
...
@@ -851,7 +861,7 @@ static int horizontalPrintResult(TAOS_RES* tres) {
int
numOfRows
=
0
;
int
numOfRows
=
0
;
int
showMore
=
1
;
int
showMore
=
1
;
do
{
do
{
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
if
(
numOfRows
<
resShowMaxNum
)
{
if
(
numOfRows
<
resShowMaxNum
)
{
...
@@ -867,7 +877,7 @@ static int horizontalPrintResult(TAOS_RES* tres) {
...
@@ -867,7 +877,7 @@ static int horizontalPrintResult(TAOS_RES* tres) {
printf
(
"[You can add limit statement to show more or redirect results to specific file to get all.]
\n
"
);
printf
(
"[You can add limit statement to show more or redirect results to specific file to get all.]
\n
"
);
showMore
=
0
;
showMore
=
0
;
}
}
numOfRows
++
;
numOfRows
++
;
row
=
taos_fetch_row
(
tres
);
row
=
taos_fetch_row
(
tres
);
}
while
(
row
!=
NULL
);
}
while
(
row
!=
NULL
);
...
@@ -909,7 +919,7 @@ void read_history() {
...
@@ -909,7 +919,7 @@ void read_history() {
if
(
errno
!=
ENOENT
)
{
if
(
errno
!=
ENOENT
)
{
fprintf
(
stderr
,
"Failed to open file %s, reason:%s
\n
"
,
f_history
,
strerror
(
errno
));
fprintf
(
stderr
,
"Failed to open file %s, reason:%s
\n
"
,
f_history
,
strerror
(
errno
));
}
}
#endif
#endif
return
;
return
;
}
}
...
@@ -934,9 +944,9 @@ void write_history() {
...
@@ -934,9 +944,9 @@ void write_history() {
FILE
*
f
=
fopen
(
f_history
,
"w"
);
FILE
*
f
=
fopen
(
f_history
,
"w"
);
if
(
f
==
NULL
)
{
if
(
f
==
NULL
)
{
#ifndef WINDOWS
#ifndef WINDOWS
fprintf
(
stderr
,
"Failed to open file %s for write, reason:%s
\n
"
,
f_history
,
strerror
(
errno
));
fprintf
(
stderr
,
"Failed to open file %s for write, reason:%s
\n
"
,
f_history
,
strerror
(
errno
));
#endif
#endif
return
;
return
;
}
}
...
@@ -982,13 +992,13 @@ void source_file(TAOS *con, char *fptr) {
...
@@ -982,13 +992,13 @@ void source_file(TAOS *con, char *fptr) {
/*
/*
if (access(fname, F_OK) != 0) {
if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
wordfree(&full_path);
wordfree(&full_path);
free(cmd);
free(cmd);
return;
return;
}
}
*/
*/
FILE
*
f
=
fopen
(
fname
,
"r"
);
FILE
*
f
=
fopen
(
fname
,
"r"
);
if
(
f
==
NULL
)
{
if
(
f
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: failed to open file %s
\n
"
,
fname
);
fprintf
(
stderr
,
"ERROR: failed to open file %s
\n
"
,
fname
);
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
33ac1a92
...
@@ -71,7 +71,9 @@ int checkVersion() {
...
@@ -71,7 +71,9 @@ int checkVersion() {
// Global configurations
// Global configurations
SShellArguments
args
=
{
SShellArguments
args
=
{
.
host
=
NULL
,
.
host
=
NULL
,
#ifndef TD_WINDOWS
.
password
=
NULL
,
.
password
=
NULL
,
#endif
.
user
=
NULL
,
.
user
=
NULL
,
.
database
=
NULL
,
.
database
=
NULL
,
.
timezone
=
NULL
,
.
timezone
=
NULL
,
...
...
src/kit/shell/src/shellWindows.c
浏览文件 @
33ac1a92
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
extern
char
configDir
[];
extern
char
configDir
[];
char
WINCLIENT_VERSION
[]
=
"Welcome to the TDengine shell from %s, Client Version:%s
\n
"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
\n\n
"
;
void
printVersion
()
{
void
printVersion
()
{
printf
(
"version: %s
\n
"
,
version
);
printf
(
"version: %s
\n
"
,
version
);
}
}
...
@@ -61,6 +64,8 @@ void printHelp() {
...
@@ -61,6 +64,8 @@ void printHelp() {
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
char
g_password
[
MAX_PASSWORD_SIZE
];
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
)
{
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
// for host
// for host
...
@@ -73,11 +78,18 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
...
@@ -73,11 +78,18 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
}
}
}
// for password
// for password
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
else
if
(
strncmp
(
argv
[
i
],
"-p"
,
2
)
==
0
)
{
arguments
->
is_use_passwd
=
true
;
arguments
->
is_use_passwd
=
true
;
if
(
i
<
argc
-
1
&&
argv
[
i
+
1
][
0
]
!=
'-'
)
{
strcpy
(
tsOsName
,
"Windows"
);
arguments
->
password
=
argv
[
++
i
];
printf
(
WINCLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
}
if
(
strlen
(
argv
[
i
])
==
2
)
{
printf
(
"Enter password: "
);
scanf
(
"%s"
,
g_password
);
getchar
();
}
else
{
tstrncpy
(
g_password
,
(
char
*
)(
argv
[
i
]
+
2
),
MAX_PASSWORD_SIZE
);
}
arguments
->
password
=
g_password
;
}
}
// for management port
// for management port
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
...
@@ -104,7 +116,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
...
@@ -104,7 +116,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
i
<
argc
-
1
)
{
char
*
tmp
=
argv
[
++
i
];
char
*
tmp
=
argv
[
++
i
];
if
(
strlen
(
tmp
)
>=
TSDB_FILENAME_LEN
)
{
if
(
strlen
(
tmp
)
>=
TSDB_FILENAME_LEN
)
{
fprintf
(
stderr
,
"config file path: %s overflow max len %d
\n
"
,
tmp
,
TSDB_FILENAME_LEN
-
1
);
fprintf
(
stderr
,
"config file path: %s overflow max len %d
\n
"
,
tmp
,
TSDB_FILENAME_LEN
-
1
);
...
@@ -265,7 +277,7 @@ void *shellLoopQuery(void *arg) {
...
@@ -265,7 +277,7 @@ void *shellLoopQuery(void *arg) {
if
(
command
==
NULL
)
return
NULL
;
if
(
command
==
NULL
)
return
NULL
;
int32_t
err
=
0
;
int32_t
err
=
0
;
do
{
do
{
memset
(
command
,
0
,
MAX_COMMAND_SIZE
);
memset
(
command
,
0
,
MAX_COMMAND_SIZE
);
shellPrintPrompt
();
shellPrintPrompt
();
...
@@ -274,7 +286,7 @@ void *shellLoopQuery(void *arg) {
...
@@ -274,7 +286,7 @@ void *shellLoopQuery(void *arg) {
err
=
shellReadCommand
(
con
,
command
);
err
=
shellReadCommand
(
con
,
command
);
if
(
err
)
{
if
(
err
)
{
break
;
break
;
}
}
}
while
(
shellRunCommand
(
con
,
command
)
==
0
);
}
while
(
shellRunCommand
(
con
,
command
)
==
0
);
return
NULL
;
return
NULL
;
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
33ac1a92
...
@@ -77,7 +77,7 @@ extern char configDir[];
...
@@ -77,7 +77,7 @@ extern char configDir[];
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64
#define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE
16
#define MAX_PASSWORD_SIZE
20
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_TB_NAME_SIZE 64
#define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录