Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
05576007
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,发现更多精彩内容 >>
提交
05576007
编写于
7月 19, 2021
作者:
O
obdev
提交者:
wangzelin.wzl
7月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support expr pi in mysql mode
上级
ee48dc4c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
130 addition
and
11 deletion
+130
-11
deps/oblib/src/lib/ob_name_def.h
deps/oblib/src/lib/ob_name_def.h
+1
-1
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
+21
-10
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_pi.cpp
src/sql/engine/expr/ob_expr_pi.cpp
+68
-0
src/sql/engine/expr/ob_expr_pi.h
src/sql/engine/expr/ob_expr_pi.h
+34
-0
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+1
-0
src/sql/parser/type_name.c
src/sql/parser/type_name.c
+1
-0
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
05576007
...
...
@@ -769,7 +769,7 @@
#define N_LPAD "lpad"
#define N_SPACE "space"
#define N_TRUNCATE "truncate"
#define N_PI "
PI
"
#define N_PI "
pi
"
#define N_TIME_STAMP_ADD "timestampadd"
#define N_CONNECT_BY_ROOT "connect_by_root"
#define N_SYS_CONNECT_BY_PATH "sys_connect_by_path"
...
...
src/sql/CMakeLists.txt
浏览文件 @
05576007
...
...
@@ -346,6 +346,8 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_repeat.cpp
engine/expr/ob_expr_replace.cpp
engine/expr/ob_expr_translate.cpp
engine/expr/ob_expr_pi.cpp
engine/expr/ob_expr_pi.h
engine/expr/ob_expr_radians.cpp
engine/expr/ob_expr_res_type_map.cpp
engine/expr/ob_expr_result_type_util.cpp
...
...
src/sql/engine/expr/ob_expr_eval_functions.cpp
浏览文件 @
05576007
...
...
@@ -169,6 +169,7 @@
#include "ob_expr_user_can_access_obj.h"
#include "ob_expr_empty_lob.h"
#include "ob_expr_radians.h"
#include "ob_expr_pi.h"
#include "ob_expr_maketime.h"
#include "ob_expr_to_blob.h"
#include "ob_expr_to_outfile_row.h"
...
...
@@ -629,16 +630,26 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
ObExprNlsLower
::
calc_lower
,
/* 378 */
ObExprNlsUpper
::
calc_upper
,
/* 379 */
ObExprToOutfileRow
::
to_outfile_str
,
/* 380 */
NULL
,
// ObExprIs::calc_is_infinite, /* 381 */
NULL
,
// ObExprIs::calc_is_nan, /* 382 */
NULL
,
// ObExprIsNot::calc_is_not_infinite, /* 383 */
NULL
,
// ObExprIsNot::calc_is_not_nan, /* 384 */
ObExprOracleNullif
::
eval_nullif_not_null
,
/* 385 */
NULL
,
// ObExprNaNvl::eval_nanvl, /* 386 */
ObExprFormat
::
calc_format_expr
,
/* 387 */
calc_translate_using_expr
,
/* 388 */
ObExprQuarter
::
calc_quater
,
/* 389 */
ObExprBitLength
::
calc_bit_length
/* 390 */
NULL
,
// ObExprIs::calc_is_infinite, /* 381 */
NULL
,
// ObExprIs::calc_is_nan, /* 382 */
NULL
,
// ObExprIsNot::calc_is_not_infinite, /* 383 */
NULL
,
// ObExprIsNot::calc_is_not_nan, /* 384 */
ObExprOracleNullif
::
eval_nullif_not_null
,
/* 385 */
NULL
,
// ObExprNaNvl::eval_nanvl, /* 386 */
ObExprFormat
::
calc_format_expr
,
/* 387 */
calc_translate_using_expr
,
/* 388 */
ObExprQuarter
::
calc_quater
,
/* 389 */
ObExprBitLength
::
calc_bit_length
,
/* 390 */
NULL
,
// ObExprConvertOracle::calc_convert_oracle_expr, /* 391 */
NULL
,
// ObExprUnistr::calc_unistr_expr, /* 392 */
NULL
,
// ObExprAsciistr::calc_asciistr_expr, /* 393 */
NULL
,
// ObExprAtTimeZone::eval_at_time_zone, /* 394 */
NULL
,
// ObExprAtLocal::eval_at_local, /* 395 */
NULL
,
// ObExprToSingleByte::calc_to_single_byte, /* 396 */
NULL
,
// ObExprToMultiByte::calc_to_multi_byte, /* 397 */
NULL
,
// ObExprDllUdf::eval_dll_udf, /* 398 */
NULL
,
// ObExprRawtonhex::calc_rawtonhex_expr, /* 399 */
ObExprPi
::
eval_pi
/* 400 */
};
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
浏览文件 @
05576007
...
...
@@ -256,6 +256,7 @@
#include "sql/engine/expr/ob_expr_user_can_access_obj.h"
#include "sql/engine/expr/ob_expr_empty_lob.h"
#include "sql/engine/expr/ob_expr_radians.h"
#include "sql/engine/expr/ob_expr_pi.h"
#include "sql/engine/expr/ob_expr_to_outfile_row.h"
#include "sql/engine/expr/ob_expr_format.h"
#include "sql/engine/expr/ob_expr_quarter.h"
...
...
@@ -646,6 +647,7 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP
(
ObExprToOutfileRow
);
REG_OP
(
ObExprFormat
);
REG_OP
(
ObExprLog
);
REG_OP
(
ObExprPi
);
// register oracle system function
REG_OP_ORCL
(
ObExprSysConnectByPath
);
REG_OP_ORCL
(
ObExprTimestampNvl
);
...
...
src/sql/engine/expr/ob_expr_pi.cpp
0 → 100644
浏览文件 @
05576007
// Copyright 1999-2021 Alibaba Inc. All Rights Reserved.
// Author:
// xiaofeng.lby@alipay.com
// Normalizer:
//
// This file is for implementation of func pi
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_pi.h"
#include "sql/session/ob_sql_session_info.h"
using
namespace
oceanbase
::
common
;
using
namespace
oceanbase
::
sql
;
namespace
oceanbase
{
namespace
sql
{
const
double
ObExprPi
::
mysql_pi_
=
3.14159265358979323846264338327950288
;
ObExprPi
::
ObExprPi
(
ObIAllocator
&
alloc
)
:
ObFuncExprOperator
(
alloc
,
T_FUN_SYS_PI
,
N_PI
,
0
,
NOT_ROW_DIMENSION
)
{
}
ObExprPi
::~
ObExprPi
()
{
}
int
ObExprPi
::
calc_result_type0
(
ObExprResType
&
type
,
ObExprTypeCtx
&
type_ctx
)
const
{
UNUSED
(
type_ctx
);
type
.
set_double
();
type
.
set_precision
(
-
1
);
type
.
set_scale
(
6
);
return
OB_SUCCESS
;
}
int
ObExprPi
::
calc_result0
(
ObObj
&
result
,
ObExprCtx
&
expr_ctx
)
const
{
UNUSED
(
expr_ctx
);
int
ret
=
OB_SUCCESS
;
result
.
set_double
(
mysql_pi_
);
return
ret
;
}
int
ObExprPi
::
eval_pi
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
)
{
UNUSED
(
expr
);
UNUSED
(
ctx
);
int
ret
=
OB_SUCCESS
;
expr_datum
.
set_double
(
mysql_pi_
);
return
ret
;
}
int
ObExprPi
::
cg_expr
(
ObExprCGCtx
&
op_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
{
UNUSED
(
op_cg_ctx
);
UNUSED
(
raw_expr
);
rt_expr
.
eval_func_
=
ObExprPi
::
eval_pi
;
return
OB_SUCCESS
;
}
}
//namespace sql
}
//namespace oceanbase
src/sql/engine/expr/ob_expr_pi.h
0 → 100644
浏览文件 @
05576007
// Copyright 1999-2021 Alibaba Inc. All Rights Reserved.
// Author:
// xiaofeng.lby@alipay.com
//
// This file is for implementation of func pi
#ifndef OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_PI_
#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_PI_
#include "sql/engine/expr/ob_expr_operator.h"
namespace
oceanbase
{
namespace
sql
{
class
ObExprPi
:
public
ObFuncExprOperator
{
public:
explicit
ObExprPi
(
common
::
ObIAllocator
&
alloc
);
virtual
~
ObExprPi
();
virtual
int
calc_result_type0
(
ObExprResType
&
type
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
;
virtual
int
calc_result0
(
common
::
ObObj
&
result
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
static
int
eval_pi
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
);
virtual
int
cg_expr
(
ObExprCGCtx
&
op_cg_ctx
,
const
ObRawExpr
&
raw_expr
,
ObExpr
&
rt_expr
)
const
override
;
private:
const
static
double
mysql_pi_
;
DISALLOW_COPY_AND_ASSIGN
(
ObExprPi
);
};
}
}
#endif
/* OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_PI_ */
src/sql/parser/ob_item_type.h
浏览文件 @
05576007
...
...
@@ -425,6 +425,7 @@ typedef enum ObItemType {
// T_FUN_SYS_COT = 710, 710 has ben taken on master
T_FUN_SYS_QUARTER
=
711
,
T_FUN_SYS_BIT_LENGTH
=
712
,
T_FUN_SYS_PI
=
713
,
///< @note add new mysql only function type before this line
T_MYSQL_ONLY_SYS_MAX_OP
=
800
,
...
...
src/sql/parser/type_name.c
浏览文件 @
05576007
...
...
@@ -370,6 +370,7 @@ const char* get_type_name(int type)
// case T_FUN_SYS_COT : return "T_FUN_SYS_COT"; 710 has ben taken on master
case
T_FUN_SYS_QUARTER
:
return
"T_FUN_SYS_QUARTER"
;
case
T_FUN_SYS_BIT_LENGTH
:
return
"T_FUN_SYS_BIT_LENGTH"
;
case
T_FUN_SYS_PI
:
return
"T_FUN_SYS_PI"
;
case
T_MYSQL_ONLY_SYS_MAX_OP
:
return
"T_MYSQL_ONLY_SYS_MAX_OP"
;
case
T_FUN_SYS_CONNECT_BY_PATH
:
return
"T_FUN_SYS_CONNECT_BY_PATH"
;
case
T_FUN_SYS_SYSTIMESTAMP
:
return
"T_FUN_SYS_SYSTIMESTAMP"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录