patch 4.0
This commit is contained in:
@ -18,21 +18,28 @@
|
||||
#include "sql/engine/expr/ob_expr_result_type_util.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
|
||||
constexpr double EPSILON = 0.000000001;
|
||||
|
||||
ObExprMod::ObExprMod(ObIAllocator& alloc)
|
||||
: ObArithExprOperator(alloc, T_OP_MOD, N_MOD, 2, NOT_ROW_DIMENSION, ObExprResultTypeUtil::get_mod_result_type,
|
||||
ObExprResultTypeUtil::get_mod_calc_type, mod_funcs_)
|
||||
ObExprMod::ObExprMod(ObIAllocator &alloc)
|
||||
: ObArithExprOperator(alloc, T_OP_MOD,
|
||||
N_MOD,
|
||||
2,
|
||||
NOT_ROW_DIMENSION,
|
||||
ObExprResultTypeUtil::get_mod_result_type,
|
||||
ObExprResultTypeUtil::get_mod_calc_type,
|
||||
mod_funcs_)
|
||||
{
|
||||
param_lazy_eval_ = true;
|
||||
}
|
||||
|
||||
int ObExprMod::calc_result_type2(
|
||||
ObExprResType& type, ObExprResType& type1, ObExprResType& type2, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprMod::calc_result_type2(ObExprResType &type,
|
||||
ObExprResType &type1,
|
||||
ObExprResType &type2,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(ObArithExprOperator::calc_result_type2(type, type1, type2, type_ctx))) {
|
||||
@ -42,91 +49,53 @@ int ObExprMod::calc_result_type2(
|
||||
} else {
|
||||
ObScale scale1 = static_cast<ObScale>(MAX(type1.get_scale(), 0));
|
||||
ObScale scale2 = static_cast<ObScale>(MAX(type2.get_scale(), 0));
|
||||
if (OB_UNLIKELY(SCALE_UNKNOWN_YET == type1.get_scale()) || OB_UNLIKELY(SCALE_UNKNOWN_YET == type2.get_scale())) {
|
||||
if (OB_UNLIKELY(SCALE_UNKNOWN_YET == type1.get_scale()) ||
|
||||
OB_UNLIKELY(SCALE_UNKNOWN_YET == type2.get_scale())) {
|
||||
type.set_scale(SCALE_UNKNOWN_YET);
|
||||
} else {
|
||||
type.set_scale(MAX(scale1, scale2));
|
||||
type.set_precision(MAX(type1.get_precision(), type2.get_precision()));
|
||||
type.set_precision(MAX(type1.get_precision(),type2.get_precision()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::calc_result2(ObObj& res, const ObObj& left, const ObObj& right, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(param_eval(expr_ctx, left, 0))) {
|
||||
LOG_WARN("failed to calculate parameter 0", K(ret));
|
||||
} else if (OB_UNLIKELY(ObNullType == left.get_type())) {
|
||||
res.set_null();
|
||||
} else if (OB_FAIL(param_eval(expr_ctx, right, 1))) {
|
||||
LOG_WARN("failed to calculate parameter 1", K(ret));
|
||||
} else if (OB_UNLIKELY(ObNullType == right.get_type())) {
|
||||
res.set_null();
|
||||
} else {
|
||||
ObObjTypeClass tc1 = left.get_type_class();
|
||||
ObObjTypeClass tc2 = right.get_type_class();
|
||||
ObScale calc_scale = result_type_.get_calc_scale();
|
||||
ObObjType calc_type = result_type_.get_calc_type();
|
||||
if (ObIntTC == tc1) {
|
||||
if (ObIntTC == tc2 || ObUIntTC == tc2) {
|
||||
ret = mod_int(res, left, right, expr_ctx.calc_buf_, calc_scale);
|
||||
} else {
|
||||
ret = ObArithExprOperator::calc_(res, left, right, expr_ctx, calc_scale, calc_type, mod_funcs_);
|
||||
}
|
||||
} else if (ObUIntTC == tc1) {
|
||||
if (ObIntTC == tc2 || ObUIntTC == tc2) {
|
||||
ret = mod_uint(res, left, right, expr_ctx.calc_buf_, calc_scale);
|
||||
} else {
|
||||
ret = ObArithExprOperator::calc_(res, left, right, expr_ctx, calc_scale, calc_type, mod_funcs_);
|
||||
}
|
||||
} else {
|
||||
ret = ObArithExprOperator::calc_(res, left, right, expr_ctx, calc_scale, calc_type, mod_funcs_);
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && result_type_.get_type() != res.get_type() && res.get_type() != ObNullType) {
|
||||
const ObObj* res_obj = NULL;
|
||||
EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE);
|
||||
EXPR_CAST_OBJ_V2(result_type_.get_type(), res, res_obj);
|
||||
if (OB_FAIL(ret)) {
|
||||
LOG_WARN("cast failed", K(ret), K(left), K(right));
|
||||
} else if (OB_ISNULL(res_obj)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null pointer", K(ret), K(left), K(right));
|
||||
} else {
|
||||
res = *res_obj;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::calc(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::calc(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
ObCalcTypeFunc calc_type_func = ObExprResultTypeUtil::get_mod_result_type;
|
||||
return ObArithExprOperator::calc(res, left, right, allocator, scale, calc_type_func, mod_funcs_);
|
||||
}
|
||||
|
||||
ObArithFunc ObExprMod::mod_funcs_[ObMaxTC] = {
|
||||
NULL,
|
||||
ObExprMod::mod_int,
|
||||
ObExprMod::mod_uint,
|
||||
ObExprMod::mod_float,
|
||||
ObExprMod::mod_double,
|
||||
ObExprMod::mod_number,
|
||||
NULL, // datetime
|
||||
NULL, // date
|
||||
NULL, // time
|
||||
NULL, // year
|
||||
NULL, // varchar
|
||||
NULL, // extend
|
||||
NULL, // unknown
|
||||
NULL, // text
|
||||
NULL, // bit
|
||||
NULL, // enumset
|
||||
NULL, // enumsetInner
|
||||
ObArithFunc ObExprMod::mod_funcs_[ObMaxTC] =
|
||||
{
|
||||
NULL,
|
||||
ObExprMod::mod_int,
|
||||
ObExprMod::mod_uint,
|
||||
ObExprMod::mod_float,
|
||||
ObExprMod::mod_double,
|
||||
ObExprMod::mod_number,
|
||||
NULL,//datetime
|
||||
NULL,//date
|
||||
NULL,//time
|
||||
NULL,//year
|
||||
NULL,//varchar
|
||||
NULL,//extend
|
||||
NULL,//unknown
|
||||
NULL,//text
|
||||
NULL,//bit
|
||||
NULL,//enumset
|
||||
NULL,//enumsetInner
|
||||
};
|
||||
|
||||
int ObExprMod::mod_int(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::mod_int(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t left_i = left.get_int();
|
||||
@ -139,7 +108,7 @@ int ObExprMod::mod_int(ObObj& res, const ObObj& left, const ObObj& right, ObIAll
|
||||
}
|
||||
} else if (OB_LIKELY(left.get_type_class() == right.get_type_class())) {
|
||||
if (INT64_MIN == left_i && -1 == right_i) {
|
||||
res.set_int(0); // INT64_MIN % -1 --> FPE
|
||||
res.set_int(0); //INT64_MIN % -1 --> FPE
|
||||
} else {
|
||||
res.set_int(left_i % right_i);
|
||||
}
|
||||
@ -158,7 +127,11 @@ int ObExprMod::mod_int(ObObj& res, const ObObj& left, const ObObj& right, ObIAll
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_uint(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::mod_uint(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t left_ui = left.get_uint64();
|
||||
@ -186,7 +159,11 @@ int ObExprMod::mod_uint(ObObj& res, const ObObj& left, const ObObj& right, ObIAl
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_float(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::mod_float(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
|
||||
int ret = OB_SUCCESS;
|
||||
@ -196,7 +173,7 @@ int ObExprMod::mod_float(ObObj& res, const ObObj& left, const ObObj& right, ObIA
|
||||
} else if (OB_UNLIKELY(left.get_type_class() != right.get_type_class())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid types", K(ret), K(left), K(right));
|
||||
} else if (fabsf(right.get_float()) < EPSILON) {
|
||||
} else if (fabsf(right.get_float()) == 0.0) {
|
||||
res.set_float(left.get_float());
|
||||
} else {
|
||||
res.set_float(fmodf(left.get_float(), right.get_float()));
|
||||
@ -207,14 +184,18 @@ int ObExprMod::mod_float(ObObj& res, const ObObj& left, const ObObj& right, ObIA
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_double(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::mod_double(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(left.get_type_class() != right.get_type_class())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid types", K(ret), K(left), K(right));
|
||||
} else if (fabs(right.get_double()) < EPSILON) {
|
||||
} else if (fabs(right.get_double()) == 0.0) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
res.set_double(left.get_double());
|
||||
} else {
|
||||
@ -229,7 +210,11 @@ int ObExprMod::mod_double(ObObj& res, const ObObj& left, const ObObj& right, ObI
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_number(ObObj& res, const ObObj& left, const ObObj& right, ObIAllocator* allocator, ObScale scale)
|
||||
int ObExprMod::mod_number(ObObj &res,
|
||||
const ObObj &left,
|
||||
const ObObj &right,
|
||||
ObIAllocator *allocator,
|
||||
ObScale scale)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
number::ObNumber res_nmb;
|
||||
@ -251,28 +236,30 @@ int ObExprMod::mod_number(ObObj& res, const ObObj& left, const ObObj& right, ObI
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_int_int(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_int_int(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
int64_t left_i = left->get_int();
|
||||
int64_t right_i = right->get_int();
|
||||
if (OB_UNLIKELY(0 == right_i)) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_int(left_i);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
} else {
|
||||
if (INT64_MIN == left_i && -1 == right_i) {
|
||||
datum.set_int(0); // INT64_MIN % -1 --> FPE
|
||||
datum.set_int(0); //INT64_MIN % -1 --> FPE
|
||||
} else {
|
||||
datum.set_int(left_i % right_i);
|
||||
}
|
||||
@ -281,22 +268,24 @@ int ObExprMod::mod_int_int(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_int_uint(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_int_uint(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
int64_t left_i = left->get_int();
|
||||
uint64_t right_ui = right->get_uint();
|
||||
if (OB_UNLIKELY(0 == right_ui)) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_int(left_i);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
@ -311,22 +300,24 @@ int ObExprMod::mod_int_uint(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_uint_int(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_uint_int(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
uint64_t left_ui = left->get_uint();
|
||||
int64_t right_i = right->get_int();
|
||||
if (OB_UNLIKELY(0 == right_i)) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_uint(left_ui);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
@ -337,22 +328,24 @@ int ObExprMod::mod_uint_int(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_uint_uint(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_uint_uint(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
uint64_t left_ui = left->get_uint();
|
||||
uint64_t right_ui = right->get_uint();
|
||||
if (OB_UNLIKELY(0 == right_ui)) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_uint(left_ui);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
@ -363,11 +356,12 @@ int ObExprMod::mod_uint_uint(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_float(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
|
||||
int ObExprMod::mod_float(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_UNLIKELY(!lib::is_oracle_mode())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -375,11 +369,11 @@ int ObExprMod::mod_float(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
} else if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
const float left_f = left->get_float();
|
||||
const float right_f = right->get_float();
|
||||
if (fabsf(right_f) < share::ObUnitConfig::CPU_EPSILON) {
|
||||
if (fabsf(right_f) < share::ObUnitResource::CPU_EPSILON) {
|
||||
datum.set_float(left_f);
|
||||
} else {
|
||||
datum.set_float(fmodf(left_f, right_f));
|
||||
@ -389,22 +383,24 @@ int ObExprMod::mod_float(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_double(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_double(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
const double left_d = left->get_double();
|
||||
const double right_d = right->get_double();
|
||||
if (fabs(right_d) < EPSILON) {
|
||||
if (fabs(right_d) == 0.0) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_double(left_d);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
@ -416,22 +412,24 @@ int ObExprMod::mod_double(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::mod_number(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
int ObExprMod::mod_number(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum* left = NULL;
|
||||
ObDatum* right = NULL;
|
||||
ObDatum *left = NULL;
|
||||
ObDatum *right = NULL;
|
||||
bool is_finish = false;
|
||||
if (OB_FAIL(get_arith_operand(expr, ctx, left, right, datum, is_finish))) {
|
||||
LOG_WARN("get_arith_operand failed", K(ret));
|
||||
} else if (is_finish) {
|
||||
// do nothing
|
||||
//do nothing
|
||||
} else {
|
||||
const number::ObNumber lnum(left->get_number());
|
||||
const number::ObNumber rnum(right->get_number());
|
||||
if (OB_UNLIKELY(rnum.is_zero())) {
|
||||
if (lib::is_oracle_mode()) {
|
||||
datum.set_number(lnum);
|
||||
} else if (CM_IS_ERROR_FOR_DIVISION_BY_ZERO(expr.extra_)) {
|
||||
ret = OB_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
datum.set_null();
|
||||
}
|
||||
@ -449,11 +447,13 @@ int ObExprMod::mod_number(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprMod::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
|
||||
int ObExprMod::cg_expr(ObExprCGCtx &op_cg_ctx,
|
||||
const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(raw_expr);
|
||||
UNUSED(op_cg_ctx);
|
||||
OB_ASSERT(2 == rt_expr.arg_cnt_);
|
||||
OB_ASSERT(NULL != rt_expr.args_);
|
||||
OB_ASSERT(NULL != rt_expr.args_[0]);
|
||||
@ -506,7 +506,7 @@ int ObExprMod::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// do nothing
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -514,9 +514,25 @@ int ObExprMod::cg_expr(ObExprCGCtx& op_cg_ctx, const ObRawExpr& raw_expr, ObExpr
|
||||
if (OB_ISNULL(rt_expr.eval_func_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected result type", K(ret), K(rt_expr.datum_meta_.type_), K(left), K(right));
|
||||
} else if (OB_ISNULL(op_cg_ctx.session_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected session is null", K(ret));
|
||||
} else {
|
||||
stmt::StmtType stmt_type = op_cg_ctx.session_->get_stmt_type();
|
||||
if (lib::is_mysql_mode()
|
||||
&& is_error_for_division_by_zero(op_cg_ctx.session_->get_sql_mode())
|
||||
&& is_strict_mode(op_cg_ctx.session_->get_sql_mode())
|
||||
&& !op_cg_ctx.session_->is_ignore_stmt()
|
||||
&& (stmt::T_INSERT == stmt_type
|
||||
|| stmt::T_REPLACE == stmt_type
|
||||
|| stmt::T_UPDATE == stmt_type)) {
|
||||
rt_expr.extra_ |= CM_ERROR_FOR_DIVISION_BY_ZERO;
|
||||
} else {
|
||||
rt_expr.extra_ &= ~CM_ERROR_FOR_DIVISION_BY_ZERO;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user