Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
79091854
O
oceanbase
项目概览
大炮V587
/
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,发现更多精彩内容 >>
提交
79091854
编写于
3月 13, 2023
作者:
O
obdev
提交者:
ob-robot
3月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix regexp function type deduce bug
上级
fa5905f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
26 deletion
+34
-26
src/sql/engine/expr/ob_expr_regexp_context.cpp
src/sql/engine/expr/ob_expr_regexp_context.cpp
+9
-16
src/sql/engine/expr/ob_expr_regexp_replace.cpp
src/sql/engine/expr/ob_expr_regexp_replace.cpp
+13
-6
src/sql/engine/expr/ob_expr_regexp_substr.cpp
src/sql/engine/expr/ob_expr_regexp_substr.cpp
+12
-4
未找到文件。
src/sql/engine/expr/ob_expr_regexp_context.cpp
浏览文件 @
79091854
...
...
@@ -19,6 +19,7 @@
#include "lib/charset/ob_charset.h"
#include "sql/engine/expr/ob_expr_regexp_context.h"
#include "sql/engine/expr/ob_expr_util.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/session/ob_sql_session_info.h"
namespace
oceanbase
{
...
...
@@ -845,24 +846,16 @@ int ObExprRegexContext::check_need_utf8(ObRawExpr *expr, bool &need_utf8)
{
int
ret
=
OB_SUCCESS
;
need_utf8
=
false
;
if
(
OB_ISNULL
(
expr
))
{
const
ObRawExpr
*
real_expr
=
NULL
;
if
(
OB_FAIL
(
ObRawExprUtils
::
get_real_expr_without_cast
(
expr
,
real_expr
)))
{
LOG_WARN
(
"fail to get real expr without cast"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
real_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected null expr"
,
K
(
ret
));
}
else
if
(
T_FUN_SYS_CAST
==
expr
->
get_expr_type
()
&&
expr
->
has_flag
(
IS_INNER_ADDED_EXPR
))
{
ObRawExpr
*
real_expr
=
expr
->
get_param_expr
(
0
);
if
(
OB_ISNULL
(
real_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected null pattern"
,
K
(
ret
));
}
else
{
need_utf8
=
real_expr
->
get_result_type
().
is_nchar
()
||
real_expr
->
get_result_type
().
is_nvarchar2
()
||
real_expr
->
get_result_type
().
is_blob
();
}
LOG_WARN
(
"real expr is invalid"
,
K
(
ret
),
K
(
real_expr
));
}
else
{
need_utf8
=
expr
->
get_result_type
().
is_nchar
()
||
expr
->
get_result_type
().
is_nvarchar2
()
||
expr
->
get_result_type
().
is_blob
();
need_utf8
=
real_
expr
->
get_result_type
().
is_nchar
()
||
real_
expr
->
get_result_type
().
is_nvarchar2
()
||
real_
expr
->
get_result_type
().
is_blob
();
}
return
ret
;
}
...
...
src/sql/engine/expr/ob_expr_regexp_replace.cpp
浏览文件 @
79091854
...
...
@@ -22,6 +22,7 @@
#include "sql/engine/expr/ob_expr_regexp_count.h"
#include "sql/engine/expr/ob_expr_operator.h"
#include "sql/engine/expr/ob_expr_lob_utils.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
using
namespace
oceanbase
::
common
;
...
...
@@ -48,6 +49,7 @@ int ObExprRegexpReplace::calc_result_typeN(ObExprResType &type,
ObRawExpr
*
raw_expr
=
type_ctx
.
get_raw_expr
();
CK
(
NULL
!=
type_ctx
.
get_raw_expr
());
int64_t
max_allowed_packet
=
0
;
const
ObRawExpr
*
real_expr
=
NULL
;
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
OB_UNLIKELY
(
param_num
<
2
||
param_num
>
6
))
{
ret
=
OB_ERR_PARAM_SIZE
;
...
...
@@ -57,7 +59,13 @@ int ObExprRegexpReplace::calc_result_typeN(ObExprResType &type,
LOG_WARN
(
"get unexpected null"
,
K
(
ret
),
K
(
type_ctx
.
get_session
()));
}
else
if
(
OB_FAIL
(
type_ctx
.
get_session
()
->
get_max_allowed_packet
(
max_allowed_packet
)))
{
LOG_WARN
(
"failed to get max allowed packet"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObRawExprUtils
::
get_real_expr_without_cast
(
raw_expr
->
get_param_expr
(
0
),
real_expr
)))
{
LOG_WARN
(
"fail to get real expr without cast"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
real_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"real expr is invalid"
,
K
(
ret
),
K
(
real_expr
));
}
else
{
const
ObExprResType
&
text
=
real_expr
->
get_result_type
();
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
param_num
;
i
++
)
{
if
(
!
types
[
i
].
is_null
()
&&
!
is_type_valid
(
types
[
i
].
get_type
()))
{
ret
=
OB_INVALID_ARGUMENT
;
...
...
@@ -67,14 +75,13 @@ int ObExprRegexpReplace::calc_result_typeN(ObExprResType &type,
if
(
OB_SUCC
(
ret
))
{
if
(
lib
::
is_oracle_mode
())
{
//deduce length
ObExprResType
&
text
=
types
[
0
];
int64_t
to_len
=
types
[
2
].
get_length
();
common
::
ObLength
len
=
text
.
get_length
();
int64_t
offset
=
len
*
to_len
;
len
=
static_cast
<
common
::
ObLength
>
(
len
+
offset
);
CK
(
len
<=
INT32_MAX
);
type
.
set_length
(
static_cast
<
common
::
ObLength
>
(
len
));
auto
input_params
=
make_const_carray
(
&
types
[
0
]
);
auto
input_params
=
make_const_carray
(
const_cast
<
ObExprResType
*>
(
&
text
)
);
OZ
(
aggregate_string_type_and_charset_oracle
(
*
type_ctx
.
get_session
(),
input_params
,
type
,
PREFER_VAR_LEN_CHAR
));
OZ
(
deduce_string_param_calc_type_and_charset
(
*
type_ctx
.
get_session
(),
type
,
input_params
));
...
...
@@ -83,15 +90,15 @@ int ObExprRegexpReplace::calc_result_typeN(ObExprResType &type,
const
common
::
ObLengthSemantics
default_length_semantics
=
(
OB_NOT_NULL
(
type_ctx
.
get_session
())
?
type_ctx
.
get_session
()
->
get_actual_nls_length_semantics
()
:
common
::
LS_BYTE
);
if
(
t
ypes
[
0
]
.
is_lob
())
{
type
.
set_type
(
t
ypes
[
0
]
.
get_type
());
if
(
t
ext
.
is_lob
())
{
type
.
set_type
(
t
ext
.
get_type
());
}
else
{
type
.
set_clob
();
type
.
set_length_semantics
(
t
ypes
[
0
].
is_varchar_or_char
()
?
types
[
0
]
.
get_length_semantics
()
:
default_length_semantics
);
type
.
set_length_semantics
(
t
ext
.
is_varchar_or_char
()
?
text
.
get_length_semantics
()
:
default_length_semantics
);
}
//建表列的最大长度
type
.
set_length
(
max_allowed_packet
);
ret
=
aggregate_charsets_for_string_result
(
type
,
types
,
1
,
type_ctx
.
get_coll_type
());
ret
=
aggregate_charsets_for_string_result
(
type
,
&
text
,
1
,
type_ctx
.
get_coll_type
());
}
}
if
(
OB_SUCC
(
ret
))
{
...
...
src/sql/engine/expr/ob_expr_regexp_substr.cpp
浏览文件 @
79091854
...
...
@@ -20,6 +20,7 @@
#include "sql/engine/expr/ob_expr_util.h"
#include "sql/engine/expr/ob_expr_regexp_count.h"
#include "sql/engine/expr/ob_expr_lob_utils.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
using
namespace
oceanbase
::
common
;
...
...
@@ -45,12 +46,19 @@ int ObExprRegexpSubstr::calc_result_typeN(ObExprResType &type,
UNUSED
(
type_ctx
);
int
ret
=
OB_SUCCESS
;
ObRawExpr
*
raw_expr
=
type_ctx
.
get_raw_expr
();
const
ObRawExpr
*
real_expr
=
NULL
;
CK
(
NULL
!=
type_ctx
.
get_raw_expr
());
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
OB_UNLIKELY
(
param_num
<
2
||
param_num
>
6
))
{
ret
=
OB_ERR_PARAM_SIZE
;
LOG_WARN
(
"param number of regexp_substr at least 2 and at most 6"
,
K
(
ret
),
K
(
param_num
));
}
else
if
(
OB_FAIL
(
ObRawExprUtils
::
get_real_expr_without_cast
(
raw_expr
->
get_param_expr
(
0
),
real_expr
)))
{
LOG_WARN
(
"fail to get real expr without cast"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
real_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"real expr is invalid"
,
K
(
ret
),
K
(
real_expr
));
}
else
{
const
ObExprResType
&
text
=
real_expr
->
get_result_type
();
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
param_num
;
i
++
)
{
if
(
!
types
[
i
].
is_null
()
&&
!
is_type_valid
(
types
[
i
].
get_type
()))
{
ret
=
OB_INVALID_ARGUMENT
;
...
...
@@ -61,8 +69,8 @@ int ObExprRegexpSubstr::calc_result_typeN(ObExprResType &type,
//need duduce result type, then reset calc type.
if
(
lib
::
is_oracle_mode
())
{
// set max length.
type
.
set_length
(
static_cast
<
common
::
ObLength
>
(
t
ypes
[
0
]
.
get_length
()));
auto
str_params
=
make_const_carray
(
&
types
[
0
]
);
type
.
set_length
(
static_cast
<
common
::
ObLength
>
(
t
ext
.
get_length
()));
auto
str_params
=
make_const_carray
(
const_cast
<
ObExprResType
*>
(
&
text
)
);
OZ
(
aggregate_string_type_and_charset_oracle
(
*
type_ctx
.
get_session
(),
str_params
,
type
,
...
...
@@ -74,8 +82,8 @@ int ObExprRegexpSubstr::calc_result_typeN(ObExprResType &type,
?
type_ctx
.
get_session
()
->
get_actual_nls_length_semantics
()
:
common
::
LS_BYTE
);
type
.
set_varchar
();
type
.
set_length
(
t
ypes
[
0
]
.
get_length
());
type
.
set_length_semantics
(
t
ypes
[
0
].
is_varchar_or_char
()
?
types
[
0
]
.
get_length_semantics
()
:
default_length_semantics
);
type
.
set_length
(
t
ext
.
get_length
());
type
.
set_length_semantics
(
t
ext
.
is_varchar_or_char
()
?
text
.
get_length_semantics
()
:
default_length_semantics
);
ret
=
aggregate_charsets_for_string_result
(
type
,
types
,
1
,
type_ctx
.
get_coll_type
());
}
if
(
OB_SUCC
(
ret
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录