Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr、小李
TDengine
提交
862c7ffc
T
TDengine
项目概览
Mr、小李
/
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,体验更适合开发者的 AI 搜索 >>
提交
862c7ffc
编写于
4月 30, 2020
作者:
L
lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-207,TD-213]
上级
4d6d6fb4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
8 deletion
+48
-8
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+3
-0
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+45
-8
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
862c7ffc
...
...
@@ -1438,6 +1438,9 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) {
pTableDataBlock
->
size
=
sizeof
(
SShellSubmitBlock
);
pTableDataBlock
->
rowSize
=
pMeterMeta
->
rowSize
;
code
=
tscAllocateMemIfNeed
(
pTableDataBlock
,
rowSize
,
&
maxRows
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
return
-
1
;
numOfRows
+=
pSql
->
res
.
numOfRows
;
pSql
->
res
.
numOfRows
=
0
;
count
=
0
;
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
862c7ffc
...
...
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <wordexp.h>
#include <iconv.h>
#include <time.h>
#include "taos.h"
#include "taosmsg.h"
...
...
@@ -162,6 +163,7 @@ static struct argp_option options[] = {
{
"password"
,
'p'
,
"PASSWORD"
,
0
,
"User password to connect to server. Default is taosdata."
,
0
},
{
"port"
,
'P'
,
"PORT"
,
0
,
"Port to connect"
,
0
},
{
"cversion"
,
'v'
,
"CVERION"
,
0
,
"client version"
,
0
},
{
"mysqlFlag"
,
'q'
,
"MYSQLFLAG"
,
0
,
"mysqlFlag, Default is 0"
,
0
},
// input/output file
{
"outpath"
,
'o'
,
"OUTPATH"
,
0
,
"Output file path."
,
1
},
{
"inpath"
,
'i'
,
"INPATH"
,
0
,
"Input file path."
,
1
},
...
...
@@ -189,6 +191,7 @@ struct arguments {
char
*
password
;
uint16_t
port
;
char
cversion
[
TSDB_FILENAME_LEN
+
1
];
uint16_t
mysqlFlag
;
// output file
char
outpath
[
TSDB_FILENAME_LEN
+
1
];
char
inpath
[
TSDB_FILENAME_LEN
+
1
];
...
...
@@ -236,6 +239,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'P'
:
arguments
->
port
=
atoi
(
arg
);
break
;
case
'q'
:
arguments
->
sqlCmdFlag
=
atoi
(
arg
);
break
;
case
'v'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid client vesion %s
\n
"
,
arg
);
...
...
@@ -341,6 +347,7 @@ struct arguments tsArguments = {
"taosdata"
,
0
,
""
,
0
,
// outpath and inpath
""
,
""
,
...
...
@@ -384,7 +391,8 @@ int main(int argc, char *argv[]) {
printf
(
"user: %s
\n
"
,
tsArguments
.
user
);
printf
(
"password: %s
\n
"
,
tsArguments
.
password
);
printf
(
"port: %u
\n
"
,
tsArguments
.
port
);
printf
(
"cversion: %s
\n
"
,
tsArguments
.
cversion
);
printf
(
"cversion: %s
\n
"
,
tsArguments
.
cversion
);
printf
(
"mysqlFlag: %d"
,
tsArguments
.
mysqlFlag
);
printf
(
"outpath: %s
\n
"
,
tsArguments
.
outpath
);
printf
(
"inpath: %s
\n
"
,
tsArguments
.
inpath
);
printf
(
"encode: %s
\n
"
,
tsArguments
.
encode
);
...
...
@@ -918,6 +926,8 @@ void taosDumpCreateDbClause(SDbInfo *dbInfo, bool isDumpProperty, FILE *fp) {
dbInfo
->
ablocks
,
dbInfo
->
tblocks
,
dbInfo
->
ctime
,
dbInfo
->
clog
,
dbInfo
->
comp
);
}
pstr
+=
sprintf
(
pstr
,
";"
);
fprintf
(
fp
,
"%s
\n\n
"
,
tmpCommand
);
free
(
tmpCommand
);
}
...
...
@@ -1236,7 +1246,7 @@ void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, FILE *fp) {
}
}
pstr
+=
sprintf
(
pstr
,
")"
);
pstr
+=
sprintf
(
pstr
,
")
;
"
);
fprintf
(
fp
,
"%s
\n
"
,
tmpBuf
);
...
...
@@ -1289,7 +1299,7 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols
/* } */
}
pstr
+=
sprintf
(
pstr
,
")"
);
pstr
+=
sprintf
(
pstr
,
")
;
"
);
fprintf
(
fp
,
"%s
\n
"
,
tmpBuf
);
free
(
tmpBuf
);
...
...
@@ -1359,14 +1369,31 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS*
return
-
1
;
}
char
sqlStr
[
8
]
=
"
\0
"
;
if
(
arguments
->
mysqlFlag
)
{
sprintf
(
sqlStr
,
"INSERT"
);
}
else
{
sprintf
(
sqlStr
,
"IMPORT"
);
}
int
rowFlag
=
0
;
count
=
0
;
while
((
row
=
taos_fetch_row
(
tmpResult
))
!=
NULL
)
{
pstr
=
tmpBuffer
;
if
(
count
==
0
)
{
pstr
+=
sprintf
(
pstr
,
"IMPORT INTO %s VALUES ("
,
tbname
);
}
else
{
pstr
+=
sprintf
(
pstr
,
"("
);
pstr
+=
sprintf
(
pstr
,
"%s INTO %s VALUES ("
,
sqlStr
,
tbname
);
}
else
{
if
(
arguments
->
mysqlFlag
)
{
if
(
0
==
rowFlag
)
{
pstr
+=
sprintf
(
pstr
,
"("
);
rowFlag
++
;
}
else
{
pstr
+=
sprintf
(
pstr
,
", ("
);
}
}
else
{
pstr
+=
sprintf
(
pstr
,
"("
);
}
}
for
(
int
col
=
0
;
col
<
numFields
;
col
++
)
{
...
...
@@ -1410,12 +1437,22 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS*
pstr
+=
sprintf
(
pstr
,
"
\'
%s
\'
"
,
tbuf
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
pstr
+=
sprintf
(
pstr
,
"%"
PRId64
""
,
*
(
int64_t
*
)
row
[
col
]);
if
(
!
arguments
->
mysqlFlag
)
{
pstr
+=
sprintf
(
pstr
,
"%"
PRId64
""
,
*
(
int64_t
*
)
row
[
col
]);
}
else
{
char
buf
[
64
]
=
"
\0
"
;
int64_t
ts
=
*
((
int64_t
*
)
row
[
col
]);
time_t
tt
=
(
time_t
)(
ts
/
1000
);
struct
tm
*
ptm
=
localtime
(
&
tt
);
strftime
(
buf
,
64
,
"%y-%m-%d %H:%M:%S"
,
ptm
);
pstr
+=
sprintf
(
pstr
,
"
\'
%s.%03d
\'
"
,
buf
,
(
int
)(
ts
%
1000
));
}
break
;
default:
break
;
}
}
pstr
+=
sprintf
(
pstr
,
") "
);
totalRows
++
;
...
...
@@ -1423,7 +1460,7 @@ int taosDumpTableData(FILE *fp, char *tbname, struct arguments *arguments, TAOS*
fprintf
(
fp
,
"%s"
,
tmpBuffer
);
if
(
count
>=
arguments
->
data_batch
)
{
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
;
\n
"
);
count
=
0
;
}
//else {
//fprintf(fp, "\\\n");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录