[BUGFIX]fix lob bugs

This commit is contained in:
skylhd
2023-05-10 13:57:06 +00:00
committed by ob-robot
parent c579d88403
commit cb396c38f2
3 changed files with 31 additions and 15 deletions

View File

@ -11230,7 +11230,9 @@ bool cast_supported(const ObObjType orig_type, const ObCollationType orig_cs_typ
} else if (is_oracle_mode() && (clob_in || ob_is_number_tc(orig_type) || ob_is_int_tc(orig_type)
|| ob_is_datetime_tc(orig_type)) && blob_out) {
bret = false;
} else if (is_oracle_mode() && ObTinyIntType == orig_type && ob_is_text_tc(expect_type)) {
} else if (is_oracle_mode() &&
(ObTinyIntType == orig_type || ObDateTimeType == orig_type) &&
ob_is_text_tc(expect_type)) {
bret = false;
} else {
ObObjTypeClass orig_tc = ob_obj_type_class(orig_type);

View File

@ -787,6 +787,9 @@ int eval_assign_question_mark_func(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &
if (ctx.exec_ctx_.get_physical_plan_ctx()->is_ignore_stmt()) {
cast_mode = cast_mode | CM_WARN_ON_FAIL | CM_CHARSET_CONVERT_IGNORE_ERR;
}
if ((v.is_blob() || dst_meta.is_blob()) && lib::is_oracle_mode()) {
cast_mode |= CM_ENABLE_BLOB_CAST;
}
ObCastCtx cast_ctx(&allocator, &dtc_params, cast_mode, dst_meta.get_collation_type());
if (OB_FAIL(ObObjCaster::to_type(dst_meta.get_type(), cast_ctx, v, dst_obj))) {
LOG_WARN("failed to cast obj to dst type", K(ret), K(v), K(dst_meta));

View File

@ -273,9 +273,12 @@ bool ObExprCast::check_cast_allowed(const ObObjType orig_type,
bool res = true;
ObObjTypeClass ori_tc = ob_obj_type_class(orig_type);
ObObjTypeClass expect_tc = ob_obj_type_class(expect_type);
if (is_oracle_mode() && is_explicit_cast) {
bool is_expect_lob_tc = (ObLobTC == expect_tc || ObTextTC == expect_tc);
bool is_ori_lob_tc = (ObLobTC == ori_tc || ObTextTC == ori_tc);
if (is_oracle_mode()) {
if (is_explicit_cast) {
// can't cast lob to other type except char/varchar/nchar/nvarchar2/raw. clob to raw not allowed too.
if (ObLobTC == ori_tc || ObTextTC == ori_tc) {
if (is_ori_lob_tc) {
if (expect_tc == ObJsonTC) {
/* oracle mode, json text use lob store */
} else if (ObStringTC == expect_tc) {
@ -287,9 +290,17 @@ bool ObExprCast::check_cast_allowed(const ObObjType orig_type,
}
}
// any type to lob type not allowed.
if (ObLobTC == expect_tc || ObTextTC == expect_tc) {
if (is_expect_lob_tc) {
res = false;
}
} else {
// BINARY FLOAT/DOUBLE not allow cast lob whether explicit
if (is_ori_lob_tc) {
if (expect_tc == ObFloatTC || expect_tc == ObDoubleTC) {
res = false;
}
}
}
}
return res;
}