fix several compatibility bug

This commit is contained in:
akaError
2023-08-10 03:42:46 +00:00
committed by ob-robot
parent ee04441040
commit e0a0ce93bd
10 changed files with 116 additions and 23 deletions

View File

@ -8659,7 +8659,9 @@ int anytype_to_varchar_char_explicit(const sql::ObExpr &expr,
src_meta = expr.args_[0]->datum_meta_;
}
if (OB_LIKELY(OB_ERR_DATA_TOO_LONG == ret)) {
if (ob_is_character_type(src_meta.type_, src_meta.cs_type_) && lib::is_oracle_mode()) {
if (lib::is_oracle_mode() &&
(ob_is_character_type(src_meta.type_, src_meta.cs_type_) ||
ob_is_raw(src_meta.type_))) {
ret = OB_SUCCESS;
} else if ((ob_is_clob(src_meta.type_, src_meta.cs_type_)
|| ob_is_clob_locator(src_meta.type_, src_meta.cs_type_)

View File

@ -285,7 +285,8 @@ int ObExprColumnConv::calc_result_typeN(ObExprResType &type,
LOG_WARN("inconsistent datatypes", "expected", type_tc, "got", value_tc);
} else {
type_ctx.set_cast_mode(
type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra() | CM_COLUMN_CONVERT);
type_ctx.get_cast_mode() | type_ctx.get_raw_expr()->get_extra() | CM_COLUMN_CONVERT
| CM_CHARSET_CONVERT_IGNORE_ERR);
types[4].set_calc_meta(type);
}
}

View File

@ -20,6 +20,7 @@
#include "sql/session/ob_sql_session_info.h"
#include "sql/engine/ob_exec_context.h"
#include "ob_datum_cast.h"
#include "common/object/ob_obj_type.h"
using namespace oceanbase::common;
using namespace oceanbase::sql;
@ -192,8 +193,11 @@ int ObExprDateAdjust::calc_date_adjust(const ObExpr &expr, ObEvalCtx &ctx, ObDat
expr_datum.set_null();
} else if (OB_FAIL(ObTimeConverter::date_adjust(dt_val, interval_val, unit_val, res_dt_val,
is_add, date_sql_mode))) {
if (OB_UNLIKELY(OB_INVALID_DATE_VALUE == ret)) {
if (OB_UNLIKELY(OB_INVALID_DATE_VALUE == ret || OB_TOO_MANY_DATETIME_PARTS == ret)) {
expr_datum.set_null();
if (OB_TOO_MANY_DATETIME_PARTS == ret) {
LOG_USER_WARN(OB_TOO_MANY_DATETIME_PARTS);
}
ret = OB_SUCCESS;
}
} else if (ObDateType == res_type) {
@ -549,7 +553,16 @@ int ObExprNextDay::calc_result_type2(ObExprResType &type,
type.set_scale(OB_MAX_DATE_PRECISION);
type1.set_calc_type(ObDateTimeType);
type1.set_calc_scale(OB_MAX_DATETIME_PRECISION);
type2.set_calc_type(ObVarcharType);
if (ob_is_numeric_tc(type2.get_type_class())) {
if (lib::is_oracle_mode()) {
type2.set_calc_type(ObNumberType);
} else {
type2.set_calc_type(ObUInt64Type);
}
} else {
type2.set_calc_type(ObVarcharType);
}
}
return ret;
}
@ -588,13 +601,31 @@ int ObExprNextDay::calc_next_day(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &ex
LOG_WARN("eval second param value failed");
} else if (param2->is_null()) {
expr_datum.set_null();
} else if (ob_is_numeric_tc(ob_obj_type_class(expr.args_[1]->datum_meta_.type_))) {
int64_t ori_date_utc = param1->get_datetime();
ObString wday_name = ObString(0,"");//not use
int64_t wday_count = 0;
int64_t res_date_utc = 0;
number::ObNumber wdaycount(param2->get_number());
if (OB_FAIL(wdaycount.extract_valid_int64_with_trunc(wday_count))) {
LOG_WARN("fail to do round", K(ret));
} else if (OB_FAIL(ObTimeConverter::calc_next_date_of_the_wday(ori_date_utc,
wday_name.trim(),
wday_count,
res_date_utc))) {
LOG_WARN("fail to calc next mday", K(ret));
} else {
expr_datum.set_datetime(res_date_utc);
}
} else {
int64_t ori_date_utc = param1->get_datetime();
ObString wday_name = param2->get_string();
int64_t wday_count = 0; //not use
int64_t res_date_utc = 0;
if (OB_FAIL(ObTimeConverter::calc_next_date_of_the_wday(ori_date_utc,
wday_name.trim(), res_date_utc))) {
wday_name.trim(),
wday_count,
res_date_utc))) {
LOG_WARN("fail to calc next mday", K(ret));
} else {
expr_datum.set_datetime(res_date_utc);

View File

@ -50,9 +50,14 @@ int ObExprFormat::calc_result_typeN(ObExprResType &type,
{
UNUSED(type_ctx);
int ret = OB_SUCCESS;
if (OB_UNLIKELY(NULL == type_array || params_count != 2)) {
if (OB_UNLIKELY(NULL == type_array || (params_count != 2 && params_count != 3))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument.", K(ret), K(type_array), K(params_count));
} else if (params_count == 3) {
//to do, format function support a optional locale parameter
ret = OB_NOT_SUPPORTED;
LOG_WARN("format function not support an optional locale parameter", K(ret));
LOG_USER_ERROR(OB_NOT_SUPPORTED, "optional locale parameter of format");
} else if (OB_FAIL(calc_result_type(type, type_array))) {
LOG_WARN("failed to calc result type", K(ret));
} else {