Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caoersss
oceanbase
提交
889d5cb6
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,发现更多精彩内容 >>
提交
889d5cb6
编写于
7月 21, 2021
作者:
L
ls0
提交者:
wangzelin.wzl
7月 21, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement expr asin/acos/cot/cos in mysql mode
上级
26d446e4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
118 addition
and
5 deletion
+118
-5
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_acos.cpp
src/sql/engine/expr/ob_expr_acos.cpp
+1
-1
src/sql/engine/expr/ob_expr_asin.cpp
src/sql/engine/expr/ob_expr_asin.cpp
+1
-1
src/sql/engine/expr/ob_expr_cot.cpp
src/sql/engine/expr/ob_expr_cot.cpp
+70
-0
src/sql/engine/expr/ob_expr_cot.h
src/sql/engine/expr/ob_expr_cot.h
+35
-0
src/sql/engine/expr/ob_expr_operator.cpp
src/sql/engine/expr/ob_expr_operator.cpp
+1
-1
src/sql/engine/expr/ob_expr_operator_factory.cpp
src/sql/engine/expr/ob_expr_operator_factory.cpp
+5
-0
src/sql/engine/expr/ob_expr_util.h
src/sql/engine/expr/ob_expr_util.h
+1
-1
src/sql/parser/ob_item_type.h
src/sql/parser/ob_item_type.h
+1
-1
src/sql/parser/type_name.c
src/sql/parser/type_name.c
+1
-0
未找到文件。
deps/oblib/src/lib/ob_name_def.h
浏览文件 @
889d5cb6
...
...
@@ -130,6 +130,7 @@
#define N_ACOS "acos"
#define N_ATAN "atan"
#define N_ATAN2 "atan2"
#define N_COT "cot"
#define N_PUMP_ROW_DESC "pump_row_desc"
#define N_ROOT_ROW_DESC "root_row_desc"
#define N_PSEUDO_COLUMN_ROW_DESC "pseudo_column_row_desc"
...
...
src/sql/CMakeLists.txt
浏览文件 @
889d5cb6
...
...
@@ -195,6 +195,7 @@ ob_set_subtarget(ob_sql engine
engine/expr/ob_expr_tan.cpp
engine/expr/ob_expr_atan.cpp
engine/expr/ob_expr_atan2.cpp
engine/expr/ob_expr_cot.cpp
engine/expr/ob_expr_between.cpp
engine/expr/ob_expr_bit_and.cpp
engine/expr/ob_expr_bit_count.cpp
...
...
src/sql/engine/expr/ob_expr_acos.cpp
浏览文件 @
889d5cb6
...
...
@@ -52,7 +52,7 @@ int ObExprAcos::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ct
}
else
if
(
obj
.
is_double
())
{
double
arg
=
obj
.
get_double
();
if
(
arg
>
1
||
arg
<
-
1
)
{
re
t
=
OB_ERR_ARGUMENT_OUT_OF_RANGE
;
re
sult
.
set_null
()
;
}
else
{
double
res
=
acos
(
arg
);
result
.
set_double
(
res
);
...
...
src/sql/engine/expr/ob_expr_asin.cpp
浏览文件 @
889d5cb6
...
...
@@ -53,7 +53,7 @@ int ObExprAsin::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ct
}
else
if
(
obj
.
is_double
())
{
double
arg
=
obj
.
get_double
();
if
(
arg
>
1
||
arg
<
-
1
)
{
re
t
=
OB_ERR_ARGUMENT_OUT_OF_RANGE
;
re
sult
.
set_null
()
;
}
else
{
double
res
=
asin
(
arg
);
result
.
set_double
(
res
);
...
...
src/sql/engine/expr/ob_expr_cot.cpp
0 → 100644
浏览文件 @
889d5cb6
/**
* Copyright 2014-2016 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.
*
*
* Authors:
* zimiao<kaizhan.dkz@antgroup.com>
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/parser/ob_item_type.h"
#include "lib/oblog/ob_log.h"
#include "lib/number/ob_number_v2.h"
#include "sql/engine/expr/ob_expr_cot.h"
#include "sql/session/ob_sql_session_info.h"
#include <math.h>
namespace
oceanbase
{
using
namespace
common
;
using
namespace
common
::
number
;
namespace
sql
{
ObExprCot
::
ObExprCot
(
ObIAllocator
&
alloc
)
:
ObFuncExprOperator
(
alloc
,
T_FUN_SYS_COT
,
N_COT
,
1
,
NOT_ROW_DIMENSION
)
{
}
ObExprCot
::~
ObExprCot
()
{
}
int
ObExprCot
::
calc_result_type1
(
ObExprResType
&
type
,
ObExprResType
&
radian
,
ObExprTypeCtx
&
type_ctx
)
const
{
return
calc_trig_function_result_type1
(
type
,
radian
,
type_ctx
);
}
int
ObExprCot
::
calc_result1
(
ObObj
&
result
,
const
ObObj
&
radian_obj
,
ObExprCtx
&
expr_ctx
)
const
{
int
ret
=
OB_SUCCESS
;
if
(
radian_obj
.
is_null
())
{
result
.
set_null
();
}
else
if
(
OB_ISNULL
(
expr_ctx
.
calc_buf_
))
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"expr_ctx.calc_buf_ is NULL"
,
K
(
ret
));
}
else
if
(
radian_obj
.
is_double
())
{
double
arg
=
radian_obj
.
get_double
();
double
tan_out
=
tan
(
arg
);
// to check tan(arg) is small enough to be zero
if
(
0.0
==
tan_out
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"tan(x) is zero"
,
K
(
ret
));
}
else
{
double
res
=
1.0
/
tan_out
;
if
(
!
std
::
isfinite
(
res
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"tan(x) is like zero"
,
K
(
ret
));
}
else
{
result
.
set_double
(
res
);
}
}
}
else
{
ret
=
OB_ERR_UNEXPECTED
;
}
return
ret
;
}
}
/* sql */
}
/* oceanbase */
\ No newline at end of file
src/sql/engine/expr/ob_expr_cot.h
0 → 100644
浏览文件 @
889d5cb6
/**
* Copyright 2014-2016 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.
*
*
* Authors:
* zimiao<kaizhan.dkz@antgroup.com>
*/
#ifndef OCEANBASE_SQL_ENGINE_EXPR_COT_
#define OCEANBASE_SQL_ENGINE_EXPR_COT_
#include "sql/engine/expr/ob_expr_operator.h"
namespace
oceanbase
{
namespace
sql
{
class
ObExprCot
:
public
ObFuncExprOperator
{
public:
explicit
ObExprCot
(
common
::
ObIAllocator
&
alloc
);
virtual
~
ObExprCot
();
virtual
int
calc_result_type1
(
ObExprResType
&
type
,
ObExprResType
&
radian
,
common
::
ObExprTypeCtx
&
type_ctx
)
const
;
virtual
int
calc_result1
(
common
::
ObObj
&
result
,
const
common
::
ObObj
&
radian_obj
,
common
::
ObExprCtx
&
expr_ctx
)
const
;
private:
DISALLOW_COPY_AND_ASSIGN
(
ObExprCot
);
};
}
}
#endif
/* OCEANBASE_SQL_ENGINE_EXPR_COT_ */
\ No newline at end of file
src/sql/engine/expr/ob_expr_operator.cpp
浏览文件 @
889d5cb6
...
...
@@ -1591,7 +1591,7 @@ int ObExprOperator::calc_trig_function_result_type1(
type
.
set_precision
(
ObAccuracy
::
DDL_DEFAULT_ACCURACY2
[
ORACLE_MODE
][
type
.
get_type
()].
get_precision
());
}
type1
.
set_calc_type
(
type
.
get_type
());
ObExprOperator
::
calc_result_flag1
(
type
,
type1
);
//no need add not null check for trig/ln/e funciotn in mysql mode
return
ret
;
}
...
...
src/sql/engine/expr/ob_expr_operator_factory.cpp
浏览文件 @
889d5cb6
...
...
@@ -105,6 +105,7 @@
#include "sql/engine/expr/ob_expr_sinh.h"
#include "sql/engine/expr/ob_expr_cosh.h"
#include "sql/engine/expr/ob_expr_tanh.h"
#include "sql/engine/expr/ob_expr_cot.h"
#include "sql/engine/expr/ob_expr_trim.h"
#include "sql/engine/expr/ob_expr_inner_trim.h"
#include "sql/engine/expr/ob_expr_unhex.h"
...
...
@@ -638,6 +639,10 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP
(
ObExprBool
);
REG_OP
(
ObExprSin
);
REG_OP
(
ObExprTan
);
REG_OP
(
ObExprCos
);
REG_OP
(
ObExprCot
);
REG_OP
(
ObExprAsin
);
REG_OP
(
ObExprAcos
);
REG_OP
(
ObExprCalcPartitionId
);
REG_OP
(
ObExprPartIdPseudoColumn
);
REG_OP
(
ObExprStmtId
);
...
...
src/sql/engine/expr/ob_expr_util.h
浏览文件 @
889d5cb6
...
...
@@ -145,7 +145,7 @@ T ObExprUtil::trunc_integer(T val, int64_t dec)
} else if (ObDoubleType == expr.args_[0]->datum_meta_.type_) { \
const double arg = radian->get_double(); \
if (INVALID_DOUBLE_ARG_CHECK) { \
re
t = INVALID_DOUBLE_ARG_ERRNO;
\
re
s_datum.set_null();
\
} else { \
res_datum.set_double(tritype(arg)); \
} \
...
...
src/sql/parser/ob_item_type.h
浏览文件 @
889d5cb6
...
...
@@ -422,7 +422,7 @@ typedef enum ObItemType {
T_FUN_SYS_MAKETIME
=
707
,
T_FUN_SYS_MONTH_NAME
=
708
,
T_FUN_SYS_FORMAT
=
709
,
// T_FUN_SYS_COT = 710, 710 has ben taken on master
T_FUN_SYS_COT
=
710
,
T_FUN_SYS_QUARTER
=
711
,
T_FUN_SYS_BIT_LENGTH
=
712
,
T_FUN_SYS_PI
=
713
,
...
...
src/sql/parser/type_name.c
浏览文件 @
889d5cb6
...
...
@@ -439,6 +439,7 @@ const char* get_type_name(int type)
case
T_FUN_SYS_ACOS
:
return
"T_FUN_SYS_ACOS"
;
case
T_FUN_SYS_ATAN
:
return
"T_FUN_SYS_ATAN"
;
case
T_FUN_SYS_ATAN2
:
return
"T_FUN_SYS_ATAN2"
;
case
T_FUN_SYS_COT
:
return
"T_FUN_SYS_COT"
;
case
T_FUN_SYS_REGEXP_COUNT
:
return
"T_FUN_SYS_REGEXP_COUNT"
;
case
T_FUN_NVL2
:
return
"T_FUN_NVL2"
;
case
T_FUN_SYS_TO_BINARY_FLOAT
:
return
"T_FUN_SYS_TO_BINARY_FLOAT"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录