patch 4.0
This commit is contained in:
@ -16,54 +16,37 @@
|
||||
#include "lib/number/ob_number_v2.h"
|
||||
#include "sql/engine/expr/ob_expr_cos.h"
|
||||
#include "sql/engine/expr/ob_expr_util.h"
|
||||
#include "sql/parser/ob_item_type.h"
|
||||
#include "objit/common/ob_item_type.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
using namespace common::number;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprCos::ObExprCos(ObIAllocator& alloc) : ObFuncExprOperator(alloc, T_FUN_SYS_COS, N_COS, 1, NOT_ROW_DIMENSION)
|
||||
{}
|
||||
ObExprCos::ObExprCos(ObIAllocator &alloc)
|
||||
: ObFuncExprOperator(alloc, T_FUN_SYS_COS, N_COS, 1, NOT_ROW_DIMENSION)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprCos::~ObExprCos()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprCos::calc_result_type1(ObExprResType& type, ObExprResType& radian, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprCos::calc_result_type1(ObExprResType &type,
|
||||
ObExprResType &radian,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
return calc_trig_function_result_type1(type, radian, type_ctx);
|
||||
}
|
||||
|
||||
int ObExprCos::calc_result1(ObObj& result, const ObObj& radian_obj, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (radian_obj.is_null_oracle()) {
|
||||
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_number()) {
|
||||
ObNumber num;
|
||||
if (OB_FAIL(radian_obj.get_number(num))) {
|
||||
LOG_WARN("get_number failed", K(radian_obj));
|
||||
} else if (OB_FAIL(num.cos(num, *(expr_ctx.calc_buf_)))) {
|
||||
LOG_WARN("taylor_series_cos failed", K(num), K(ret));
|
||||
} else {
|
||||
result.set_number(num);
|
||||
}
|
||||
} else if (radian_obj.is_double()) {
|
||||
double arg = radian_obj.get_double();
|
||||
double res = cos(arg);
|
||||
result.set_double(res);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEF_CALC_TRIGONOMETRIC_EXPR(cos, false, OB_SUCCESS);
|
||||
|
||||
int ObExprCos::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprCos::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(expr_cg_ctx);
|
||||
@ -72,5 +55,5 @@ int ObExprCos::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObEx
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} /* sql */
|
||||
} /* oceanbase */
|
||||
|
||||
Reference in New Issue
Block a user