patch 4.0
This commit is contained in:
@ -17,57 +17,33 @@
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "lib/number/ob_number_v2.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace oceanbase::common;
|
||||
|
||||
namespace sql {
|
||||
ObExprExp::ObExprExp(ObIAllocator& alloc) : ObFuncExprOperator(alloc, T_FUN_SYS_EXP, N_EXP, 1, NOT_ROW_DIMENSION)
|
||||
{}
|
||||
namespace sql
|
||||
{
|
||||
ObExprExp::ObExprExp(ObIAllocator &alloc)
|
||||
: ObFuncExprOperator(alloc, T_FUN_SYS_EXP, N_EXP, 1, NOT_ROW_DIMENSION)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprExp::~ObExprExp()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprExp::calc_result_type1(ObExprResType& type, ObExprResType& type1, common::ObExprTypeCtx& type_ctx) const
|
||||
int ObExprExp::calc_result_type1(ObExprResType &type,
|
||||
ObExprResType &type1,
|
||||
common::ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
return calc_trig_function_result_type1(type, type1, type_ctx);
|
||||
}
|
||||
|
||||
int ObExprExp::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ctx) const
|
||||
int calc_exp_expr_double(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObDatum &res_datum)
|
||||
{
|
||||
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 (obj.is_null()) {
|
||||
result.set_null();
|
||||
} else if (obj.is_number()) {
|
||||
const number::ObNumber arg_number = obj.get_number();
|
||||
number::ObNumber result_number;
|
||||
common::ObIAllocator& allocator = *(expr_ctx.calc_buf_);
|
||||
if (OB_FAIL(arg_number.e_power(result_number, allocator))) {
|
||||
LOG_WARN("e_power failed", K(ret), K(arg_number), K(result_number));
|
||||
} else {
|
||||
result.set_number(result_number);
|
||||
}
|
||||
} else if (obj.is_double()) {
|
||||
double value = obj.get_double();
|
||||
value = exp(value);
|
||||
if (isinf(value) || isnan(value)) {
|
||||
ret = OB_OPERATE_OVERFLOW;
|
||||
} else {
|
||||
result.set_double(value);
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("obj type should be number or double", K(obj), K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int calc_exp_expr_double(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* arg = NULL;
|
||||
ObDatum *arg = NULL;
|
||||
if (OB_FAIL(expr.args_[0]->eval(ctx, arg))) {
|
||||
LOG_WARN("eval arg failed", K(ret), K(expr));
|
||||
} else if (arg->is_null()) {
|
||||
@ -84,10 +60,11 @@ int calc_exp_expr_double(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int calc_exp_expr_number(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
||||
int calc_exp_expr_number(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObDatum &res_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* arg = NULL;
|
||||
ObDatum *arg = NULL;
|
||||
if (OB_FAIL(expr.args_[0]->eval(ctx, arg))) {
|
||||
LOG_WARN("eval arg failed", K(ret), K(expr));
|
||||
} else if (arg->is_null()) {
|
||||
@ -95,7 +72,8 @@ int calc_exp_expr_number(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
||||
} else {
|
||||
number::ObNumber arg_nmb(arg->get_number());
|
||||
number::ObNumber res_nmb;
|
||||
if (OB_FAIL(arg_nmb.e_power(res_nmb, ctx.get_reset_tmp_alloc()))) {
|
||||
ObEvalCtx::TempAllocGuard alloc_guard(ctx);
|
||||
if (OB_FAIL(arg_nmb.e_power(res_nmb, alloc_guard.get_allocator()))) {
|
||||
LOG_WARN("e_power failed", K(ret));
|
||||
} else {
|
||||
res_datum.set_number(res_nmb);
|
||||
@ -104,7 +82,8 @@ int calc_exp_expr_number(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprExp::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
int ObExprExp::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(expr_cg_ctx);
|
||||
@ -126,5 +105,5 @@ int ObExprExp::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, ObEx
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
Reference in New Issue
Block a user