Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
710d41da
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看板
提交
710d41da
编写于
1月 17, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1600]<fix>: return error code to client if importing data from file failed.
上级
da13f686
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
44 deletion
+65
-44
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+65
-44
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
710d41da
...
...
@@ -1409,36 +1409,37 @@ typedef struct SImportFileSupport {
static
void
parseFileSendDataBlock
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
assert
(
param
!=
NULL
&&
tres
!=
NULL
);
char
*
tokenBuf
=
NULL
;
size_t
n
=
0
;
ssize_t
readLen
=
0
;
char
*
line
=
NULL
;
int32_t
count
=
0
;
int32_t
maxRows
=
0
;
FILE
*
fp
=
NULL
;
SSqlObj
*
pSql
=
tres
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SImportFileSupport
*
pSupporter
=
(
SImportFileSupport
*
)
param
;
SImportFileSupport
*
pSupporter
=
(
SImportFileSupport
*
)
param
;
SSqlObj
*
pParentSql
=
pSupporter
->
pSql
;
FILE
*
fp
=
pSupporter
->
fp
;
fp
=
pSupporter
->
fp
;
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
// handle error
assert
(
taos_errno
(
pSql
)
==
code
);
do
{
if
(
code
==
TSDB_CODE_TDB_TABLE_RECONFIGURE
)
{
assert
(
pSql
->
res
.
numOfRows
==
0
);
int32_t
errc
=
fseek
(
fp
,
0
,
SEEK_SET
);
if
(
errc
<
0
)
{
tscError
(
"%p failed to seek SEEK_SET since:%s"
,
pSql
,
tstrerror
(
errno
));
}
else
{
break
;
}
if
(
code
==
TSDB_CODE_TDB_TABLE_RECONFIGURE
)
{
assert
(
pSql
->
res
.
numOfRows
==
0
);
int32_t
ret
=
fseek
(
fp
,
0
,
SEEK_SET
);
if
(
ret
<
0
)
{
tscError
(
"%p failed to seek SEEK_SET since:%s"
,
pSql
,
tstrerror
(
errno
));
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_error
;
}
taos_free_result
(
pSql
);
tfree
(
pSupporter
);
fclose
(
fp
);
}
else
{
pParentSql
->
res
.
code
=
code
;
tscAsyncResultOnError
(
pParentSql
);
return
;
}
while
(
0
);
goto
_error
;
}
}
// accumulate the total submit records
...
...
@@ -1452,28 +1453,32 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
SParsedDataColInfo
spd
=
{.
numOfCols
=
tinfo
.
numOfColumns
};
tscSetAssignedColumnInfo
(
&
spd
,
pSchema
,
tinfo
.
numOfColumns
);
size_t
n
=
0
;
ssize_t
readLen
=
0
;
char
*
line
=
NULL
;
int32_t
count
=
0
;
int32_t
maxRows
=
0
;
tfree
(
pCmd
->
pTableNameList
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
if
(
pCmd
->
pTableBlockHashList
==
NULL
)
{
pCmd
->
pTableBlockHashList
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
);
if
(
pCmd
->
pTableBlockHashList
==
NULL
)
{
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
}
STableDataBlocks
*
pTableDataBlock
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pCmd
->
pTableBlockHashList
,
pTableMeta
->
id
.
uid
,
TSDB_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
tinfo
.
rowSize
,
pTableMetaInfo
->
name
,
pTableMeta
,
&
pTableDataBlock
,
NULL
);
int32_t
ret
=
tscGetDataBlockFromList
(
pCmd
->
pTableBlockHashList
,
pTableMeta
->
id
.
uid
,
TSDB_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
tinfo
.
rowSize
,
pTableMetaInfo
->
name
,
pTableMeta
,
&
pTableDataBlock
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// return ret;
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
tscAllocateMemIfNeed
(
pTableDataBlock
,
tinfo
.
rowSize
,
&
maxRows
);
char
*
tokenBuf
=
calloc
(
1
,
4096
);
tokenBuf
=
calloc
(
1
,
TSDB_MAX_BYTES_PER_ROW
);
if
(
tokenBuf
==
NULL
)
{
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
while
((
readLen
=
tgetline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
if
((
'\r'
==
line
[
readLen
-
1
])
||
(
'\n'
==
line
[
readLen
-
1
]))
{
...
...
@@ -1501,27 +1506,43 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
}
tfree
(
tokenBuf
);
free
(
line
);
t
free
(
line
);
if
(
count
>
0
)
{
code
=
doPackSendDataBlock
(
pSql
,
count
,
pTableDataBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pParentSql
->
res
.
code
=
code
;
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
count
>
0
)
{
code
=
doPackSendDataBlock
(
pSql
,
count
,
pTableDataBlock
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
return
;
}
else
{
pParentSql
->
res
.
code
=
code
;
goto
_error
;
}
}
else
{
pParentSql
->
res
.
code
=
code
;
tscAsyncResultOnError
(
pParentSql
);
taos_free_result
(
pSql
);
tfree
(
pSupporter
);
fclose
(
fp
);
pParentSql
->
fp
=
pParentSql
->
fetchFp
;
// all data has been sent to vnode, call user function
int32_t
v
=
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
?
pParentSql
->
res
.
code
:
(
int32_t
)
pParentSql
->
res
.
numOfRows
;
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
v
);
return
;
}
}
}
else
{
taos_free_result
(
pSql
);
tfree
(
pSupporter
);
fclose
(
fp
);
pParentSql
->
fp
=
pParentSql
->
fetchFp
;
_error:
tfree
(
tokenBuf
);
tfree
(
line
);
taos_free_result
(
pSql
);
tfree
(
pSupporter
);
fclose
(
fp
)
;
// all data has been sent to vnode, call user function
int32_t
v
=
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
?
pParentSql
->
res
.
code
:
(
int32_t
)
pParentSql
->
res
.
numOfRows
;
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
v
);
}
tscAsyncResultOnError
(
pParentSql
);
}
void
tscProcessMultiVnodesImportFromFile
(
SSqlObj
*
pSql
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录