Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
a1f04865
O
oceanbase
项目概览
caoersss
/
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,发现更多精彩内容 >>
提交
a1f04865
编写于
3月 15, 2022
作者:
Y
yy0
提交者:
LINGuanRen
3月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:40048757,40048854
上级
293e2ec4
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
169 addition
and
5539 deletion
+169
-5539
deps/oblib/src/lib/json_type/ob_json_bin.cpp
deps/oblib/src/lib/json_type/ob_json_bin.cpp
+20
-11
deps/oblib/src/lib/json_type/ob_json_bin.h
deps/oblib/src/lib/json_type/ob_json_bin.h
+2
-2
h0416
h0416
+0
-5500
src/sql/engine/expr/ob_expr_bool.cpp
src/sql/engine/expr/ob_expr_bool.cpp
+3
-1
src/sql/engine/expr/ob_expr_case.cpp
src/sql/engine/expr/ob_expr_case.cpp
+3
-0
src/sql/engine/expr/ob_expr_merge_result_type.map
src/sql/engine/expr/ob_expr_merge_result_type.map
+116
-18
src/sql/engine/expr/ob_expr_or.cpp
src/sql/engine/expr/ob_expr_or.cpp
+20
-4
src/sql/resolver/expr/ob_raw_expr_deduce_type.cpp
src/sql/resolver/expr/ob_raw_expr_deduce_type.cpp
+5
-3
未找到文件。
deps/oblib/src/lib/json_type/ob_json_bin.cpp
浏览文件 @
a1f04865
...
...
@@ -650,7 +650,7 @@ int ObJsonBin::serialize_json_value(ObJsonNode *json_tree, ObJsonBuffer &result)
case
ObJsonNodeType
::
J_DOUBLE
:
{
const
ObJsonDouble
*
d
=
static_cast
<
const
ObJsonDouble
*>
(
json_tree
);
double
value
=
d
->
value
();
if
(
std
::
isnan
(
value
)
||
std
::
isinf
(
value
))
{
if
(
isnan
(
value
)
||
isinf
(
value
))
{
ret
=
OB_INVALID_NUMERIC
;
LOG_WARN
(
"invalid double value"
,
K
(
ret
),
K
(
value
));
}
else
if
(
OB_FAIL
(
result
.
append
(
reinterpret_cast
<
const
char
*>
(
&
value
),
sizeof
(
double
))))
{
...
...
@@ -1783,7 +1783,7 @@ int ObJsonBin::move_parent_iter()
}
// inlined will reuse value entry offset which length is type_size
int
ObJsonBin
::
set_curr_by_type
(
int64_t
new_pos
,
uint64_t
val_offset
,
uint8_t
type
)
int
ObJsonBin
::
set_curr_by_type
(
int64_t
new_pos
,
uint64_t
val_offset
,
uint8_t
type
,
uint8_t
entry_size
)
{
INIT_SUCC
(
ret
);
char
*
ptr
=
curr_
.
ptr
();
...
...
@@ -1820,7 +1820,7 @@ int ObJsonBin::set_curr_by_type(int64_t new_pos, uint64_t val_offset, uint8_t ty
}
case
ObJsonNodeType
::
J_INT
:
{
if
(
is_inlined
)
{
int_val_
=
ObJsonVar
::
var_uint2int
(
val_offset
);
int_val_
=
ObJsonVar
::
var_uint2int
(
val_offset
,
entry_size
);
bytes_
=
0
;
}
else
{
int64_t
val
=
0
;
...
...
@@ -2141,7 +2141,7 @@ int ObJsonBin::get_element_in_array_v0(size_t index, char **get_addr_only)
}
else
{
pos_
=
pos_
+
val_offset
;
}
if
(
OB_FAIL
(
set_curr_by_type
(
pos_
,
val_offset
,
val_type
)))
{
if
(
OB_FAIL
(
set_curr_by_type
(
pos_
,
val_offset
,
val_type
,
type
)))
{
LOG_WARN
(
"failed to move iter to sub obj."
,
K
(
ret
),
K
(
index
));
}
}
...
...
@@ -2212,7 +2212,7 @@ int ObJsonBin::get_element_in_object_v0(size_t i, char **get_addr_only)
}
else
{
pos_
=
pos_
+
value_offset
;
}
if
(
OB_FAIL
(
set_curr_by_type
(
pos_
,
value_offset
,
val_type
)))
{
if
(
OB_FAIL
(
set_curr_by_type
(
pos_
,
value_offset
,
val_type
,
type
)))
{
LOG_WARN
(
"failed to move iter to sub obj."
,
K
(
ret
),
K
(
i
));
}
}
...
...
@@ -3685,12 +3685,21 @@ int ObJsonBin::rebuild_json_value(const char *data,
break
;
}
case
ObJsonNodeType
::
J_DECIMAL
:
{
ObPrecision
prec
=
-
1
;
ObScale
scale
=
-
1
;
number
::
ObNumber
num
;
int64_t
pos
=
0
;
number
::
ObNumber
temp_number
;
if
(
OB_FAIL
(
temp_number
.
deserialize
(
data
,
length
,
pos
)))
{
LOG_WARN
(
"failed to deserialize decimal data"
,
K
(
ret
));
if
(
OB_FAIL
(
serialization
::
decode_i16
(
data
,
length
,
pos
,
&
prec
)))
{
LOG_WARN
(
"fail to deserialize decimal precision."
,
K
(
ret
),
K
(
length
));
}
else
if
(
OB_FAIL
(
serialization
::
decode_i16
(
data
,
length
,
pos
,
&
scale
)))
{
LOG_WARN
(
"fail to deserialize decimal scale."
,
K
(
ret
),
K
(
length
),
K
(
prec
));
}
else
if
(
OB_FAIL
(
num
.
deserialize
(
data
,
length
,
pos
)))
{
LOG_WARN
(
"fail to deserialize number."
,
K
(
ret
),
K
(
length
));
}
else
{
ret
=
result
.
append
(
data
,
pos
);
ObJsonDecimal
decimal
(
num
,
prec
,
scale
);
if
(
OB_FAIL
(
serialize_json_decimal
(
&
decimal
,
result
)))
{
LOG_WARN
(
"failed to seialize json decimal"
,
K
(
ret
));
}
}
break
;
}
...
...
@@ -4342,9 +4351,9 @@ uint64_t ObJsonVar::var_int2uint(int64_t var)
return
val
;
}
int64_t
ObJsonVar
::
var_uint2int
(
uint64_t
var
)
int64_t
ObJsonVar
::
var_uint2int
(
uint64_t
var
,
uint8_t
entry_size
)
{
ObJsonBinLenSize
size
=
static_cast
<
ObJsonBinLenSize
>
(
ObJsonVar
::
get_var_type
(
var
));
ObJsonBinLenSize
size
=
static_cast
<
ObJsonBinLenSize
>
(
max
(
ObJsonVar
::
get_var_type
(
var
),
entry_size
));
int64_t
val
=
0
;
switch
(
size
)
{
case
JBLS_UINT8
:
{
...
...
deps/oblib/src/lib/json_type/ob_json_bin.h
浏览文件 @
a1f04865
...
...
@@ -412,7 +412,7 @@ private:
int
deserialize_json_array_v0
(
const
char
*
data
,
uint64_t
length
,
ObJsonArray
*
array
);
inline
int
deserialize_json_array
(
const
char
*
data
,
uint64_t
length
,
ObJsonArray
*
array
,
ObJBVerType
vertype
);
int
set_curr_by_type
(
int64_t
new_pos
,
uint64_t
val_offset
,
uint8_t
type
);
int
set_curr_by_type
(
int64_t
new_pos
,
uint64_t
val_offset
,
uint8_t
type
,
uint8_t
entry_size
=
0
);
void
parse_obj_header
(
const
char
*
data
,
uint64_t
&
offset
,
uint8_t
&
node_type
,
uint8_t
&
type
,
uint8_t
&
obj_size_type
,
uint64_t
&
count
,
uint64_t
&
obj_size
)
const
;
...
...
@@ -513,7 +513,7 @@ public:
static
uint8_t
get_var_type
(
uint64_t
var
);
static
int
read_var
(
const
char
*
data
,
uint8_t
type
,
int64_t
*
var
);
static
uint64_t
var_int2uint
(
int64_t
var
);
static
int64_t
var_uint2int
(
uint64_t
var
);
static
int64_t
var_uint2int
(
uint64_t
var
,
uint8_t
entry_size
=
0
);
static
uint8_t
get_var_type
(
int64_t
var
);
};
...
...
h0416
已删除
100644 → 0
浏览文件 @
293e2ec4
此差异已折叠。
点击以展开。
src/sql/engine/expr/ob_expr_bool.cpp
浏览文件 @
a1f04865
...
...
@@ -101,7 +101,9 @@ CHECK_IS_TRUE_FUNC_NAME(other_type)
{
if
(
ob_is_json
(
expr
.
args_
[
0
]
->
datum_meta_
.
type_
))
{
int
cmp_result
=
0
;
if
(
OB_FAIL
(
ObJsonExprHelper
::
is_json_zero
(
child_datum
->
get_string
(),
cmp_result
)))
{
if
(
child_datum
->
is_null
())
{
res_datum
.
set_int32
(
1
);;
}
else
if
(
OB_FAIL
(
ObJsonExprHelper
::
is_json_zero
(
child_datum
->
get_string
(),
cmp_result
)))
{
LOG_WARN
(
"failed: compare json"
,
K
(
ret
));
}
else
{
res_datum
.
set_int32
(
cmp_result
);
...
...
src/sql/engine/expr/ob_expr_case.cpp
浏览文件 @
a1f04865
...
...
@@ -97,6 +97,9 @@ int ObExprCase::calc_result_typeN(
types_stack
[
i
].
set_calc_meta
(
types_stack
[
i
].
get_obj_meta
());
}
else
{
types_stack
[
i
].
set_calc_meta
(
type
.
get_obj_meta
());
if
(
ob_is_json
(
types_stack
[
i
].
get_type
()))
{
types_stack
[
i
].
set_calc_collation_type
(
CS_TYPE_UTF8MB4_BIN
);
}
}
}
}
...
...
src/sql/engine/expr/ob_expr_merge_result_type.map
浏览文件 @
a1f04865
此差异已折叠。
点击以展开。
src/sql/engine/expr/ob_expr_or.cpp
浏览文件 @
a1f04865
...
...
@@ -49,17 +49,21 @@ int ObExprOr::calc_result2(
bool
obj1_is_true
=
false
;
EXPR_SET_CAST_CTX_MODE
(
expr_ctx
);
if
(
ob_is_json
(
obj1
.
get_type
()))
{
bool
is_obj1_json
=
ob_is_json
(
obj1
.
get_type
());
if
(
is_obj1_json
)
{
// cause for json type, in some case can't transform to number type
// add special process for json type
// use the some logical as mysql
int
cmp_result
=
0
;
if
(
OB_FAIL
(
ObJsonExprHelper
::
is_json_zero
(
obj1
.
get_string
(),
cmp_result
)))
{
if
(
obj1
.
is_null
())
{
}
else
if
(
OB_FAIL
(
ObJsonExprHelper
::
is_json_zero
(
obj1
.
get_string
(),
cmp_result
)))
{
LOG_WARN
(
"failed: compare json"
,
K
(
ret
));
}
else
{
result
.
set_int32
(
cmp_result
)
;
obj1_is_true
=
cmp_result
!=
0
;
}
}
else
if
(
OB_FAIL
(
ObLogicalExprOperator
::
is_true
(
obj1
,
expr_ctx
.
cast_mode_
|
CM_NO_RANGE_CHECK
,
obj1_is_true
)))
{
}
if
(
!
is_obj1_json
&&
OB_FAIL
(
ObLogicalExprOperator
::
is_true
(
obj1
,
expr_ctx
.
cast_mode_
|
CM_NO_RANGE_CHECK
,
obj1_is_true
)))
{
LOG_WARN
(
"fail to evaluate obj1"
,
K
(
obj1
),
K
(
ret
));
}
else
if
(
obj1_is_true
)
{
result
.
set_int32
(
static_cast
<
int32_t
>
(
true
));
...
...
@@ -73,6 +77,18 @@ int ObExprOr::calc_result2(
}
else
{
// obj1 must be false here.
bool
bool_v2
=
false
;
bool
is_obj2_json
=
ob_is_json
(
obj2
.
get_type
());
if
(
is_obj2_json
)
{
int
cmp_result
=
0
;
if
(
obj1
.
is_null
())
{
}
else
if
(
OB_FAIL
(
ObJsonExprHelper
::
is_json_zero
(
obj1
.
get_string
(),
cmp_result
)))
{
LOG_WARN
(
"failed: compare json"
,
K
(
ret
));
}
else
{
bool_v2
=
cmp_result
!=
0
;
}
}
if
(
OB_FAIL
(
ObLogicalExprOperator
::
is_true
(
obj2
,
expr_ctx
.
cast_mode_
|
CM_NO_RANGE_CHECK
,
bool_v2
)))
{
LOG_WARN
(
"fail to evaluate obj2"
,
K
(
obj2
),
K
(
ret
));
}
else
{
...
...
src/sql/resolver/expr/ob_raw_expr_deduce_type.cpp
浏览文件 @
a1f04865
...
...
@@ -302,9 +302,11 @@ int ObRawExprDeduceType::calc_result_type(
if
(
ObLobType
==
type
->
get_type
())
{
type
->
set_type
(
ObLongTextType
);
}
// ToDo: test and fix, not all sql functions need calc json as long text
if
(
ObJsonType
==
type
->
get_type
()
&&
need_calc_json_as_text
(
expr
.
get_expr_type
()))
{
type
->
set_calc_type
(
ObLongTextType
);
if
(
ObJsonType
==
type
->
get_type
())
{
if
(
need_calc_json_as_text
(
expr
.
get_expr_type
()))
{
// ToDo: test and fix, not all sql functions need calc json as long text
type
->
set_calc_type
(
ObLongTextType
);
}
}
}
op
->
set_row_dimension
(
row_dimension
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录