diff --git a/src/share/ob_errno.cpp b/src/share/ob_errno.cpp index c2f2d1caf4..fcfd24fd61 100755 --- a/src/share/ob_errno.cpp +++ b/src/share/ob_errno.cpp @@ -938,7 +938,7 @@ static const _error _error_OB_DIVISION_BY_ZERO = { .error_cause = "Internal Error", .error_solution = "Contact OceanBase Support", .mysql_errno = ER_DIVISION_BY_ZERO, - .sqlstate = "42000", + .sqlstate = "22012", .str_error = "Divided by zero", .str_user_error = "Divided by zero", .oracle_errno = 600, diff --git a/src/share/ob_errno.def b/src/share/ob_errno.def index f478abb301..0171954211 100755 --- a/src/share/ob_errno.def +++ b/src/share/ob_errno.def @@ -163,7 +163,7 @@ DEFINE_ERROR_DEP(OB_LOG_NOT_ALIGN, -4074, -1, "HY000", "Log not aligned"); DEFINE_ERROR(OB_LOG_MISSING, -4075, -1, "HY000", "Log entry missed"); DEFINE_ERROR(OB_NEED_WAIT, -4076, -1, "HY000", "Need wait"); DEFINE_ERROR_DEP(OB_NOT_IMPLEMENT, -4077, -1, "0A000", "Not implemented feature"); -DEFINE_ERROR_DEP(OB_DIVISION_BY_ZERO, -4078, ER_DIVISION_BY_ZERO, "42000", "Divided by zero"); +DEFINE_ERROR_DEP(OB_DIVISION_BY_ZERO, -4078, ER_DIVISION_BY_ZERO, "22012", "Divided by zero"); DEFINE_ERROR_DEP(OB_EXCEED_MEM_LIMIT, -4080, -1, "HY013", "exceed memory limit"); DEFINE_ERROR(OB_RESULT_UNKNOWN, -4081, -1, "HY000", "Unknown result"); DEFINE_ERROR(OB_NO_RESULT, -4084, -1, "02000", "No result"); diff --git a/src/share/object/ob_obj_cast.cpp b/src/share/object/ob_obj_cast.cpp index 89eeb3fd4b..770d0f8f53 100644 --- a/src/share/object/ob_obj_cast.cpp +++ b/src/share/object/ob_obj_cast.cpp @@ -5095,8 +5095,12 @@ static int string_double(const ObObjType expect_type, ObObjCastParams ¶ms, } else if (OB_SUCCESS != (ret = check_convert_str_err( str_utf8.ptr(), endptr, str_utf8.length(), err, in.get_collation_type()))) { LOG_WARN("failed to check_convert_str_err", K(ret), K(str_utf8), K(value), K(err), K(in.get_collation_type())); - ret = OB_ERR_DOUBLE_TRUNCATED; + // Compatible with oracle error massage, mapping `OB_ERR_DOUBLE_TRUNCATED` to invalid number error + if (lib::is_oracle_mode()) { + ret = OB_ERR_DOUBLE_TRUNCATED; + } if (CM_IS_WARN_ON_FAIL(cast_mode)) { + ret = OB_ERR_DOUBLE_TRUNCATED; LOG_USER_WARN(OB_ERR_DOUBLE_TRUNCATED, str_utf8.length(), str_utf8.ptr()); } } diff --git a/src/sql/engine/expr/ob_datum_cast.cpp b/src/sql/engine/expr/ob_datum_cast.cpp index 5e55564a66..c6ebb50477 100644 --- a/src/sql/engine/expr/ob_datum_cast.cpp +++ b/src/sql/engine/expr/ob_datum_cast.cpp @@ -967,8 +967,12 @@ int common_string_double(const ObExpr &expr, } } else if (OB_FAIL(check_convert_str_err(in_str.ptr(), endptr, in_str.length(), err, in_cs_type))) { LOG_WARN("failed to check_convert_str_err", K(ret), K(in_str), K(out_val), K(err), K(in_cs_type)); - ret = OB_ERR_DOUBLE_TRUNCATED; + // Compatible with oracle error massage, mapping `OB_ERR_DOUBLE_TRUNCATED` to invalid number error + if (lib::is_oracle_mode()) { + ret = OB_ERR_DOUBLE_TRUNCATED; + } if (CM_IS_WARN_ON_FAIL(expr.extra_)) { + ret = OB_ERR_DOUBLE_TRUNCATED; LOG_USER_WARN(OB_ERR_DOUBLE_TRUNCATED, in_str.length(), in_str.ptr()); } }