Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
7be8c365
O
oceanbase
项目概览
Metz
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7be8c365
编写于
8月 26, 2021
作者:
B
bf0
提交者:
wangzelin.wzl
8月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix load data parser bug
上级
ca421cf8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
33 deletion
+29
-33
src/sql/engine/cmd/ob_load_data_impl.cpp
src/sql/engine/cmd/ob_load_data_impl.cpp
+18
-24
src/sql/engine/cmd/ob_load_data_impl.h
src/sql/engine/cmd/ob_load_data_impl.h
+9
-9
src/sql/resolver/cmd/ob_load_data_resolver.cpp
src/sql/resolver/cmd/ob_load_data_resolver.cpp
+2
-0
未找到文件。
src/sql/engine/cmd/ob_load_data_impl.cpp
浏览文件 @
7be8c365
...
@@ -1264,29 +1264,29 @@ int ObCSVParser::next_line(bool& yield_line)
...
@@ -1264,29 +1264,29 @@ int ObCSVParser::next_line(bool& yield_line)
bool
yield
=
false
;
bool
yield
=
false
;
int
with_back_slash
=
0
;
int
with_back_slash
=
0
;
for
(;
!
yield
&&
cur_pos_
!=
buf_end_pos_
;
++
cur_pos_
)
{
for
(;
!
yield
&&
cur_pos_
!=
buf_end_pos_
;
++
cur_pos_
,
++
cur_field_end_pos_
)
{
bool
line_term_matched
=
false
;
if
(
*
cur_pos_
==
formats_
.
enclose_char_
&&
!
in_enclose_flag_
&&
cur_pos_
==
cur_field_begin_pos_
)
{
if
(
*
cur_pos_
==
formats_
.
enclose_char_
&&
!
in_enclose_flag_
&&
cur_pos_
==
cur_field_begin_pos_
)
{
in_enclose_flag_
=
true
;
in_enclose_flag_
=
true
;
}
last_end_enclosed_
=
NULL
;
}
else
if
((
*
cur_pos_
==
formats_
.
escape_char_
&&
formats_
.
escape_char_
!=
formats_
.
enclose_char_
)
||
if
(
!
is_escaped_flag_
&&
*
cur_pos_
==
formats_
.
escape_char_
)
{
(
in_enclose_flag_
&&
formats_
.
enclose_char_
==
*
cur_pos_
&&
cur_pos_
<
buf_end_pos_
&&
is_escaped_flag_
=
true
;
formats_
.
enclose_char_
==
*
(
cur_pos_
+
1
)))
{
}
else
{
if
(
cur_pos_
<
buf_end_pos_
)
{
char
escaped_res
=
*
cur_pos_
;
cur_pos_
++
;
if
(
is_escaped_flag_
)
{
if
(
!
is_fast_parse_
)
{
escaped_res
=
escaped_char
(
*
cur_pos_
,
&
with_back_slash
);
*
cur_field_end_pos_
=
escaped_char
(
*
cur_pos_
,
&
with_back_slash
);
}
}
}
bool
has_escaped
=
cur_field_end_pos_
!=
cur_pos_
;
}
else
{
if
(
has_escaped
&&
!
is_fast_parse_
)
{
if
(
cur_field_end_pos_
!=
cur_pos_
&&
!
is_fast_parse_
)
{
*
cur_field_end_pos_
=
escaped_res
;
*
cur_field_end_pos_
=
*
cur_pos_
;
}
}
if
(
formats_
.
enclose_char_
==
*
cur_pos_
)
{
bool
line_term_matched
=
false
;
last_end_enclosed_
=
cur_field_end_pos_
;
}
else
if
(
is_terminate_char
(
*
cur_pos_
,
cur_field_end_pos_
,
line_term_matched
))
{
if
(
is_terminate_char
(
*
cur_pos_
,
cur_field_end_pos_
,
line_term_matched
))
{
if
(
!
line_term_matched
||
cur_field_begin_pos_
<
cur_pos_
)
{
if
(
!
line_term_matched
||
cur_field_begin_pos_
<
cur_pos_
)
{
handle_one_field
(
cur_field_end_pos_
,
has_escaped
);
handle_one_field
(
cur_field_end_pos_
,
cur_field_end_pos_
!=
cur_pos_
);
field_id_
++
;
field_id_
++
;
}
}
char
*
next_pos
=
cur_pos_
+
1
;
char
*
next_pos
=
cur_pos_
+
1
;
...
@@ -1303,12 +1303,6 @@ int ObCSVParser::next_line(bool& yield_line)
...
@@ -1303,12 +1303,6 @@ int ObCSVParser::next_line(bool& yield_line)
cur_line_begin_pos_
=
next_pos
;
cur_line_begin_pos_
=
next_pos
;
}
}
}
}
if
(
is_escaped_flag_
)
{
is_escaped_flag_
=
false
;
}
++
cur_field_end_pos_
;
}
}
}
}
...
...
src/sql/engine/cmd/ob_load_data_impl.h
浏览文件 @
7be8c365
...
@@ -542,6 +542,7 @@ public:
...
@@ -542,6 +542,7 @@ public:
cur_line_begin_pos_
=
NULL
;
cur_line_begin_pos_
=
NULL
;
buf_begin_pos_
=
NULL
;
buf_begin_pos_
=
NULL
;
buf_end_pos_
=
NULL
;
buf_end_pos_
=
NULL
;
last_end_enclosed_
=
NULL
;
field_id_
=
0
;
field_id_
=
0
;
in_enclose_flag_
=
false
;
in_enclose_flag_
=
false
;
is_escaped_flag_
=
false
;
is_escaped_flag_
=
false
;
...
@@ -590,12 +591,13 @@ private:
...
@@ -590,12 +591,13 @@ private:
common
::
ObBitSet
<>
string_type_column_
;
common
::
ObBitSet
<>
string_type_column_
;
// parsing state variables
// parsing state variables
bool
is_last_buf_
;
bool
is_last_buf_
;
char
*
cur_pos_
;
char
*
cur_pos_
;
char
*
cur_field_begin_pos_
;
char
*
cur_field_begin_pos_
;
char
*
cur_field_end_pos_
;
char
*
cur_field_end_pos_
;
char
*
cur_line_begin_pos_
;
char
*
cur_line_begin_pos_
;
char
*
buf_begin_pos_
;
char
*
buf_begin_pos_
;
char
*
buf_end_pos_
;
char
*
buf_end_pos_
;
char
*
last_end_enclosed_
;
int64_t
field_id_
;
int64_t
field_id_
;
bool
in_enclose_flag_
;
bool
in_enclose_flag_
;
bool
is_escaped_flag_
;
bool
is_escaped_flag_
;
...
@@ -643,10 +645,8 @@ OB_INLINE bool ObCSVParser::is_terminate_char(char cur_char, char*& cur_pos, boo
...
@@ -643,10 +645,8 @@ OB_INLINE bool ObCSVParser::is_terminate_char(char cur_char, char*& cur_pos, boo
if
(
!
in_enclose_flag_
)
{
if
(
!
in_enclose_flag_
)
{
ret_bool
=
true
;
// return true
ret_bool
=
true
;
// return true
}
else
{
}
else
{
char
*
pre_pos
=
cur_pos
-
1
;
// with in_enclose_flag_ = true, a term char is valid only if an enclosed char before it
// with in_enclose_flag_ = true, a term char is valid only if an enclosed char before it
if
(
static_cast
<
int64_t
>
(
*
pre_pos
)
==
formats_
.
enclose_char_
&&
if
(
last_end_enclosed_
==
cur_pos
-
1
)
{
cur_field_begin_pos_
!=
pre_pos
)
{
// 123---->'---->123
remove_enclosed_char
(
cur_pos
);
remove_enclosed_char
(
cur_pos
);
ret_bool
=
true
;
// return true
ret_bool
=
true
;
// return true
}
else
{
}
else
{
...
...
src/sql/resolver/cmd/ob_load_data_resolver.cpp
浏览文件 @
7be8c365
...
@@ -534,12 +534,14 @@ int ObLoadDataResolver::validate_stmt(ObLoadDataStmt* stmt)
...
@@ -534,12 +534,14 @@ int ObLoadDataResolver::validate_stmt(ObLoadDataStmt* stmt)
escape_char
=
(
data_struct_in_file
.
field_escaped_str_
.
empty
()
escape_char
=
(
data_struct_in_file
.
field_escaped_str_
.
empty
()
?
INT64_MAX
?
INT64_MAX
:
static_cast
<
int64_t
>
(
data_struct_in_file
.
field_escaped_str_
[
0
]));
:
static_cast
<
int64_t
>
(
data_struct_in_file
.
field_escaped_str_
[
0
]));
/*
if (OB_SUCC(ret)) {
if (OB_SUCC(ret)) {
if (escape_char != ObDataInFileStruct::DEFAULT_FIELD_ESCAPED_CHAR) {
if (escape_char != ObDataInFileStruct::DEFAULT_FIELD_ESCAPED_CHAR) {
ret = OB_WRONG_FIELD_TERMINATORS;
ret = OB_WRONG_FIELD_TERMINATORS;
LOG_USER_ERROR(OB_WRONG_FIELD_TERMINATORS);
LOG_USER_ERROR(OB_WRONG_FIELD_TERMINATORS);
}
}
}
}
*/
if
(
OB_SUCC
(
ret
))
{
if
(
OB_SUCC
(
ret
))
{
const
char
*
is_ambiguous_field_sep
=
strchr
(
"ntrb0ZN"
,
static_cast
<
int
>
(
field_sep_char
));
const
char
*
is_ambiguous_field_sep
=
strchr
(
"ntrb0ZN"
,
static_cast
<
int
>
(
field_sep_char
));
const
char
*
is_unsafe_field_sep
=
strchr
(
".0123456789e+-"
,
static_cast
<
int
>
(
field_sep_char
));
const
char
*
is_unsafe_field_sep
=
strchr
(
".0123456789e+-"
,
static_cast
<
int
>
(
field_sep_char
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录