Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f2d06f08
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看板
未验证
提交
f2d06f08
编写于
6月 22, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2406 from taosdata/hotfix/test
Hotfix/test
上级
2c3afd83
3c1850ac
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
74 addition
and
33 deletion
+74
-33
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+5
-2
src/kit/shell/src/shellImport.c
src/kit/shell/src/shellImport.c
+4
-1
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+20
-14
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+16
-10
src/os/linux/src/linuxSysPara.c
src/os/linux/src/linuxSysPara.c
+5
-5
src/util/inc/tutil.h
src/util/inc/tutil.h
+2
-0
src/util/src/tnote.c
src/util/src/tnote.c
+2
-0
src/util/src/tutil.c
src/util/src/tutil.c
+19
-0
未找到文件。
src/kit/shell/src/shellEngine.c
浏览文件 @
f2d06f08
...
...
@@ -474,7 +474,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
}
while
(
row
!=
NULL
);
result
=
NULL
;
taos_free_result
(
tres
);
//
taos_free_result(tres);
fclose
(
fp
);
return
numOfRows
;
...
...
@@ -803,6 +803,7 @@ void source_file(TAOS *con, char *fptr) {
char
*
fname
=
full_path
.
we_wordv
[
0
];
/*
if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
...
...
@@ -810,6 +811,7 @@ void source_file(TAOS *con, char *fptr) {
free(cmd);
return;
}
*/
FILE
*
f
=
fopen
(
fname
,
"r"
);
if
(
f
==
NULL
)
{
...
...
@@ -849,7 +851,7 @@ void source_file(TAOS *con, char *fptr) {
void
shellGetGrantInfo
(
void
*
con
)
{
return
;
#if 0
char sql[] = "show grants";
TAOS_RES* tres = taos_query(con, sql);
...
...
@@ -900,4 +902,5 @@ void shellGetGrantInfo(void *con) {
}
fprintf(stdout, "\n");
#endif
}
src/kit/shell/src/shellImport.c
浏览文件 @
f2d06f08
...
...
@@ -73,7 +73,7 @@ static void shellParseDirectory(const char *directoryName, const char *prefix, c
}
int
fileNum
=
0
;
while
(
fscanf
(
fp
,
"%s"
,
fileArray
[
fileNum
++
]))
{
while
(
fscanf
(
fp
,
"%
128
s"
,
fileArray
[
fileNum
++
]))
{
if
(
strcmp
(
fileArray
[
fileNum
-
1
],
shellTablesSQLFile
)
==
0
)
{
fileNum
--
;
}
...
...
@@ -150,9 +150,11 @@ static void shellSourceFile(TAOS *con, char *fptr) {
char
*
fname
=
full_path
.
we_wordv
[
0
];
if
(
fname
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: invalid filename
\n
"
);
free
(
cmd
);
return
;
}
/*
if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
...
...
@@ -168,6 +170,7 @@ static void shellSourceFile(TAOS *con, char *fptr) {
free(cmd);
return;
}
*/
FILE
*
f
=
fopen
(
fname
,
"r"
);
if
(
f
==
NULL
)
{
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
f2d06f08
...
...
@@ -162,7 +162,7 @@ void shellReadCommand(TAOS *con, char *command) {
// Read input.
char
c
;
while
(
1
)
{
c
=
getchar
();
c
=
(
char
)
getchar
();
// getchar() return an 'int' value
if
(
c
<
0
)
{
// For UTF-8
int
count
=
countPrefixOnes
(
c
);
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
f2d06f08
...
...
@@ -34,6 +34,7 @@
#include <wordexp.h>
#include "taos.h"
#include "tutil.h"
extern
char
configDir
[];
...
...
@@ -82,7 +83,7 @@ typedef struct DemoArguments {
bool
insert_only
;
char
*
output_file
;
int
mode
;
char
*
datatype
[
MAX_NUM_DATATYPE
];
char
*
datatype
[
MAX_NUM_DATATYPE
+
1
];
int
len_of_binary
;
int
num_of_CPR
;
int
num_of_threads
;
...
...
@@ -432,7 +433,7 @@ int main(int argc, char *argv[]) {
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
printf
(
"###################################################################
\n\n
"
);
printf
(
"Press enter key to continue"
);
getchar
();
(
void
)
getchar
();
fprintf
(
fp
,
"###################################################################
\n
"
);
fprintf
(
fp
,
"# Server IP: %s:%hu
\n
"
,
ip_addr
==
NULL
?
"localhost"
:
ip_addr
,
port
);
...
...
@@ -845,10 +846,10 @@ void *syncWrite(void *sarg) {
pstr
+=
sprintf
(
pstr
,
"insert into %s.%s%d values"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
tID
);
int
k
;
for
(
k
=
0
;
k
<
winfo
->
nrecords_per_request
;)
{
int
rand_num
=
rand
()
%
100
;
int
rand_num
=
t
rand
()
%
100
;
int
len
=
-
1
;
if
(
winfo
->
data_of_order
==
1
&&
rand_num
<
winfo
->
data_of_rate
)
{
long
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
long
d
=
tmp_time
-
t
rand
()
%
1000000
+
rand_num
;
len
=
generateData
(
data
,
data_type
,
ncols_per_record
,
d
,
len_of_binary
);
}
else
{
len
=
generateData
(
data
,
data_type
,
ncols_per_record
,
tmp_time
+=
1000
,
len_of_binary
);
...
...
@@ -940,10 +941,10 @@ void callBack(void *param, TAOS_RES *res, int code) {
pstr
+=
sprintf
(
pstr
,
"insert into %s values"
,
tb_info
->
tb_name
);
for
(
int
i
=
0
;
i
<
tb_info
->
nrecords_per_request
;
i
++
)
{
int
rand_num
=
rand
()
%
100
;
int
rand_num
=
t
rand
()
%
100
;
if
(
tb_info
->
data_of_order
==
1
&&
rand_num
<
tb_info
->
data_of_rate
)
{
long
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
long
d
=
tmp_time
-
t
rand
()
%
1000000
+
rand_num
;
generateData
(
data
,
datatype
,
ncols_per_record
,
d
,
len_of_binary
);
}
else
{
...
...
@@ -985,22 +986,27 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
}
}
if
(
0
==
c
)
{
perror
(
"data type error!"
);
exit
(
-
1
);
}
for
(
int
i
=
0
;
i
<
num_of_cols
;
i
++
)
{
if
(
strcasecmp
(
data_type
[
i
%
c
],
"tinyint"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
rand
()
%
128
));
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
t
rand
()
%
128
));
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"smallint"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
rand
()
%
32767
));
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
t
rand
()
%
32767
));
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"int"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
rand
()
%
10
));
pstr
+=
sprintf
(
pstr
,
", %d"
,
(
int
)(
t
rand
()
%
10
));
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"bigint"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
", %"
PRId64
,
rand
()
%
2147483648
);
pstr
+=
sprintf
(
pstr
,
", %"
PRId64
,
t
rand
()
%
2147483648
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"float"
)
==
0
)
{
pstr
+=
sprintf
(
pstr
,
", %10.4f"
,
(
float
)(
rand
()
/
1000
));
pstr
+=
sprintf
(
pstr
,
", %10.4f"
,
(
float
)(
t
rand
()
/
1000
));
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"double"
)
==
0
)
{
double
t
=
(
double
)(
rand
()
/
1000000
);
double
t
=
(
double
)(
t
rand
()
/
1000000
);
pstr
+=
sprintf
(
pstr
,
", %20.8f"
,
t
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"bool"
)
==
0
)
{
bool
b
=
rand
()
&
1
;
bool
b
=
t
rand
()
&
1
;
pstr
+=
sprintf
(
pstr
,
", %s"
,
b
?
"true"
:
"false"
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"binary"
)
==
0
)
{
char
s
[
len_of_binary
];
...
...
@@ -1026,7 +1032,7 @@ void rand_string(char *str, int size) {
--
size
;
int
n
;
for
(
n
=
0
;
n
<
size
;
n
++
)
{
int
key
=
rand
()
%
(
int
)(
sizeof
charset
-
1
);
int
key
=
t
rand
()
%
(
int
)(
sizeof
charset
-
1
);
str
[
n
]
=
charset
[
key
];
}
str
[
n
]
=
0
;
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
f2d06f08
...
...
@@ -229,7 +229,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
return
-
1
;
}
strcpy
(
arguments
->
output
,
full_path
.
we_wordv
[
0
]
);
tstrncpy
(
arguments
->
output
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
);
wordfree
(
&
full_path
);
break
;
case
'i'
:
...
...
@@ -411,7 +411,7 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo) {
if
((
row
=
taos_fetch_row
(
result
))
!=
NULL
)
{
isSet
=
true
;
pTableRecordInfo
->
isMetric
=
true
;
strcpy
(
pTableRecordInfo
->
tableRecord
.
metric
,
table
);
tstrncpy
(
pTableRecordInfo
->
tableRecord
.
metric
,
table
,
TSDB_TABLE_NAME_LEN
);
}
taos_free_result
(
result
);
...
...
@@ -642,9 +642,12 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
taos_free_result
(
result
);
lseek
(
fd
,
0
,
SEEK_SET
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
while
(
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
))
>
0
)
{
while
(
1
)
{
ssize_t
ret
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
if
(
ret
<=
0
)
break
;
tableRecord
.
name
[
sizeof
(
tableRecord
.
name
)
-
1
]
=
0
;
tableRecord
.
metric
[
sizeof
(
tableRecord
.
metric
)
-
1
]
=
0
;
taosDumpTable
(
tableRecord
.
name
,
tableRecord
.
metric
,
arguments
,
fp
);
...
...
@@ -807,7 +810,7 @@ int taosGetTableDes(char *table, STableDef *tableDes) {
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
strcpy
(
tableDes
->
name
,
table
);
tstrncpy
(
tableDes
->
name
,
table
,
TSDB_COL_NAME_LEN
);
while
((
row
=
taos_fetch_row
(
result
))
!=
NULL
)
{
strncpy
(
tableDes
->
cols
[
count
].
field
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
...
...
@@ -903,16 +906,19 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
taos_free_result
(
result
);
result
=
NULL
;
lseek
(
fd
,
0
,
SEEK_SET
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
while
(
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
))
>
0
)
{
while
(
1
)
{
ssize_t
ret
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
if
(
ret
<=
0
)
break
;
tableRecord
.
name
[
sizeof
(
tableRecord
.
name
)
-
1
]
=
0
;
tableRecord
.
metric
[
sizeof
(
tableRecord
.
metric
)
-
1
]
=
0
;
taosDumpTable
(
tableRecord
.
name
,
tableRecord
.
metric
,
arguments
,
fp
);
}
tclose
(
fd
);
remove
(
".table.tmp"
);
(
void
)
remove
(
".table.tmp"
);
return
0
;
}
...
...
@@ -1004,7 +1010,7 @@ int taosDumpTableData(FILE *fp, char *tbname, SDumpArguments *arguments) {
break
;
}
}
pstr
+=
sprintf
(
pstr
,
")"
);
sprintf
(
pstr
,
")"
);
count
++
;
fprintf
(
fp
,
"%s"
,
buffer
);
...
...
@@ -1327,7 +1333,7 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
if
((
int
)
wc
<
256
)
{
pbuf
=
stpcpy
(
pbuf
,
ascii_literal_list
[(
int
)
wc
]);
}
else
{
}
else
if
(
byte_width
>
0
)
{
memcpy
(
pbuf
,
pstr
,
byte_width
);
pbuf
+=
byte_width
;
}
...
...
src/os/linux/src/linuxSysPara.c
浏览文件 @
f2d06f08
...
...
@@ -162,7 +162,7 @@ static void taosGetSystemTimezone() {
FILE
*
f
=
fopen
(
"/etc/timezone"
,
"r"
);
char
buf
[
65
]
=
{
0
};
if
(
f
!=
NULL
)
{
fread
(
buf
,
64
,
1
,
f
);
(
void
)
fread
(
buf
,
64
,
1
,
f
);
fclose
(
f
);
}
...
...
@@ -547,7 +547,7 @@ void taosSetCoreDump() {
struct
rlimit
rlim
;
struct
rlimit
rlim_new
;
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
uPrint
(
"the old unlimited para: rlim_cur=%d, rlim_max=%
d"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
uPrint
(
"the old unlimited para: rlim_cur=%d, rlim_max=%
"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
...
...
@@ -559,7 +559,7 @@ void taosSetCoreDump() {
}
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
uPrint
(
"the new unlimited para: rlim_cur=%d, rlim_max=%
d"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
uPrint
(
"the new unlimited para: rlim_cur=%d, rlim_max=%
"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
}
#ifndef _TD_ARM_
...
...
@@ -586,7 +586,7 @@ void taosSetCoreDump() {
uPrint
(
"_sysctl(kern_core_uses_pid) set fail: %s"
,
strerror
(
errno
));
}
uPrint
(
"The old core_uses_pid[%
d
]: %d"
,
old_len
,
old_usespid
);
uPrint
(
"The old core_uses_pid[%
"
PRIu64
"
]: %d"
,
old_len
,
old_usespid
);
old_usespid
=
0
;
...
...
@@ -603,7 +603,7 @@ void taosSetCoreDump() {
uPrint
(
"_sysctl(kern_core_uses_pid) get fail: %s"
,
strerror
(
errno
));
}
uPrint
(
"The new core_uses_pid[%
d
]: %d"
,
old_len
,
old_usespid
);
uPrint
(
"The new core_uses_pid[%
"
PRIu64
"
]: %d"
,
old_len
,
old_usespid
);
#endif
#if 0
...
...
src/util/inc/tutil.h
浏览文件 @
f2d06f08
...
...
@@ -119,6 +119,8 @@ extern "C" {
uint32_t
taosRand
(
void
);
uint32_t
trand
(
void
);
size_t
twcslen
(
const
wchar_t
*
wcs
);
int32_t
strdequote
(
char
*
src
);
...
...
src/util/src/tnote.c
浏览文件 @
f2d06f08
...
...
@@ -128,10 +128,12 @@ int taosOpenNewNote(taosNoteInfo * pNote)
bool
taosCheckNoteIsOpen
(
char
*
noteName
,
taosNoteInfo
*
pNote
)
{
/*
int exist = access(noteName, F_OK);
if (exist != 0) {
return false;
}
*/
int
fd
=
open
(
noteName
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
fd
<
0
)
{
...
...
src/util/src/tutil.c
浏览文件 @
f2d06f08
...
...
@@ -55,6 +55,25 @@ uint32_t taosRand(void)
*/
return
rand
();
}
uint32_t
trand
(
void
)
{
int
fd
;
int
seed
;
fd
=
open
(
"/dev/urandom"
,
0
);
if
(
fd
<
0
)
{
seed
=
time
(
0
);
}
else
{
int
len
=
read
(
fd
,
&
seed
,
sizeof
(
seed
));
if
(
len
<
0
)
{
seed
=
time
(
0
);
}
close
(
fd
);
}
return
(
uint32_t
)
seed
;
}
#endif
size_t
twcslen
(
const
wchar_t
*
wcs
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录