diff --git a/src/sql/resolver/expr/ob_raw_expr_wrap_enum_set.cpp b/src/sql/resolver/expr/ob_raw_expr_wrap_enum_set.cpp index f34c33d40f82a98d65d02aa305e95be90619689f..af9270fc3382030adb44d79b9561cddf9d3233ad 100644 --- a/src/sql/resolver/expr/ob_raw_expr_wrap_enum_set.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_wrap_enum_set.cpp @@ -865,6 +865,8 @@ int ObRawExprWrapEnumSet::visit_query_ref_expr( } else if (NULL != new_expr) { // replace with new wrapped expr ref_stmt->get_select_item(0).expr_ = new_expr; + expr.get_column_types().at(0) = new_expr->get_result_type(); + LOG_TRACE("succeed to wrap enum to str", K(dest_type), K(*new_expr), K(expr)); } else { /*do nothing*/ } } diff --git a/src/sql/rewrite/ob_transformer_impl.cpp b/src/sql/rewrite/ob_transformer_impl.cpp index ff7cdb77122b63785c91d800116ac660b6463c2c..1d043707475b5241a1087a99f524e0956bfdadaa 100644 --- a/src/sql/rewrite/ob_transformer_impl.cpp +++ b/src/sql/rewrite/ob_transformer_impl.cpp @@ -313,7 +313,7 @@ int ObTransformerImpl::choose_rewrite_rules(ObDMLStmt* stmt, uint64_t& need_type LOG_WARN("failed to check stmt functions", K(ret)); } else { // TODO::unpivot open - if (func.contain_unpivot_query_) { + if (func.contain_unpivot_query_ || func.contain_enum_set_values_) { disable_list = ObTransformRule::ALL_TRANSFORM_RULES; } if (func.contain_sequence_) { @@ -345,6 +345,14 @@ int ObTransformerImpl::check_stmt_functions(ObDMLStmt* stmt, StmtFunc& func) func.contain_for_update_ = func.contain_for_update_ || has_for_update; func.contain_unpivot_query_ = func.contain_unpivot_query_ || stmt->is_unpivot_select(); } + for (int64_t i = 0; OB_SUCC(ret) && !func.contain_enum_set_values_ && i < stmt->get_column_items().count(); ++i) { + const ColumnItem &col = stmt->get_column_items().at(i); + if (OB_ISNULL(col.get_expr())) { + ret = OB_ERR_UNEXPECTED; + } else if (ob_is_enumset_tc(col.get_expr()->get_data_type())) { + func.contain_enum_set_values_ = true; + } + } if (OB_SUCC(ret) && (stmt->is_delete_stmt() || stmt->is_update_stmt() || stmt->is_merge_stmt() || stmt->is_insert_stmt())) { ObDelUpdStmt* del_upd_stmt = static_cast(stmt); diff --git a/src/sql/rewrite/ob_transformer_impl.h b/src/sql/rewrite/ob_transformer_impl.h index 99a34e38204d2cbdeee28432ca4e8f8a89694f83..b5ff292c7430d254bdac6427cc632d6182503b2b 100644 --- a/src/sql/rewrite/ob_transformer_impl.h +++ b/src/sql/rewrite/ob_transformer_impl.h @@ -110,13 +110,14 @@ public: contain_for_update_(false), contain_domain_index_(false), update_global_index_(false), - contain_unpivot_query_(false) + contain_unpivot_query_(false), + contain_enum_set_values_(false) {} bool all_found() const { return contain_hie_query_ && contain_sequence_ && contain_for_update_ && contain_domain_index_ && - update_global_index_ && contain_unpivot_query_; + update_global_index_ && contain_unpivot_query_ && contain_enum_set_values_; } bool contain_hie_query_; @@ -125,6 +126,7 @@ public: bool contain_domain_index_; bool update_global_index_; bool contain_unpivot_query_; + bool contain_enum_set_values_; }; int check_stmt_functions(ObDMLStmt* stmt, StmtFunc& func); inline ObTransformerCtx* get_trans_ctx()