Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
71c02750
T
TDengine
项目概览
慢慢CG
/
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看板
提交
71c02750
编写于
9月 27, 2021
作者:
Z
zhaoyanggh
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/taosdata/TDengine
into fix/TD-10456
上级
d025ec5e
6ef532bd
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
183 addition
and
138 deletion
+183
-138
packaging/tools/make_install.sh
packaging/tools/make_install.sh
+3
-1
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+177
-134
tests/gotest/batchtest.bat
tests/gotest/batchtest.bat
+2
-2
tests/gotest/batchtest.sh
tests/gotest/batchtest.sh
+1
-1
未找到文件。
packaging/tools/make_install.sh
浏览文件 @
71c02750
...
...
@@ -245,6 +245,8 @@ function install_lib() {
else
${
csudo
}
cp
-Rf
${
binary_dir
}
/build/lib/libtaos.
${
verNumber
}
.dylib
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.
*
${
install_main_dir
}
/driver/libtaos.1.dylib
||
:
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.1.dylib
${
install_main_dir
}
/driver/libtaos.dylib
||
:
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.
*
${
lib_link_dir
}
/libtaos.1.dylib
||
:
${
csudo
}
ln
-sf
${
lib_link_dir
}
/libtaos.1.dylib
${
lib_link_dir
}
/libtaos.dylib
||
:
fi
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
71c02750
...
...
@@ -38,8 +38,8 @@
static
int
converStringToReadable
(
char
*
str
,
int
size
,
char
*
buf
,
int
bufsize
);
static
int
convertNCharToReadable
(
char
*
str
,
int
size
,
char
*
buf
,
int
bufsize
);
static
void
taosD
umpCharset
(
FILE
*
fp
);
static
void
taosL
oadFileCharset
(
FILE
*
fp
,
char
*
fcharset
);
static
void
d
umpCharset
(
FILE
*
fp
);
static
void
l
oadFileCharset
(
FILE
*
fp
,
char
*
fcharset
);
typedef
struct
{
short
bytes
;
...
...
@@ -159,7 +159,8 @@ typedef struct {
}
TableRecord
;
typedef
struct
{
bool
isStable
;
bool
isStb
;
bool
belongStb
;
int64_t
dumpNtbCount
;
TableRecord
**
dumpNtbInfos
;
TableRecord
tableRecord
;
...
...
@@ -329,18 +330,19 @@ static resultStatistics g_resultStatistics = {0};
static
FILE
*
g_fpOfResult
=
NULL
;
static
int
g_numOfCores
=
1
;
static
int
taosD
umpOut
();
static
int
taosD
umpIn
();
static
void
taosD
umpCreateDbClause
(
SDbInfo
*
dbInfo
,
bool
isDumpProperty
,
static
int
d
umpOut
();
static
int
d
umpIn
();
static
void
d
umpCreateDbClause
(
SDbInfo
*
dbInfo
,
bool
isDumpProperty
,
FILE
*
fp
);
//static int
taosD
umpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taos);
static
int
dumpStable
(
char
*
table
,
FILE
*
fp
,
SDbInfo
*
dbInfo
);
//static int
d
umpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taos);
static
int
dumpStable
Clasuse
(
SDbInfo
*
dbInfo
,
char
*
table
,
FILE
*
fp
);
static
int
dumpCreateTableClause
(
STableDef
*
tableDes
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
);
static
void
taosD
umpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
static
void
d
umpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
);
static
int64_t
taosDumpTable
(
char
*
tbName
,
char
*
stable
,
FILE
*
fp
,
char
*
dbName
,
int
precision
);
static
int
getTableDes
(
char
*
dbName
,
char
*
table
,
STableDef
*
stableDes
,
bool
isSuperTable
);
static
int64_t
dumpTableData
(
FILE
*
fp
,
char
*
tbName
,
char
*
dbName
,
int
precision
,
...
...
@@ -420,16 +422,16 @@ static void printVersion() {
}
}
UNUSED_FUNC
void
errorWrongValue
(
char
*
program
,
char
*
wrong_arg
,
char
*
wrong_value
)
void
errorWrongValue
(
char
*
program
,
char
*
wrong_arg
,
char
*
wrong_value
)
{
fprintf
(
stderr
,
"%s %s: %s is an invalid value
\n
"
,
program
,
wrong_arg
,
wrong_value
);
fprintf
(
stderr
,
"Try `taosd
emo --help' or `taosdemo
--usage' for more information.
\n
"
);
fprintf
(
stderr
,
"Try `taosd
ump --help' or `taosdump
--usage' for more information.
\n
"
);
}
static
void
errorUnrecognized
(
char
*
program
,
char
*
wrong_arg
)
{
fprintf
(
stderr
,
"%s: unrecognized options '%s'
\n
"
,
program
,
wrong_arg
);
fprintf
(
stderr
,
"Try `taosd
emo --help' or `taosdemo
--usage' for more information.
\n
"
);
fprintf
(
stderr
,
"Try `taosd
ump --help' or `taosdump
--usage' for more information.
\n
"
);
}
static
void
errorPrintReqArg
(
char
*
program
,
char
*
wrong_arg
)
...
...
@@ -438,7 +440,7 @@ static void errorPrintReqArg(char *program, char *wrong_arg)
"%s: option requires an argument -- '%s'
\n
"
,
program
,
wrong_arg
);
fprintf
(
stderr
,
"Try `taosd
emo --help' or `taosdemo
--usage' for more information.
\n
"
);
"Try `taosd
ump --help' or `taosdump
--usage' for more information.
\n
"
);
}
static
void
errorPrintReqArg2
(
char
*
program
,
char
*
wrong_arg
)
...
...
@@ -447,7 +449,7 @@ static void errorPrintReqArg2(char *program, char *wrong_arg)
"%s: option requires a number argument '-%s'
\n
"
,
program
,
wrong_arg
);
fprintf
(
stderr
,
"Try `taosd
emo --help' or `taosdemo
--usage' for more information.
\n
"
);
"Try `taosd
ump --help' or `taosdump
--usage' for more information.
\n
"
);
}
static
void
errorPrintReqArg3
(
char
*
program
,
char
*
wrong_arg
)
...
...
@@ -456,7 +458,7 @@ static void errorPrintReqArg3(char *program, char *wrong_arg)
"%s: option '%s' requires an argument
\n
"
,
program
,
wrong_arg
);
fprintf
(
stderr
,
"Try `taosd
emo --help' or `taosdemo
--usage' for more information.
\n
"
);
"Try `taosd
ump --help' or `taosdump
--usage' for more information.
\n
"
);
}
/* Parse a single option. */
...
...
@@ -483,7 +485,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
errorPrintReqArg2
(
"taosdump"
,
"P"
);
exit
(
EXIT_FAILURE
);
}
g_args
.
port
=
atoi
(
arg
);
uint64_t
port
=
atoi
(
arg
);
if
(
port
>
65535
)
{
errorWrongValue
(
"taosdump"
,
"-P or --port"
,
arg
);
exit
(
EXIT_FAILURE
);
}
g_args
.
port
=
(
uint16_t
)
port
;
break
;
case
'q'
:
g_args
.
mysqlFlag
=
atoi
(
arg
);
...
...
@@ -815,15 +824,20 @@ static int getTableRecordInfo(
while
((
row
=
taos_fetch_row
(
result
))
!=
NULL
)
{
isSet
=
true
;
pTableRecordInfo
->
isSt
able
=
false
;
pTableRecordInfo
->
isSt
b
=
false
;
tstrncpy
(
pTableRecordInfo
->
tableRecord
.
name
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
min
(
TSDB_TABLE_NAME_LEN
,
fields
[
TSDB_SHOW_TABLES_NAME_INDEX
].
bytes
+
1
));
if
(
strlen
((
char
*
)
row
[
TSDB_SHOW_TABLES_METRIC_INDEX
])
>
0
)
{
pTableRecordInfo
->
belongStb
=
true
;
tstrncpy
(
pTableRecordInfo
->
tableRecord
.
stable
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_METRIC_INDEX
],
min
(
TSDB_TABLE_NAME_LEN
,
fields
[
TSDB_SHOW_TABLES_METRIC_INDEX
].
bytes
+
1
));
}
else
{
pTableRecordInfo
->
belongStb
=
false
;
}
break
;
}
...
...
@@ -848,7 +862,7 @@ static int getTableRecordInfo(
while
((
row
=
taos_fetch_row
(
result
))
!=
NULL
)
{
isSet
=
true
;
pTableRecordInfo
->
isSt
able
=
true
;
pTableRecordInfo
->
isSt
b
=
true
;
tstrncpy
(
pTableRecordInfo
->
tableRecord
.
stable
,
table
,
TSDB_TABLE_NAME_LEN
);
break
;
...
...
@@ -951,7 +965,66 @@ static int getDumpDbCount()
return
count
;
}
static
int64_t
dumpNormalTableWithoutStb
(
SDbInfo
*
dbInfo
,
char
*
ntbName
)
static
int
convertSchemaToAvroSchema
(
STableDef
*
stableDes
,
char
**
avroSchema
)
{
errorPrint
(
"%s() LN%d TODO: covert table schema to avro schema
\n
"
,
__func__
,
__LINE__
);
return
0
;
}
static
int64_t
dumpNormalTable
(
char
*
dbName
,
char
*
stable
,
char
*
tbName
,
int
precision
,
FILE
*
fp
)
{
int
colCount
=
0
;
STableDef
*
tableDes
=
(
STableDef
*
)
calloc
(
1
,
sizeof
(
STableDef
)
+
sizeof
(
SColDes
)
*
TSDB_MAX_COLUMNS
);
if
(
stable
!=
NULL
&&
stable
[
0
]
!=
'\0'
)
{
// dump table schema which is created by using super table
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
if
(
colCount
<
0
)
{
errorPrint
(
"%s"
,
"getTableDes() failed
\n
"
);
free
(
tableDes
);
return
-
1
;
}
// create child-table using super-table
dumpCreateMTableClause
(
tableDes
,
stable
,
colCount
,
fp
,
dbName
);
}
else
{
// dump table definition
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
if
(
colCount
<
0
)
{
free
(
tableDes
);
return
-
1
;
}
// create normal-table or super-table
dumpCreateTableClause
(
tableDes
,
colCount
,
fp
,
dbName
);
}
char
*
jsonAvroSchema
=
NULL
;
if
(
g_args
.
avro
)
{
convertSchemaToAvroSchema
(
tableDes
,
&
jsonAvroSchema
);
}
free
(
tableDes
);
int64_t
ret
=
0
;
if
(
!
g_args
.
schemaonly
)
{
ret
=
dumpTableData
(
fp
,
tbName
,
dbName
,
precision
,
jsonAvroSchema
);
}
return
ret
;
}
static
int64_t
dumpNormalTableBelongStb
(
SDbInfo
*
dbInfo
,
char
*
stbName
,
char
*
ntbName
)
{
int64_t
count
=
0
;
...
...
@@ -973,21 +1046,47 @@ static int64_t dumpNormalTableWithoutStb(SDbInfo *dbInfo, char *ntbName)
return
-
1
;
}
count
=
taosDumpTable
(
ntbName
,
NULL
,
fp
,
dbInfo
->
name
,
getPrecisionByString
(
dbInfo
->
precision
));
count
=
dumpNormalTable
(
dbInfo
->
name
,
stbName
,
ntbName
,
getPrecisionByString
(
dbInfo
->
precision
),
fp
);
fclose
(
fp
);
return
count
;
}
static
int64_t
dumpNormalTable
(
FILE
*
fp
,
TAOS
*
taos
,
char
*
dbName
,
char
*
tbName
,
char
*
stbName
,
int
precision
)
static
int64_t
dumpNormalTableWithoutStb
(
SDbInfo
*
dbInfo
,
char
*
ntbName
)
{
int64_t
count
=
0
;
count
=
taosDumpTable
(
tbName
,
stbName
,
fp
,
dbName
,
precision
);
char
tmpBuf
[
4096
]
=
{
0
};
FILE
*
fp
=
NULL
;
if
(
g_args
.
outpath
[
0
]
!=
0
)
{
sprintf
(
tmpBuf
,
"%s/%s.%s.sql"
,
g_args
.
outpath
,
dbInfo
->
name
,
ntbName
);
}
else
{
sprintf
(
tmpBuf
,
"%s.%s.sql"
,
dbInfo
->
name
,
ntbName
);
}
fp
=
fopen
(
tmpBuf
,
"w"
);
if
(
fp
==
NULL
)
{
errorPrint
(
"%s() LN%d, failed to open file %s
\n
"
,
__func__
,
__LINE__
,
tmpBuf
);
return
-
1
;
}
count
=
dumpNormalTable
(
dbInfo
->
name
,
NULL
,
ntbName
,
getPrecisionByString
(
dbInfo
->
precision
),
fp
);
fclose
(
fp
);
return
count
;
}
...
...
@@ -1021,12 +1120,12 @@ static void *dumpNtbOfDb(void *arg) {
debugPrint
(
"[%d] No.
\t
%"
PRId64
" table name: %s
\n
"
,
pThreadInfo
->
threadIndex
,
i
,
((
TableInfo
*
)(
g_tablesList
+
pThreadInfo
->
tableFrom
+
i
))
->
name
);
dumpNormalTable
(
fp
,
pThreadInfo
->
taos
,
dumpNormalTable
(
pThreadInfo
->
dbName
,
((
TableInfo
*
)(
g_tablesList
+
pThreadInfo
->
tableFrom
+
i
))
->
name
,
((
TableInfo
*
)(
g_tablesList
+
pThreadInfo
->
tableFrom
+
i
))
->
stable
,
pThreadInfo
->
precision
);
((
TableInfo
*
)(
g_tablesList
+
pThreadInfo
->
tableFrom
+
i
))
->
name
,
pThreadInfo
->
precision
,
fp
);
}
fclose
(
fp
);
...
...
@@ -1080,12 +1179,12 @@ static void *dumpNormalTablesOfStb(void *arg) {
debugPrint
(
"[%d] sub table %"
PRId64
": name: %s
\n
"
,
pThreadInfo
->
threadIndex
,
i
++
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
]);
dumpNormalTable
(
fp
,
pThreadInfo
->
taos
,
dumpNormalTable
(
pThreadInfo
->
dbName
,
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
pThreadInfo
->
stbName
,
pThreadInfo
->
precision
);
(
char
*
)
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
pThreadInfo
->
precision
,
fp
);
}
fclose
(
fp
);
...
...
@@ -1300,7 +1399,7 @@ static int64_t dumpCreateSTableClauseOfDb(
int64_t
superTblCnt
=
0
;
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
if
(
0
==
dumpStable
(
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
fp
,
dbInfo
))
{
if
(
0
==
dumpStable
Clasuse
(
dbInfo
,
row
[
TSDB_SHOW_TABLES_NAME_INDEX
],
fp
))
{
superTblCnt
++
;
}
}
...
...
@@ -1382,7 +1481,7 @@ static int64_t dumpNTablesOfDb(SDbInfo *dbInfo)
static
int64_t
dumpWholeDatabase
(
SDbInfo
*
dbInfo
,
FILE
*
fp
)
{
taosD
umpCreateDbClause
(
dbInfo
,
g_args
.
with_property
,
fp
);
d
umpCreateDbClause
(
dbInfo
,
g_args
.
with_property
,
fp
);
fprintf
(
g_fpOfResult
,
"
\n
#### database: %s
\n
"
,
dbInfo
->
name
);
...
...
@@ -1393,14 +1492,13 @@ static int64_t dumpWholeDatabase(SDbInfo *dbInfo, FILE *fp)
return
dumpNTablesOfDb
(
dbInfo
);
}
static
int
taosD
umpOut
()
{
static
int
d
umpOut
()
{
TAOS
*
taos
=
NULL
;
TAOS_RES
*
result
=
NULL
;
TAOS_ROW
row
;
FILE
*
fp
=
NULL
;
int32_t
count
=
0
;
TableRecordInfo
tableRecordInfo
;
char
tmpBuf
[
4096
]
=
{
0
};
if
(
g_args
.
outpath
[
0
]
!=
0
)
{
...
...
@@ -1446,7 +1544,7 @@ static int taosDumpOut() {
/* --------------------------------- Main Code -------------------------------- */
/* if (g_args.databases || g_args.all_databases) { // dump part of databases or all databases */
/* */
taosD
umpCharset
(
fp
);
d
umpCharset
(
fp
);
sprintf
(
command
,
"show databases"
);
result
=
taos_query
(
taos
,
command
);
...
...
@@ -1568,11 +1666,13 @@ static int taosDumpOut() {
g_totalDumpOutRows
+=
records
;
}
}
else
{
taosD
umpCreateDbClause
(
g_dbInfos
[
0
],
g_args
.
with_property
,
fp
);
d
umpCreateDbClause
(
g_dbInfos
[
0
],
g_args
.
with_property
,
fp
);
}
int
superTblCnt
=
0
;
for
(
int
i
=
1
;
g_args
.
arg_list
[
i
];
i
++
)
{
TableRecordInfo
tableRecordInfo
;
if
(
getTableRecordInfo
(
g_dbInfos
[
0
]
->
name
,
g_args
.
arg_list
[
i
],
&
tableRecordInfo
)
<
0
)
{
...
...
@@ -1582,14 +1682,24 @@ static int taosDumpOut() {
}
int64_t
records
=
0
;
if
(
tableRecordInfo
.
isStable
)
{
// dump all table of this stable
int
ret
=
dumpStable
(
if
(
tableRecordInfo
.
isStb
)
{
// dump all table of this stable
int
ret
=
dumpStableClasuse
(
g_dbInfos
[
0
],
tableRecordInfo
.
tableRecord
.
stable
,
fp
,
g_dbInfos
[
0
]
);
fp
);
if
(
ret
>=
0
)
{
superTblCnt
++
;
records
=
dumpNtbOfStbByThreads
(
g_dbInfos
[
0
],
g_args
.
arg_list
[
i
]);
}
}
else
if
(
tableRecordInfo
.
belongStb
){
dumpStableClasuse
(
g_dbInfos
[
0
],
tableRecordInfo
.
tableRecord
.
stable
,
fp
);
records
=
dumpNormalTableBelongStb
(
g_dbInfos
[
0
],
tableRecordInfo
.
tableRecord
.
stable
,
g_args
.
arg_list
[
i
]);
}
else
{
records
=
dumpNormalTableWithoutStb
(
g_dbInfos
[
0
],
g_args
.
arg_list
[
i
]);
}
...
...
@@ -1781,74 +1891,7 @@ static int getTableDes(
return
colCount
;
}
static
int
convertSchemaToAvroSchema
(
STableDef
*
stableDes
,
char
**
avroSchema
)
{
errorPrint
(
"%s() LN%d TODO: covert table schema to avro schema
\n
"
,
__func__
,
__LINE__
);
return
0
;
}
static
int64_t
taosDumpTable
(
char
*
tbName
,
char
*
stable
,
FILE
*
fp
,
char
*
dbName
,
int
precision
)
{
int
colCount
=
0
;
STableDef
*
tableDes
=
(
STableDef
*
)
calloc
(
1
,
sizeof
(
STableDef
)
+
sizeof
(
SColDes
)
*
TSDB_MAX_COLUMNS
);
if
(
stable
!=
NULL
&&
stable
[
0
]
!=
'\0'
)
{
// dump table schema which is created by using super table
/*
colCount = getTableDes(stable, tableDes, taos);
if (count < 0) {
free(tableDes);
return -1;
}
dumpCreateTableClause(tableDes, count, fp);
memset(tableDes, 0, sizeof(STableDef) + sizeof(SColDes) * TSDB_MAX_COLUMNS);
*/
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
if
(
colCount
<
0
)
{
free
(
tableDes
);
return
-
1
;
}
// create child-table using super-table
taosDumpCreateMTableClause
(
tableDes
,
stable
,
colCount
,
fp
,
dbName
);
}
else
{
// dump table definition
colCount
=
getTableDes
(
dbName
,
tbName
,
tableDes
,
false
);
if
(
colCount
<
0
)
{
free
(
tableDes
);
return
-
1
;
}
// create normal-table or super-table
dumpCreateTableClause
(
tableDes
,
colCount
,
fp
,
dbName
);
}
char
*
jsonAvroSchema
=
NULL
;
if
(
g_args
.
avro
)
{
convertSchemaToAvroSchema
(
tableDes
,
&
jsonAvroSchema
);
}
free
(
tableDes
);
int64_t
ret
=
0
;
if
(
!
g_args
.
schemaonly
)
{
ret
=
dumpTableData
(
fp
,
tbName
,
dbName
,
precision
,
jsonAvroSchema
);
}
return
ret
;
}
static
void
taosDumpCreateDbClause
(
static
void
dumpCreateDbClause
(
SDbInfo
*
dbInfo
,
bool
isDumpProperty
,
FILE
*
fp
)
{
char
sqlstr
[
TSDB_MAX_SQL_LEN
]
=
{
0
};
...
...
@@ -1870,7 +1913,7 @@ static void taosDumpCreateDbClause(
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
}
static
int
dumpStable
(
char
*
stbName
,
FILE
*
fp
,
SDbInfo
*
dbInfo
)
static
int
dumpStable
Clasuse
(
SDbInfo
*
dbInfo
,
char
*
stbName
,
FILE
*
fp
)
{
uint64_t
sizeOfTableDes
=
(
uint64_t
)(
sizeof
(
STableDef
)
+
sizeof
(
SColDes
)
*
TSDB_MAX_COLUMNS
);
...
...
@@ -1949,7 +1992,7 @@ static int dumpCreateTableClause(STableDef *tableDes, int numOfCols,
return
fprintf
(
fp
,
"%s
\n\n
"
,
sqlstr
);
}
static
void
taosD
umpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
static
void
d
umpCreateMTableClause
(
STableDef
*
tableDes
,
char
*
stable
,
int
numOfCols
,
FILE
*
fp
,
char
*
dbName
)
{
int
counter
=
0
;
int
count_temp
=
0
;
...
...
@@ -2386,7 +2429,7 @@ static int convertNCharToReadable(char *str, int size, char *buf, int bufsize) {
return
0
;
}
static
void
taosD
umpCharset
(
FILE
*
fp
)
{
static
void
d
umpCharset
(
FILE
*
fp
)
{
char
charsetline
[
256
];
(
void
)
fseek
(
fp
,
0
,
SEEK_SET
);
...
...
@@ -2394,7 +2437,7 @@ static void taosDumpCharset(FILE *fp) {
(
void
)
fwrite
(
charsetline
,
strlen
(
charsetline
),
1
,
fp
);
}
static
void
taosL
oadFileCharset
(
FILE
*
fp
,
char
*
fcharset
)
{
static
void
l
oadFileCharset
(
FILE
*
fp
,
char
*
fcharset
)
{
char
*
line
=
NULL
;
size_t
line_size
=
0
;
...
...
@@ -2526,7 +2569,7 @@ static void taosMallocDumpFiles()
}
}
static
void
taosF
reeDumpFiles
()
static
void
f
reeDumpFiles
()
{
for
(
int
i
=
0
;
i
<
g_tsSqlFileNum
;
i
++
)
{
tfree
(
g_tsDumpInSqlFiles
[
i
]);
...
...
@@ -2594,7 +2637,7 @@ static FILE* taosOpenDumpInFile(char *fptr) {
return
f
;
}
static
int
taosD
umpInOneFile
(
TAOS
*
taos
,
FILE
*
fp
,
char
*
fcharset
,
static
int
d
umpInOneFile
(
TAOS
*
taos
,
FILE
*
fp
,
char
*
fcharset
,
char
*
encode
,
char
*
fileName
)
{
int
read_len
=
0
;
char
*
cmd
=
NULL
;
...
...
@@ -2651,7 +2694,7 @@ static int taosDumpInOneFile(TAOS* taos, FILE* fp, char* fcharset,
return
0
;
}
static
void
*
taosD
umpInWorkThreadFp
(
void
*
arg
)
static
void
*
d
umpInWorkThreadFp
(
void
*
arg
)
{
threadInfo
*
pThread
=
(
threadInfo
*
)
arg
;
setThreadName
(
"dumpInWorkThrd"
);
...
...
@@ -2665,14 +2708,14 @@ static void* taosDumpInWorkThreadFp(void *arg)
}
fprintf
(
stderr
,
", Success Open input file: %s
\n
"
,
SQLFileName
);
taosD
umpInOneFile
(
pThread
->
taos
,
fp
,
g_tsCharset
,
g_args
.
encode
,
SQLFileName
);
d
umpInOneFile
(
pThread
->
taos
,
fp
,
g_tsCharset
,
g_args
.
encode
,
SQLFileName
);
}
}
return
NULL
;
}
static
void
taosS
tartDumpInWorkThreads
()
static
void
s
tartDumpInWorkThreads
()
{
pthread_attr_t
thattr
;
threadInfo
*
pThread
;
...
...
@@ -2704,7 +2747,7 @@ static void taosStartDumpInWorkThreads()
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
(
pThread
->
threadID
),
&
thattr
,
taosD
umpInWorkThreadFp
,
(
void
*
)
pThread
)
!=
0
)
{
d
umpInWorkThreadFp
,
(
void
*
)
pThread
)
!=
0
)
{
errorPrint
(
"%s() LN%d, thread:%d failed to start
\n
"
,
__func__
,
__LINE__
,
pThread
->
threadIndex
);
exit
(
0
);
...
...
@@ -2721,7 +2764,7 @@ static void taosStartDumpInWorkThreads()
free
(
threadObj
);
}
static
int
taosD
umpIn
()
{
static
int
d
umpIn
()
{
assert
(
g_args
.
isDumpIn
);
TAOS
*
taos
=
NULL
;
...
...
@@ -2750,19 +2793,19 @@ static int taosDumpIn() {
}
fprintf
(
stderr
,
"Success Open input file: %s
\n
"
,
g_tsDbSqlFile
);
taosL
oadFileCharset
(
fp
,
g_tsCharset
);
l
oadFileCharset
(
fp
,
g_tsCharset
);
taosD
umpInOneFile
(
taos
,
fp
,
g_tsCharset
,
g_args
.
encode
,
d
umpInOneFile
(
taos
,
fp
,
g_tsCharset
,
g_args
.
encode
,
g_tsDbSqlFile
);
}
taos_close
(
taos
);
if
(
0
!=
tsSqlFileNumOfTbls
)
{
taosS
tartDumpInWorkThreads
();
s
tartDumpInWorkThreads
();
}
taosF
reeDumpFiles
();
f
reeDumpFiles
();
return
0
;
}
...
...
@@ -2883,7 +2926,7 @@ int main(int argc, char *argv[]) {
fprintf
(
g_fpOfResult
,
"# DumpIn start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
if
(
taosD
umpIn
()
<
0
)
{
if
(
d
umpIn
()
<
0
)
{
ret
=
-
1
;
}
}
else
{
...
...
@@ -2891,7 +2934,7 @@ int main(int argc, char *argv[]) {
fprintf
(
g_fpOfResult
,
"# DumpOut start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
if
(
taosD
umpOut
()
<
0
)
{
if
(
d
umpOut
()
<
0
)
{
ret
=
-
1
;
}
else
{
fprintf
(
g_fpOfResult
,
"
\n
============================== TOTAL STATISTICS ==============================
\n
"
);
...
...
tests/gotest/batchtest.bat
浏览文件 @
71c02750
...
...
@@ -9,7 +9,7 @@ if "%severIp%"=="" (set severIp=127.0.0.1)
if
"
%serverPort%
"
==
""
(
set
serverPort
=
6030
)
go
env
-w
GO111MODULE
=
on
go
env
-w
GOPROXY
=
https
://goproxy.
io
,
direct
go
env
-w
GOPROXY
=
https
://goproxy.
cn
,
direct
cd
case001
case001
.bat
%severIp%
%serverPort%
...
...
tests/gotest/batchtest.sh
浏览文件 @
71c02750
...
...
@@ -14,7 +14,7 @@ if [ ! -n "$serverPort" ]; then
fi
go
env
-w
GO111MODULE
=
on
go
env
-w
GOPROXY
=
https://goproxy.
io
,direct
go
env
-w
GOPROXY
=
https://goproxy.
cn
,direct
bash ./case001/case001.sh
$severIp
$serverPort
bash ./case002/case002.sh
$severIp
$serverPort
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录