Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
e28151b1
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,发现更多精彩内容 >>
提交
e28151b1
编写于
11月 30, 2021
作者:
A
al0
提交者:
LINGuanRen
11月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support uuid_short in mysql mode.
上级
d06570ba
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
143 addition
and
4 deletion
+143
-4
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
+2
-0
src/sql/engine/expr/ob_expr_eval_functions.cpp
src/sql/engine/expr/ob_expr_eval_functions.cpp
+2
-1
src/sql/engine/expr/ob_expr_operator_factory.cpp
src/sql/engine/expr/ob_expr_operator_factory.cpp
+2
-0
src/sql/engine/expr/ob_expr_uuid_short.cpp
src/sql/engine/expr/ob_expr_uuid_short.cpp
+78
-0
src/sql/engine/expr/ob_expr_uuid_short.h
src/sql/engine/expr/ob_expr_uuid_short.h
+51
-0
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+1
-0
src/sql/resolver/expr/ob_raw_expr.cpp
src/sql/resolver/expr/ob_raw_expr.cpp
+2
-1
src/sql/resolver/expr/ob_raw_expr_info_extractor.cpp
src/sql/resolver/expr/ob_raw_expr_info_extractor.cpp
+4
-2
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
e28151b1
...
@@ -778,6 +778,7 @@
...
@@ -778,6 +778,7 @@
#define N_YEAR "year"
#define N_YEAR "year"
#define N_TIME "time"
#define N_TIME "time"
#define N_UUID "uuid"
#define N_UUID "uuid"
#define N_UUID_SHORT "uuid_short"
#define N_SYS_GUID "sys_guid"
#define N_SYS_GUID "sys_guid"
#define N_SET_TO_STR "set_to_str"
#define N_SET_TO_STR "set_to_str"
#define N_ENUM_TO_STR "enum_to_str"
#define N_ENUM_TO_STR "enum_to_str"
...
...
src/sql/CMakeLists.txt
浏览文件 @
e28151b1
...
@@ -166,6 +166,8 @@ ob_set_subtarget(ob_sql engine
...
@@ -166,6 +166,8 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_user_can_access_obj.cpp
engine/expr/ob_expr_user_can_access_obj.cpp
engine/expr/ob_expr_any_value.h
engine/expr/ob_expr_any_value.h
engine/expr/ob_expr_any_value.cpp
engine/expr/ob_expr_any_value.cpp
engine/expr/ob_expr_uuid_short.h
engine/expr/ob_expr_uuid_short.cpp
engine/pdml/ob_batch_row_cache.cpp
engine/pdml/ob_batch_row_cache.cpp
engine/pdml/ob_pdml_data_driver.cpp
engine/pdml/ob_pdml_data_driver.cpp
engine/pdml/ob_px_multi_part_modify.cpp
engine/pdml/ob_px_multi_part_modify.cpp
...
...
src/sql/engine/expr/ob_expr_eval_functions.cpp
浏览文件 @
e28151b1
...
@@ -189,6 +189,7 @@
...
@@ -189,6 +189,7 @@
#include "ob_expr_any_value.h"
#include "ob_expr_any_value.h"
#include "ob_expr_validate_password_strength.h"
#include "ob_expr_validate_password_strength.h"
#include "ob_expr_benchmark.h"
#include "ob_expr_benchmark.h"
#include "ob_expr_uuid_short.h"
namespace
oceanbase
{
namespace
oceanbase
{
using
namespace
common
;
using
namespace
common
;
...
@@ -710,7 +711,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
...
@@ -710,7 +711,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
NULL
,
/* 445 */
NULL
,
/* 445 */
NULL
,
/* 446 */
NULL
,
/* 446 */
NULL
,
/* 447 */
NULL
,
/* 447 */
NULL
,
/* 448 */
ObExprUuidShort
::
eval_uuid_short
,
/* 448 */
ObExprBenchmark
::
eval_benchmark
,
/* 449 */
ObExprBenchmark
::
eval_benchmark
,
/* 449 */
ObExprExportSet
::
eval_export_set
,
/* 450 */
ObExprExportSet
::
eval_export_set
,
/* 450 */
ObExprInet6Aton
::
calc_inet6_aton
,
/* 451 */
ObExprInet6Aton
::
calc_inet6_aton
,
/* 451 */
...
...
src/sql/engine/expr/ob_expr_operator_factory.cpp
浏览文件 @
e28151b1
...
@@ -273,6 +273,7 @@
...
@@ -273,6 +273,7 @@
#include "sql/engine/expr/ob_expr_any_value.h"
#include "sql/engine/expr/ob_expr_any_value.h"
#include "sql/engine/expr/ob_expr_validate_password_strength.h"
#include "sql/engine/expr/ob_expr_validate_password_strength.h"
#include "sql/engine/expr/ob_expr_benchmark.h"
#include "sql/engine/expr/ob_expr_benchmark.h"
#include "sql/engine/expr/ob_expr_uuid_short.h"
using
namespace
oceanbase
::
common
;
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
oceanbase
{
...
@@ -614,6 +615,7 @@ void ObExprOperatorFactory::register_expr_operators()
...
@@ -614,6 +615,7 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP
(
ObExprDllUdf
);
REG_OP
(
ObExprDllUdf
);
REG_OP
(
ObExprExp
);
REG_OP
(
ObExprExp
);
REG_OP
(
ObExprAnyValue
);
REG_OP
(
ObExprAnyValue
);
REG_OP
(
ObExprUuidShort
);
/* subquery comparison experator */
/* subquery comparison experator */
REG_OP
(
ObExprSubQueryRef
);
REG_OP
(
ObExprSubQueryRef
);
REG_OP
(
ObExprSubQueryEqual
);
REG_OP
(
ObExprSubQueryEqual
);
...
...
src/sql/engine/expr/ob_expr_uuid_short.cpp
0 → 100644
浏览文件 @
e28151b1
/*
* Copyright 2014-2021 Alibaba Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* ob_expr_uuid_short.cpp is for uuid_short function
*
* Date: 2021/8/20
*
* Authors:
* ailing.lcq<ailing.lcq@alibaba-inc.com>
*
*/
#define USING_LOG_PREFIX SQL_RESV
#include "sql/engine/expr/ob_expr_uuid_short.h"
#include "observer/ob_server_struct.h"
#include "lib/time/ob_time_utility.h"
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
sql
{
ObExprUuidShort
::
ObExprUuidShort
(
ObIAllocator
&
alloc
)
:
ObFuncExprOperator
(
alloc
,
T_FUN_SYS_UUID_SHORT
,
N_UUID_SHORT
,
0
,
NOT_ROW_DIMENSION
)
{}
ObExprUuidShort
::~
ObExprUuidShort
()
{}
/**
* Note:
* The total number of serverids over(>=) 256 will not guarantee uniqueness,
* but we will not report an error, because this is a undefined behavior in mysql.
* In short, users should need to know this.
*/
uint64_t
ObExprUuidShort
::
generate_uuid_short
()
{
// uuid_short
// | <8> | <32> | <24>
// server_id server_start_time incremented_variable
static
volatile
uint64_t
server_id_and_server_startup_time
=
((
GCTX
.
server_id_
&
255
)
<<
56
)
|
((
static_cast
<
uint64_t
>
(
common
::
ObTimeUtility
::
current_time
()
/
1000000
)
<<
24
)
&
((
static_cast
<
uint64_t
>
(
1
)
<<
56
)
-
1
));
uint64_t
uuid_short
=
ATOMIC_AAF
(
&
server_id_and_server_startup_time
,
1
);
LOG_DEBUG
(
"uuid_short generated."
,
K
(
uuid_short
));
return
uuid_short
;
}
int
ObExprUuidShort
::
calc_result0
(
common
::
ObObj
&
result
,
common
::
ObExprCtx
&
expr_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
UNUSED
(
expr_ctx
);
result
.
set_uint64
(
generate_uuid_short
());
return
ret
;
}
int
ObExprUuidShort
::
cg_expr
(
ObExprCGCtx
&
expr_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
{
UNUSED
(
raw_expr
);
UNUSED
(
expr_cg_ctx
);
rt_expr
.
eval_func_
=
ObExprUuidShort
::
eval_uuid_short
;
return
OB_SUCCESS
;
}
int
ObExprUuidShort
::
eval_uuid_short
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
)
{
int
ret
=
OB_SUCCESS
;
UNUSED
(
expr
);
UNUSED
(
ctx
);
expr_datum
.
set_uint
(
generate_uuid_short
());
return
ret
;
}
}
// namespace sql
}
// namespace oceanbase
src/sql/engine/expr/ob_expr_uuid_short.h
0 → 100644
浏览文件 @
e28151b1
/*
* Copyright 2014-2021 Alibaba Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* ob_expr_uuid_short.h is for uuid_short function
*
* Date: 2021/8/20
*
* Authors:
* ailing.lcq<ailing.lcq@alibaba-inc.com>
*
*/
#ifndef _OB_EXPR_UUID_SHORT_H_
#define _OB_EXPR_UUID_SHORT_H_
#include "sql/engine/expr/ob_expr_operator.h"
namespace
oceanbase
{
namespace
sql
{
class
ObExprUuidShort
:
public
ObFuncExprOperator
{
public:
explicit
ObExprUuidShort
(
common
::
ObIAllocator
&
alloc
);
virtual
~
ObExprUuidShort
();
virtual
int
calc_result_type0
(
ObExprResType
&
type
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
;
virtual
int
calc_result0
(
common
::
ObObj
&
result
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
virtual
int
cg_expr
(
ObExprCGCtx
&
expr_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
override
;
static
int
eval_uuid_short
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
);
private:
static
uint64_t
generate_uuid_short
();
DISALLOW_COPY_AND_ASSIGN
(
ObExprUuidShort
)
const
;
};
inline
int
ObExprUuidShort
::
calc_result_type0
(
ObExprResType
&
type
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
{
UNUSED
(
type_ctx
);
type
.
set_uint64
();
return
common
::
OB_SUCCESS
;
}
}
// namespace sql
}
// namespace oceanbase
#endif
/* _OB_EXPR_UUID_SHORT_H_ */
// select uuid_short();
\ No newline at end of file
src/sql/parser/ob_item_type.h
浏览文件 @
e28151b1
...
@@ -429,6 +429,7 @@ typedef enum ObItemType {
...
@@ -429,6 +429,7 @@ typedef enum ObItemType {
T_FUN_SYS_ANY_VALUE
=
714
,
T_FUN_SYS_ANY_VALUE
=
714
,
T_FUN_SYS_DEGREES
=
715
,
T_FUN_SYS_DEGREES
=
715
,
T_FUN_SYS_VALIDATE_PASSWORD_STRENGTH
=
716
,
T_FUN_SYS_VALIDATE_PASSWORD_STRENGTH
=
716
,
T_FUN_SYS_UUID_SHORT
=
719
,
T_FUN_SYS_BENCHMARK
=
720
,
T_FUN_SYS_BENCHMARK
=
720
,
T_FUN_SYS_EXPORT_SET
=
721
,
T_FUN_SYS_EXPORT_SET
=
721
,
...
...
src/sql/resolver/expr/ob_raw_expr.cpp
浏览文件 @
e28151b1
...
@@ -493,7 +493,8 @@ bool ObRawExpr::is_non_pure_sys_func_expr() const
...
@@ -493,7 +493,8 @@ bool ObRawExpr::is_non_pure_sys_func_expr() const
T_FUN_SYS_UNIX_TIMESTAMP
==
type_
||
T_FUN_SYS_UTC_TIMESTAMP
==
type_
||
T_FUN_SYS_RAND
==
type_
||
T_FUN_SYS_UNIX_TIMESTAMP
==
type_
||
T_FUN_SYS_UTC_TIMESTAMP
==
type_
||
T_FUN_SYS_RAND
==
type_
||
T_FUN_SYS_UUID
==
type_
||
T_FUN_SYS_SLEEP
==
type_
||
T_FUN_SYS_LAST_INSERT_ID
==
type_
||
T_FUN_SYS_UUID
==
type_
||
T_FUN_SYS_SLEEP
==
type_
||
T_FUN_SYS_LAST_INSERT_ID
==
type_
||
T_FUN_SYS_ROW_COUNT
==
type_
||
T_FUN_SYS_FOUND_ROWS
==
type_
||
T_FUN_SYS_REGEXP_INSTR
==
type_
||
T_FUN_SYS_ROW_COUNT
==
type_
||
T_FUN_SYS_FOUND_ROWS
==
type_
||
T_FUN_SYS_REGEXP_INSTR
==
type_
||
T_FUN_SYS_REGEXP_LIKE
==
type_
||
T_FUN_SYS_REGEXP_REPLACE
==
type_
||
T_FUN_SYS_REGEXP_SUBSTR
==
type_
)
{
T_FUN_SYS_REGEXP_LIKE
==
type_
||
T_FUN_SYS_REGEXP_REPLACE
==
type_
||
T_FUN_SYS_REGEXP_SUBSTR
==
type_
||
T_FUN_SYS_UUID_SHORT
==
type_
)
{
return
true
;
return
true
;
}
}
}
}
...
...
src/sql/resolver/expr/ob_raw_expr_info_extractor.cpp
浏览文件 @
e28151b1
...
@@ -155,7 +155,8 @@ int ObRawExprInfoExtractor::add_const(ObRawExpr& expr)
...
@@ -155,7 +155,8 @@ int ObRawExprInfoExtractor::add_const(ObRawExpr& expr)
CONST_ACTION
(
param_expr
);
CONST_ACTION
(
param_expr
);
}
}
if
(
is_const_expr
&&
if
(
is_const_expr
&&
(
T_FUN_SYS_RAND
==
expr
.
get_expr_type
()
||
T_FUN_SYS_SEQ_NEXTVAL
==
expr
.
get_expr_type
()
||
(
T_FUN_SYS_RAND
==
expr
.
get_expr_type
()
||
T_FUN_SYS_UUID
==
expr
.
get_expr_type
()
||
T_FUN_SYS_UUID_SHORT
==
expr
.
get_expr_type
()
||
T_FUN_SYS_SEQ_NEXTVAL
==
expr
.
get_expr_type
()
||
T_FUN_SYS_AUTOINC_NEXTVAL
==
expr
.
get_expr_type
()
||
T_FUN_SYS_ROWNUM
==
expr
.
get_expr_type
()
||
T_FUN_SYS_AUTOINC_NEXTVAL
==
expr
.
get_expr_type
()
||
T_FUN_SYS_ROWNUM
==
expr
.
get_expr_type
()
||
T_FUN_SYS_ROWKEY_TO_ROWID
==
expr
.
get_expr_type
()
||
T_OP_CONNECT_BY_ROOT
==
expr
.
get_expr_type
()
||
T_FUN_SYS_ROWKEY_TO_ROWID
==
expr
.
get_expr_type
()
||
T_OP_CONNECT_BY_ROOT
==
expr
.
get_expr_type
()
||
T_FUN_SYS_CONNECT_BY_PATH
==
expr
.
get_expr_type
()
||
T_FUN_SYS_GUID
==
expr
.
get_expr_type
()
||
T_FUN_SYS_CONNECT_BY_PATH
==
expr
.
get_expr_type
()
||
T_FUN_SYS_GUID
==
expr
.
get_expr_type
()
||
...
@@ -502,7 +503,8 @@ int ObRawExprInfoExtractor::visit(ObSysFunRawExpr& expr)
...
@@ -502,7 +503,8 @@ int ObRawExprInfoExtractor::visit(ObSysFunRawExpr& expr)
if
(
OB_FAIL
(
expr
.
add_flag
(
IS_RAND_FUNC
)))
{
if
(
OB_FAIL
(
expr
.
add_flag
(
IS_RAND_FUNC
)))
{
LOG_WARN
(
"failed to add flag IS_RAND_FUNC"
,
K
(
ret
));
LOG_WARN
(
"failed to add flag IS_RAND_FUNC"
,
K
(
ret
));
}
}
}
else
if
(
T_FUN_SYS_GUID
==
expr
.
get_expr_type
()
||
T_FUN_SYS_UUID
==
expr
.
get_expr_type
())
{
}
else
if
(
T_FUN_SYS_GUID
==
expr
.
get_expr_type
()
||
T_FUN_SYS_UUID
==
expr
.
get_expr_type
()
||
T_FUN_SYS_UUID_SHORT
==
expr
.
get_expr_type
())
{
if
(
OB_FAIL
(
expr
.
add_flag
(
IS_RAND_FUNC
)))
{
if
(
OB_FAIL
(
expr
.
add_flag
(
IS_RAND_FUNC
)))
{
LOG_WARN
(
"failed to add flag IS_RAND_FUNC"
,
K
(
ret
));
LOG_WARN
(
"failed to add flag IS_RAND_FUNC"
,
K
(
ret
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录