diff --git a/src/sql/engine/expr/ob_expr_cast.cpp b/src/sql/engine/expr/ob_expr_cast.cpp index 2120d4588..cc53d46fb 100644 --- a/src/sql/engine/expr/ob_expr_cast.cpp +++ b/src/sql/engine/expr/ob_expr_cast.cpp @@ -634,6 +634,10 @@ int ObExprCast::adjust_udt_cast_type(const ObExprResType &src_type, ObExprResTyp LOG_WARN("cast unsupported sql udt type to pl udt type", K(ret), K(src_type), K(dst_type)); } } + } else if (src_type.is_null()) { + if (dst_type.get_type() == ObUserDefinedSQLType) { + dst_type.set_sql_udt(ObXMLSqlType); + } } return ret; } diff --git a/src/sql/engine/expr/ob_expr_result_type_util.cpp b/src/sql/engine/expr/ob_expr_result_type_util.cpp index 5dc044840..9ca811f8c 100644 --- a/src/sql/engine/expr/ob_expr_result_type_util.cpp +++ b/src/sql/engine/expr/ob_expr_result_type_util.cpp @@ -760,6 +760,14 @@ int ObExprResultTypeUtil::deduce_max_string_length_oracle(const ObDataTypeCastPa length /= ObCharset::get_charset(target_type.get_collation_type())->mbminlen; } } + } else if (orig_type.is_user_defined_sql_type() || orig_type.is_ext()) { + // udt types like xml can cast to string, the accuracy in pl extend is used for udt id + if (LS_CHAR == length_semantics) { + int64_t mbminlen = ObCharset::get_charset(target_type.get_collation_type())->mbminlen; + length = OB_MAX_VARCHAR_LENGTH_KEY / mbminlen; + } else { + length = OB_MAX_VARCHAR_LENGTH_KEY; // issue 49536718: CREATE INDEX index ON table (UPPER(c1)); + } } else { int64_t ascii_bytes = 0; if (orig_type.is_null()) {