diff --git a/src/sql/engine/expr/ob_expr_merge_result_type.map b/src/sql/engine/expr/ob_expr_merge_result_type.map index 01b2aca079..14d6079946 100644 --- a/src/sql/engine/expr/ob_expr_merge_result_type.map +++ b/src/sql/engine/expr/ob_expr_merge_result_type.map @@ -50,7 +50,7 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = { ObLobType, /*NullType=>ObLobType*/ ObJsonType, /*NullType=>ObJsonType*/ ObGeometryType, /*NullType=>ObGeometryType*/ - ObMaxType, /*NullType=>ObUserDefinedSQLType*/ + ObUserDefinedSQLType,/*NullType=>ObUserDefinedSQLType*/ }, /*TinyIntType*/ diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 1dc43a3da2..c07bc869be 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -2668,7 +2668,15 @@ int ObSPIService::spi_execute_immediate(ObPLExecCtx *ctx, if (params[i]->is_pl_extend()) { if (params[i]->get_meta().get_extend_type() != PL_REF_CURSOR_TYPE) { new_param.set_int_value(0); - OZ (pl::ObUserDefinedType::deep_copy_obj(allocator, *params[i], new_param, true)); + if (!ob_is_xml_pl_type(params[i]->get_type(), params[i]->get_udt_id())) { + OZ (pl::ObUserDefinedType::deep_copy_obj(allocator, *params[i], new_param, true)); + } else { + const ObDataTypeCastParams dtc_params = sql::ObBasicSessionInfo::create_dtc_params(ctx->exec_ctx_->get_my_session()); + ObCastCtx cast_ctx(ctx->allocator_, &dtc_params, CM_NONE, ObCharset::get_system_collation()); + if (OB_FAIL(ObObjCaster::to_type(ObUserDefinedSQLType, cast_ctx, *params[i], new_param))) { + LOG_WARN("failed to_type", K(ret), K(new_param)); + } + } } } else { OZ (deep_copy_obj(allocator, *params[i], new_param)); @@ -5157,6 +5165,14 @@ int ObSPIService::construct_exec_params(ObPLExecCtx *ctx, } else if (result.is_ext()) { if (result_type.is_ext()) { OX (result.set_udt_id(result_type.get_udt_id())); + // xml pl type add cast + if (ob_is_xml_pl_type(result_type.get_type(), result_type.get_udt_id())) { + const ObDataTypeCastParams dtc_params = sql::ObBasicSessionInfo::create_dtc_params(ctx->exec_ctx_->get_my_session()); + ObCastCtx cast_ctx(ctx->allocator_, &dtc_params, CM_NONE, ObCharset::get_system_collation()); + if (OB_FAIL(ObObjCaster::to_type(ObUserDefinedSQLType, cast_ctx, result, result))) { + LOG_WARN("failed to_type", K(ret), K(result)); + } + } if (OB_SUCC(ret) && result_type.get_extend_type() > 0 && result_type.get_extend_type() < T_EXT_SQL_ARRAY diff --git a/src/sql/optimizer/ob_join_order.cpp b/src/sql/optimizer/ob_join_order.cpp index 748eec4d4c..4e75fd080f 100644 --- a/src/sql/optimizer/ob_join_order.cpp +++ b/src/sql/optimizer/ob_join_order.cpp @@ -3684,7 +3684,8 @@ int ObJoinOrder::generate_const_predicates_from_view(const ObDMLStmt *stmt, if (OB_ISNULL(sel_expr = child_stmt->get_select_item(idx).expr_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected expr", K(ret), K(idx), K(sel_expr)); - } else if (!sel_expr->is_const_expr() || sel_expr->get_result_type().is_lob()) { + } else if (!sel_expr->is_const_expr() || sel_expr->get_result_type().is_lob() || + ob_is_xml_sql_type(sel_expr->get_result_type().get_type(), sel_expr->get_result_type().get_subschema_id())) { //do nothing } else if (OB_FAIL(ObTransformUtils::is_expr_not_null(not_null_ctx, sel_expr, diff --git a/src/sql/resolver/expr/ob_shared_expr_resolver.cpp b/src/sql/resolver/expr/ob_shared_expr_resolver.cpp index ec4fdb83d7..2bd66c2b05 100644 --- a/src/sql/resolver/expr/ob_shared_expr_resolver.cpp +++ b/src/sql/resolver/expr/ob_shared_expr_resolver.cpp @@ -24,6 +24,7 @@ bool ObQuestionmarkEqualCtx::compare_const(const ObConstRawExpr &left, (left.get_result_type().is_ext() && left.get_result_type().get_extend_type() > 0 && left.get_result_type().get_extend_type() < T_EXT_SQL_ARRAY) || + left.get_result_type().is_user_defined_sql_type() || OB_SUCCESS != err_code_) { // do nothing } else if (left.get_expr_type() != T_QUESTIONMARK) {