Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
02e3302d
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,发现更多精彩内容 >>
提交
02e3302d
编写于
9月 13, 2021
作者:
S
st0
提交者:
wangzelin.wzl
9月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support function crc32
上级
c19f7ea9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
154 addition
and
0 deletion
+154
-0
deps/oblib/src/lib/ob_name_def.h
deps/oblib/src/lib/ob_name_def.h
+1
-0
src/sql/CMakeLists.txt
src/sql/CMakeLists.txt
+1
-0
src/sql/engine/expr/ob_expr_crc32.cpp
src/sql/engine/expr/ob_expr_crc32.cpp
+108
-0
src/sql/engine/expr/ob_expr_crc32.h
src/sql/engine/expr/ob_expr_crc32.h
+39
-0
src/sql/engine/expr/ob_expr_eval_functions.cpp
src/sql/engine/expr/ob_expr_eval_functions.cpp
+2
-0
src/sql/engine/expr/ob_expr_operator_factory.cpp
src/sql/engine/expr/ob_expr_operator_factory.cpp
+2
-0
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+1
-0
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
02e3302d
...
...
@@ -397,6 +397,7 @@
#define N_INSERT "insert"
#define N_SUBSTRING_INDEX "substring_index"
#define N_MD5 "md5"
#define N_CRC32 "crc32"
#define N_HEX "hex"
#define N_UNHEX "unhex"
#define N_HEXTORAW "hextoraw"
...
...
src/sql/CMakeLists.txt
浏览文件 @
02e3302d
...
...
@@ -222,6 +222,7 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_conv.cpp
engine/expr/ob_expr_convert.cpp
engine/expr/ob_expr_cosh.cpp
engine/expr/ob_expr_crc32.cpp
engine/expr/ob_expr_timezone.cpp
engine/expr/ob_expr_tz_offset.cpp
engine/expr/ob_expr_from_tz.cpp
...
...
src/sql/engine/expr/ob_expr_crc32.cpp
0 → 100644
浏览文件 @
02e3302d
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "lib/compress/zlib/zlib.h"
#include "lib/charset/ob_charset.h"
#include "lib/ob_name_def.h"
#include "lib/utility/ob_macro_utils.h"
#include "share/object/ob_obj_cast.h"
#include "sql/engine/expr/ob_expr_crc32.h"
#include "sql/engine/expr/ob_expr_util.h"
#include "sql/session/ob_sql_session_info.h"
namespace
oceanbase
{
using
namespace
common
;
namespace
sql
{
ObExprCrc32
::
ObExprCrc32
(
ObIAllocator
&
alloc
)
:
ObFuncExprOperator
(
alloc
,
T_FUN_SYS_CRC32
,
N_CRC32
,
1
,
NOT_ROW_DIMENSION
)
{}
int
ObExprCrc32
::
calc_result_type1
(
ObExprResType
&
type
,
ObExprResType
&
type1
,
ObExprTypeCtx
&
type_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
UNUSED
(
type_ctx
);
type
.
set_precision
(
10
);
type
.
set_uint32
();
if
(
OB_LIKELY
(
type1
.
is_not_null
()))
{
type
.
set_result_flag
(
OB_MYSQL_NOT_NULL_FLAG
);
}
if
(
ob_is_string_type
(
type1
.
get_type
()))
{
type1
.
set_calc_type
(
type1
.
get_type
());
type1
.
set_calc_collation_type
(
type1
.
get_collation_type
());
}
else
{
type1
.
set_calc_type
(
ObVarcharType
);
type1
.
set_calc_collation_type
(
ObCharset
::
get_system_collation
());
}
return
ret
;
}
int
ObExprCrc32
::
calc_result1
(
common
::
ObObj
&
obj
,
const
common
::
ObObj
&
obj1
,
ObExprCtx
&
expr_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
if
(
OB_ISNULL
(
expr_ctx
.
calc_buf_
))
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"varchar buffer not init"
,
K
(
ret
));
}
else
if
(
obj1
.
is_null
())
{
obj
.
set_null
();
}
else
{
uint64_t
val
;
ObString
str_val
=
obj1
.
get_string
();
if
(
str_val
.
length
()
<=
0
)
{
val
=
0ULL
;
}
else
{
val
=
crc32
(
0
,
reinterpret_cast
<
unsigned
char
*>
(
str_val
.
ptr
()),
str_val
.
length
());
}
obj
.
set_uint32
(
val
);
}
return
ret
;
}
int
ObExprCrc32
::
calc_crc32_expr
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
res_datum
)
{
int
ret
=
OB_SUCCESS
;
unsigned
char
*
buf
=
NULL
;
ObDatum
*
s_datum
=
NULL
;
if
(
OB_FAIL
(
expr
.
args_
[
0
]
->
eval
(
ctx
,
s_datum
)))
{
LOG_WARN
(
"eval arg failed"
,
K
(
ret
));
}
else
if
(
s_datum
->
is_null
())
{
res_datum
.
set_null
();
}
else
{
const
ObString
&
str_val
=
s_datum
->
get_string
();
if
(
str_val
.
empty
())
{
res_datum
.
set_uint
(
0ULL
);
}
else
{
buf
=
reinterpret_cast
<
unsigned
char
*>
(
const_cast
<
char
*>
(
str_val
.
ptr
()));
res_datum
.
set_uint
(
crc32
(
0
,
buf
,
str_val
.
length
()));
}
}
return
ret
;
}
int
ObExprCrc32
::
cg_expr
(
ObExprCGCtx
&
expr_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
{
int
ret
=
OB_SUCCESS
;
UNUSED
(
expr_cg_ctx
);
UNUSED
(
raw_expr
);
CK
(
1
==
rt_expr
.
arg_cnt_
);
CK
(
!
OB_ISNULL
(
rt_expr
.
args_
)
&&
!
OB_ISNULL
(
rt_expr
.
args_
[
0
]));
CK
(
ob_is_string_type
(
rt_expr
.
args_
[
0
]
->
datum_meta_
.
type_
));
rt_expr
.
eval_func_
=
calc_crc32_expr
;
return
ret
;
}
}
// namespace sql
}
// namespace oceanbase
\ No newline at end of file
src/sql/engine/expr/ob_expr_crc32.h
0 → 100644
浏览文件 @
02e3302d
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_CRC32_
#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_CRC32_
#include "sql/engine/expr/ob_expr_operator.h"
namespace
oceanbase
{
namespace
sql
{
class
ObExprCrc32
:
public
ObFuncExprOperator
{
public:
explicit
ObExprCrc32
(
common
::
ObIAllocator
&
alloc
);
virtual
~
ObExprCrc32
(){};
static
int
calc_crc32
(
common
::
ObObj
&
obj
,
const
common
::
ObObj
&
obj1
,
common
::
ObExprCtx
&
expr_ctx
);
virtual
int
calc_result_type1
(
ObExprResType
&
type
,
ObExprResType
&
type1
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
;
virtual
int
calc_result1
(
common
::
ObObj
&
obj
,
const
common
::
ObObj
&
obj1
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
virtual
int
cg_expr
(
ObExprCGCtx
&
expr_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
;
static
int
calc_crc32_expr
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
res_datum
);
private:
DISALLOW_COPY_AND_ASSIGN
(
ObExprCrc32
);
};
}
// namespace sql
}
// namespace oceanbase
#endif // OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_CRC32_
\ No newline at end of file
src/sql/engine/expr/ob_expr_eval_functions.cpp
浏览文件 @
02e3302d
...
...
@@ -50,6 +50,7 @@
#include "ob_expr_like.h"
#include "ob_expr_lower.h"
#include "ob_expr_md5.h"
#include "ob_expr_crc32.h"
#include "ob_expr_mid.h"
#include "ob_expr_minus.h"
#include "ob_expr_mod.h"
...
...
@@ -715,6 +716,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
ObExprInetAton
::
calc_inet_aton
,
/* 456 */
ObExprInet6Ntoa
::
calc_inet6_ntoa
,
/* 457 */
ObExprConvertTZ
::
eval_convert_tz
,
/* 458 */
ObExprCrc32
::
calc_crc32_expr
,
/* 459 */
};
REG_SER_FUNC_ARRAY
(
OB_SFA_SQL_EXPR_EVAL
,
g_expr_eval_functions
,
ARRAYSIZEOF
(
g_expr_eval_functions
));
...
...
src/sql/engine/expr/ob_expr_operator_factory.cpp
浏览文件 @
02e3302d
...
...
@@ -170,6 +170,7 @@
#include "sql/engine/expr/ob_expr_reverse.h"
#include "sql/engine/expr/ob_expr_right.h"
#include "sql/engine/expr/ob_expr_md5.h"
#include "sql/engine/expr/ob_expr_crc32.h"
#include "sql/engine/expr/ob_expr_lrpad.h"
#include "sql/engine/expr/ob_expr_conv.h"
#include "sql/engine/expr/ob_expr_sign.h"
...
...
@@ -629,6 +630,7 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP
(
ObExprIfNull
);
REG_OP
(
ObExprConcatWs
);
REG_OP
(
ObExprCmpMeta
);
REG_OP
(
ObExprCrc32
);
REG_OP
(
ObExprQuote
);
REG_OP
(
ObExprPad
);
REG_OP
(
ObExprHostIP
);
...
...
src/sql/parser/ob_item_type.h
浏览文件 @
02e3302d
...
...
@@ -435,6 +435,7 @@ typedef enum ObItemType {
T_FUN_SYS_IS_IPV4_MAPPED
=
719
,
T_FUN_SYS_IS_IPV4_COMPAT
=
720
,
T_FUN_SYS_INETATON
=
721
,
T_FUN_SYS_CRC32
=
722
,
///< @note add new mysql only function type before this line
T_MYSQL_ONLY_SYS_MAX_OP
=
800
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录