Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
KASAKI11
TDengine
提交
d9c8642d
T
TDengine
项目概览
KASAKI11
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d9c8642d
编写于
8月 04, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
8月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2910 from taosdata/hotfix/lihui
Hotfix/lihui
上级
9747bdd4
562c195c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
39 deletion
+61
-39
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+57
-35
src/util/src/version.c
src/util/src/version.c
+4
-4
未找到文件。
src/kit/taosdump/taosdump.c
浏览文件 @
d9c8642d
...
...
@@ -29,6 +29,7 @@
#include <iconv.h>
#include <time.h>
#include "os.h"
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
...
...
@@ -191,7 +192,7 @@ struct arguments {
char
*
user
;
char
*
password
;
uint16_t
port
;
char
cversion
[
TSDB_FILENAME_LEN
+
1
];
char
cversion
[
12
];
uint16_t
mysqlFlag
;
// output file
char
outpath
[
TSDB_FILENAME_LEN
+
1
];
...
...
@@ -248,7 +249,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf
(
stderr
,
"Invalid client vesion %s
\n
"
,
arg
);
return
-
1
;
}
strcpy
(
arguments
->
cversion
,
full_path
.
we_wordv
[
0
]
);
tstrncpy
(
arguments
->
cversion
,
full_path
.
we_wordv
[
0
],
11
);
wordfree
(
&
full_path
);
break
;
// output file path
...
...
@@ -257,7 +258,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
->
outpath
,
full_path
.
we_wordv
[
0
]
);
tstrncpy
(
arguments
->
outpath
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
);
wordfree
(
&
full_path
);
break
;
case
'i'
:
...
...
@@ -266,7 +267,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
->
inpath
,
full_path
.
we_wordv
[
0
]
);
tstrncpy
(
arguments
->
inpath
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
);
wordfree
(
&
full_path
);
break
;
case
'c'
:
...
...
@@ -430,7 +431,7 @@ int main(int argc, char *argv[]) {
printf
(
"==============================
\n
"
);
if
(
tsArguments
.
cversion
[
0
]
!=
0
){
strcpy
(
version
,
tsArguments
.
cversion
);
tstrncpy
(
version
,
tsArguments
.
cversion
,
11
);
}
if
(
taosCheckParam
(
&
tsArguments
)
<
0
)
{
...
...
@@ -513,7 +514,7 @@ int taosGetTableRecordInfo(char *table, STableRecordInfo *pTableRecordInfo, TAOS
while
((
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
);
break
;
}
...
...
@@ -541,9 +542,9 @@ int32_t taosSaveAllNormalTableToTempFile(TAOS *taosCon, char*meter, char* metric
}
}
memset
(
tableRecord
.
name
,
0
,
sizeof
(
STableRecord
));
strcpy
(
tableRecord
.
name
,
meter
);
strcpy
(
tableRecord
.
metric
,
metric
);
memset
(
&
tableRecord
,
0
,
sizeof
(
STableRecord
));
tstrncpy
(
tableRecord
.
name
,
meter
,
TSDB_TABLE_NAME_LEN
);
tstrncpy
(
tableRecord
.
metric
,
metric
,
TSDB_TABLE_NAME_LEN
);
taosTWrite
(
*
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
return
0
;
...
...
@@ -587,7 +588,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
taos_free_result
(
result
);
for
(
int32_t
loopCnt
=
0
;
loopCnt
<
numOfThread
;
loopCnt
++
)
{
sprintf
(
tmpFileName
,
".tables.tmp.%d"
,
loopCnt
);
remove
(
tmpFileName
);
(
void
)
remove
(
tmpFileName
);
}
free
(
tmpCommand
);
return
-
1
;
...
...
@@ -597,8 +598,8 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
}
memset
(
tableRecord
.
name
,
0
,
sizeof
(
STableRecord
));
strncpy
(
tableRecord
.
name
,
(
char
*
)
row
[
0
],
fields
[
0
].
bytes
);
strcpy
(
tableRecord
.
metric
,
metric
);
t
strncpy
(
tableRecord
.
name
,
(
char
*
)
row
[
0
],
fields
[
0
].
bytes
);
tstrncpy
(
tableRecord
.
metric
,
metric
,
TSDB_TABLE_NAME_LEN
);
taosTWrite
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
...
...
@@ -606,12 +607,16 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
if
(
numOfTable
>=
arguments
->
table_batch
)
{
numOfTable
=
0
;
taosC
lose
(
fd
);
c
lose
(
fd
);
fd
=
-
1
;
}
}
taosClose
(
fd
);
fd
=
-
1
;
if
(
fd
>=
0
)
{
close
(
fd
);
fd
=
-
1
;
}
taos_free_result
(
result
);
*
totalNumOfThread
=
numOfThread
;
...
...
@@ -852,7 +857,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
tmpResult
);
strcpy
(
tableDes
->
name
,
table
);
tstrncpy
(
tableDes
->
name
,
table
,
TSDB_COL_NAME_LEN
);
while
((
row
=
taos_fetch_row
(
tmpResult
))
!=
NULL
)
{
strncpy
(
tableDes
->
cols
[
count
].
field
,
(
char
*
)
row
[
TSDB_DESCRIBE_METRIC_FIELD_INDEX
],
...
...
@@ -1056,6 +1061,7 @@ void* taosDumpOutWorkThreadFp(void *arg)
fp
=
fopen
(
tmpFileName
,
"w"
);
if
(
fp
==
NULL
)
{
fprintf
(
stderr
,
"failed to open file %s
\n
"
,
tmpFileName
);
close
(
fd
);
return
NULL
;
}
...
...
@@ -1067,16 +1073,20 @@ void* taosDumpOutWorkThreadFp(void *arg)
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"invalid database %s
\n
"
,
pThread
->
dbName
);
taos_free_result
(
tmpResult
);
fclose
(
fp
);
close
(
fd
);
return
NULL
;
}
fprintf
(
fp
,
"USE %s
\n\n
"
,
pThread
->
dbName
);
while
(
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
))
>
0
)
{
while
(
1
)
{
ssize_t
readLen
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
if
(
readLen
<=
0
)
break
;
taosDumpTable
(
tableRecord
.
name
,
tableRecord
.
metric
,
&
tsArguments
,
fp
,
pThread
->
taosCon
);
}
taos_free_result
(
tmpResult
);
taosC
lose
(
fd
);
c
lose
(
fd
);
fclose
(
fp
);
return
NULL
;
...
...
@@ -1090,7 +1100,7 @@ static void taosStartDumpOutWorkThreads(struct arguments* args, int32_t numOfTh
SThreadParaObj
*
pThread
=
threadObj
+
t
;
pThread
->
threadIndex
=
t
;
pThread
->
totalThreads
=
numOfThread
;
strcpy
(
pThread
->
dbName
,
dbName
);
tstrncpy
(
pThread
->
dbName
,
dbName
,
TSDB_TABLE_NAME_LEN
);
pThread
->
taosCon
=
taos_connect
(
args
->
host
,
args
->
user
,
args
->
password
,
NULL
,
args
->
port
);
if
(
pThread
->
taosCon
==
NULL
)
{
...
...
@@ -1189,7 +1199,7 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp)
fprintf
(
stderr
,
"failed to open temp file: %s
\n
"
,
tmpFileName
);
taos_free_result
(
tmpResult
);
free
(
tmpCommand
);
remove
(
".stables.tmp"
);
(
void
)
remove
(
".stables.tmp"
);
exit
(
-
1
);
}
...
...
@@ -1200,14 +1210,17 @@ int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp)
}
taos_free_result
(
tmpResult
);
lseek
(
fd
,
0
,
SEEK_SET
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
while
(
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
))
>
0
)
{
while
(
1
)
{
ssize_t
readLen
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
if
(
readLen
<=
0
)
break
;
(
void
)
taosDumpStable
(
tableRecord
.
name
,
fp
,
taosCon
);
}
taosC
lose
(
fd
);
remove
(
".stables.tmp"
);
c
lose
(
fd
);
(
void
)
remove
(
".stables.tmp"
);
free
(
tmpCommand
);
return
0
;
...
...
@@ -1269,7 +1282,7 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
taos_free_result
(
tmpResult
);
for
(
int32_t
loopCnt
=
0
;
loopCnt
<
numOfThread
;
loopCnt
++
)
{
sprintf
(
tmpFileName
,
".tables.tmp.%d"
,
loopCnt
);
remove
(
tmpFileName
);
(
void
)
remove
(
tmpFileName
);
}
free
(
tmpCommand
);
return
-
1
;
...
...
@@ -1279,8 +1292,8 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
}
memset
(
&
tableRecord
,
0
,
sizeof
(
STableRecord
));
strncpy
(
tableRecord
.
name
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
fields
[
TSDB_SHOW_TABLES_NAME_INDEX
].
bytes
);
strncpy
(
tableRecord
.
metric
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_METRIC_INDEX
],
fields
[
TSDB_SHOW_TABLES_METRIC_INDEX
].
bytes
);
t
strncpy
(
tableRecord
.
name
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
fields
[
TSDB_SHOW_TABLES_NAME_INDEX
].
bytes
);
t
strncpy
(
tableRecord
.
metric
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_METRIC_INDEX
],
fields
[
TSDB_SHOW_TABLES_METRIC_INDEX
].
bytes
);
taosTWrite
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
...
...
@@ -1288,19 +1301,23 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
if
(
numOfTable
>=
arguments
->
table_batch
)
{
numOfTable
=
0
;
taosC
lose
(
fd
);
c
lose
(
fd
);
fd
=
-
1
;
}
}
taosClose
(
fd
);
fd
=
-
1
;
if
(
fd
>=
0
)
{
close
(
fd
);
fd
=
-
1
;
}
taos_free_result
(
tmpResult
);
// start multi threads to dumpout
taosStartDumpOutWorkThreads
(
arguments
,
numOfThread
,
dbInfo
->
name
);
for
(
int
loopCnt
=
0
;
loopCnt
<
numOfThread
;
loopCnt
++
)
{
sprintf
(
tmpFileName
,
".tables.tmp.%d"
,
loopCnt
);
remove
(
tmpFileName
);
(
void
)
remove
(
tmpFileName
);
}
free
(
tmpCommand
);
...
...
@@ -1718,6 +1735,10 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
while
(
size
>
0
)
{
if
(
*
pstr
==
'\0'
)
break
;
int
byte_width
=
mbtowc
(
&
wc
,
pstr
,
MB_CUR_MAX
);
if
(
byte_width
<
0
)
{
fprintf
(
stderr
,
"mbtowc() return fail.
\n
"
);
exit
(
-
1
);
}
if
((
int
)
wc
<
256
)
{
pbuf
=
stpcpy
(
pbuf
,
ascii_literal_list
[(
int
)
wc
]);
...
...
@@ -1736,16 +1757,16 @@ int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
void
taosDumpCharset
(
FILE
*
fp
)
{
char
charsetline
[
256
];
fseek
(
fp
,
0
,
SEEK_SET
);
(
void
)
fseek
(
fp
,
0
,
SEEK_SET
);
sprintf
(
charsetline
,
"#!%s
\n
"
,
tsCharset
);
fwrite
(
charsetline
,
strlen
(
charsetline
),
1
,
fp
);
(
void
)
fwrite
(
charsetline
,
strlen
(
charsetline
),
1
,
fp
);
}
void
taosLoadFileCharset
(
FILE
*
fp
,
char
*
fcharset
)
{
char
*
line
=
NULL
;
size_t
line_size
=
0
;
fseek
(
fp
,
0
,
SEEK_SET
);
(
void
)
fseek
(
fp
,
0
,
SEEK_SET
);
ssize_t
size
=
getline
(
&
line
,
&
line_size
,
fp
);
if
(
size
<=
2
)
{
goto
_exit_no_charset
;
...
...
@@ -1764,7 +1785,7 @@ void taosLoadFileCharset(FILE *fp, char *fcharset) {
return
;
_exit_no_charset:
fseek
(
fp
,
0
,
SEEK_SET
);
(
void
)
fseek
(
fp
,
0
,
SEEK_SET
);
*
fcharset
=
'\0'
;
taosTFree
(
line
);
return
;
...
...
@@ -1825,6 +1846,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch
if
(
fileNum
!=
totalFiles
)
{
fprintf
(
stderr
,
"ERROR: directory:%s changed while read
\n
"
,
directoryName
);
pclose
(
fp
);
exit
(
0
);
}
...
...
src/util/src/version.c
浏览文件 @
d9c8642d
char
version
[
12
]
=
"2.0.0.0"
;
char
compatible_version
[
12
]
=
"2.0.0.0"
;
char
gitinfo
[
48
]
=
"
3264067e97300c84caa61ac909d548c9ca56de6b
"
;
char
gitinfoOfInternal
[
48
]
=
"
da88f4a2474737d1f9c76adcf0ff7fd0975e7342
"
;
char
buildinfo
[
64
]
=
"Built by root at 2020-0
4-01 14:38
"
;
char
gitinfo
[
48
]
=
"
8df8b7d9930342dd34ba13df160a7d538fad7bc7
"
;
char
gitinfoOfInternal
[
48
]
=
"
bad4f040145fba581d1ab0c5dd718a5ede3e209f
"
;
char
buildinfo
[
64
]
=
"Built by root at 2020-0
8-03 17:23
"
;
void
libtaos_
1_6_5_4
_Linux_x64
()
{};
void
libtaos_
2_0_0_0
_Linux_x64
()
{};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录