diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index 85fc1c5a96..f1d9f7464d 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -2873,7 +2873,11 @@ do { \ ObObj tmp; // CHARSET_ANY代表接受任何字符集,因此不能改变入参的字符集 if (CS_TYPE_ANY == result_type.get_collation_type()) { - result_type.set_collation_type(params->at(i).get_meta().get_collation_type()); + if (params->at(i).get_meta().is_string_or_lob_locator_type()) { + result_type.set_collation_type(params->at(i).get_meta().get_collation_type()); + } else { + result_type.set_collation_type(ctx_.exec_ctx_->get_my_session()->get_nls_collation()); + } } if ((result_type.is_blob() || result_type.is_blob_locator() || params->at(i).is_blob() || params->at(i).is_blob_locator()) diff --git a/src/sql/engine/expr/ob_datum_cast.cpp b/src/sql/engine/expr/ob_datum_cast.cpp index 0046555466..bbce1c6934 100644 --- a/src/sql/engine/expr/ob_datum_cast.cpp +++ b/src/sql/engine/expr/ob_datum_cast.cpp @@ -3324,7 +3324,12 @@ CAST_FUNC_NAME(text, raw) bool has_set_res = false; OZ(ObDatumHexUtils::hextoraw_string(expr, in_str, ctx, res_datum, has_set_res)); } else { // blob to raw - res_datum.set_string(in_str.ptr(), in_str.length()); + // empty blob treat as null in oracle + if (lib::is_oracle_mode() && in_str.length() == 0) { + res_datum.set_null(); + } else { + res_datum.set_string(in_str.ptr(), in_str.length()); + } } } return ret; diff --git a/src/sql/resolver/ddl/ob_ddl_resolver.cpp b/src/sql/resolver/ddl/ob_ddl_resolver.cpp index e04d2b3895..5cc06b8845 100644 --- a/src/sql/resolver/ddl/ob_ddl_resolver.cpp +++ b/src/sql/resolver/ddl/ob_ddl_resolver.cpp @@ -5359,6 +5359,9 @@ int ObDDLResolver::check_default_value(ObObj &default_value, } else if (column.is_xmltype() && ob_is_numeric_type(tmp_default_value.get_type())) { ret = OB_ERR_INVALID_XML_DATATYPE; LOG_WARN("incorrect cmp type with xml arguments",K(tmp_default_value.get_type()), K(ret)); + } else if (lib::is_oracle_mode() && column.get_meta_type().is_blob() && ob_is_numeric_type(tmp_default_value.get_type())) { + ret = OB_ERR_INVALID_TYPE_FOR_OP; + LOG_WARN("inconsistent datatypes", "expected", data_type, "got", tmp_default_value.get_type(), K(ret)); } else if(OB_FAIL(ObObjCaster::to_type(data_type, cast_ctx, tmp_default_value, tmp_dest_obj, tmp_res_obj))) { LOG_WARN("cast obj failed, ", "src type", tmp_default_value.get_type(), "dest type", data_type, K(tmp_default_value), K(ret)); } else if (OB_ISNULL(tmp_res_obj)) {