[xml bugfix] adapt insert all for xml type and extract bugfix
This commit is contained in:
		| @ -525,18 +525,12 @@ struct DatumUDTHashCalculator : public DefHashMethod<T> | ||||
| { | ||||
|   static int calc_datum_hash(const ObDatum &datum, const uint64_t seed, uint64_t &res) | ||||
|   { | ||||
|     UNUSED(datum); | ||||
|     UNUSED(seed); | ||||
|     UNUSED(res); | ||||
|     return OB_NOT_SUPPORTED; | ||||
|     return datum_lob_locator_hash(datum, CS_TYPE_UTF8MB4_BIN, seed, T::is_varchar_hash ? T::hash : NULL, res); | ||||
|   } | ||||
|  | ||||
|   static int calc_datum_hash_v2(const ObDatum &datum, const uint64_t seed, uint64_t &res) | ||||
|   { | ||||
|     UNUSED(datum); | ||||
|     UNUSED(seed); | ||||
|     UNUSED(res); | ||||
|     return OB_NOT_SUPPORTED; | ||||
|     return datum_lob_locator_hash(datum, CS_TYPE_UTF8MB4_BIN, seed, T::is_varchar_hash ? T::hash : NULL, res); | ||||
|   } | ||||
| }; | ||||
|  | ||||
|  | ||||
| @ -599,6 +599,7 @@ int ObMultiTableInsertResolver::mock_values_column_ref(const ObColumnRefRawExpr | ||||
|       value_desc->set_dependant_expr(const_cast<ObRawExpr *>(column_ref->get_dependant_expr())); | ||||
|       value_desc->set_ref_id(table_info.table_id_, column_ref->get_column_id()); | ||||
|       value_desc->set_column_attr(ObString::make_string(OB_VALUES), column_ref->get_column_name()); | ||||
|       value_desc->set_udt_set_id(column_ref->get_udt_set_id()); | ||||
|       if (ob_is_enumset_tc(column_ref->get_result_type().get_type ()) | ||||
|           && OB_FAIL(value_desc->set_enum_set_values(column_ref->get_enum_set_values()))) { | ||||
|         LOG_WARN("failed to set_enum_set_values", K(*column_ref), K(ret)); | ||||
|  | ||||
| @ -1966,6 +1966,8 @@ int ObRawExprDeduceType::check_group_aggr_param(ObAggFunRawExpr &expr) | ||||
|                         && T_FUN_GROUP_CONCAT != expr.get_expr_type() | ||||
|                         && T_FUN_GROUP_PERCENT_RANK != expr.get_expr_type() | ||||
|                         && T_FUN_GROUP_RANK != expr.get_expr_type())) | ||||
|                 && !(ob_is_user_defined_sql_type(param_expr->get_data_type()) | ||||
|                       && (T_FUN_APPROX_COUNT_DISTINCT == expr.get_expr_type() || T_FUN_APPROX_COUNT_DISTINCT_SYNOPSIS == expr.get_expr_type())) | ||||
|                 && !(T_FUN_COUNT == expr.get_expr_type() && ob_is_json(param_expr->get_data_type())) | ||||
|                 && !(T_FUN_COUNT == expr.get_expr_type() && (ob_is_user_defined_sql_type(param_expr->get_data_type()) || | ||||
|                                                              ob_is_user_defined_pl_type(param_expr->get_data_type()))) | ||||
| @ -3024,10 +3026,16 @@ int ObRawExprDeduceType::set_xmlagg_result_type(ObAggFunRawExpr &expr, | ||||
|           ret = OB_ERR_NO_ORDER_MAP_SQL; | ||||
|           LOG_WARN("cannot ORDER objects without MAP or ORDER method", K(ret)); | ||||
|         } | ||||
|       } else if (order_expr->get_result_type().get_type() == ObUserDefinedSQLType | ||||
|                   || order_expr->get_result_type().get_type() == ObExtendType) { | ||||
|         ret = OB_ERR_NO_ORDER_MAP_SQL; | ||||
|         LOG_WARN("cannot ORDER objects without MAP or ORDER method", K(ret)); | ||||
|       } else { | ||||
|         ObObjType result_type = order_expr->get_result_type().get_type(); | ||||
|         if (result_type == ObUserDefinedSQLType || result_type == ObExtendType) { | ||||
|           ret = OB_ERR_NO_ORDER_MAP_SQL; | ||||
|           LOG_WARN("cannot ORDER objects without MAP or ORDER method", K(ret)); | ||||
|         } else if (ob_is_text_tc(result_type) || | ||||
|                     ob_is_lob_tc(result_type)) { | ||||
|           ret = OB_ERR_INVALID_TYPE_FOR_OP; | ||||
|           LOG_WARN("Column of LOB type cannot be used for sorting", K(ret)); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -6932,23 +6932,36 @@ int ObTransformPreProcess::transform_udt_columns(const ObIArray<ObParentDMLStmt> | ||||
|  | ||||
|         LOG_TRACE("succeed to do const propagation for assignment expr", K(is_happened)); | ||||
|       } | ||||
|     } else if (stmt->get_stmt_type() == stmt::T_INSERT) { | ||||
|         ObInsertStmt *insert_stmt = static_cast<ObInsertStmt*>(stmt); | ||||
|         common::ObIArray<ObRawExpr*> &value_vector = insert_stmt->get_values_vector(); | ||||
|         int64_t column_count = insert_stmt->get_values_desc().count(); | ||||
|         int64_t row_count = insert_stmt->get_values_vector().count() / column_count; | ||||
|     } else if (stmt->get_stmt_type() == stmt::T_INSERT || stmt->get_stmt_type() == stmt::T_INSERT_ALL) { | ||||
|       ObDelUpdStmt *insert_stmt = static_cast<ObDelUpdStmt*>(stmt); | ||||
|       // common::ObIArray<ObRawExpr*> &value_vector = insert_stmt->get_values_vector(); | ||||
|       // int64_t column_count = insert_stmt->get_values_desc().count(); | ||||
|       // int64_t row_count = insert_stmt->get_values_vector().count() / column_count; | ||||
|       ObInsertAllStmt *insert_all_stmt = static_cast<ObInsertAllStmt*>(stmt); | ||||
|       ObInsertStmt *single_insert_stmt = static_cast<ObInsertStmt*>(stmt); | ||||
|       common::ObArray<ObInsertTableInfo*> table_info_arr; | ||||
|       if (stmt->get_stmt_type() == stmt::T_INSERT) { | ||||
|         table_info_arr.push_back(&(single_insert_stmt->get_insert_table_info())); | ||||
|       } else { | ||||
|         ObIArray<ObInsertAllTableInfo*> &table_infos = insert_all_stmt->get_insert_all_table_info(); | ||||
|         for (int64_t i = 0; i < table_infos.count(); i++) { | ||||
|           table_info_arr.push_back(table_infos.at(i)); | ||||
|         } | ||||
|       } | ||||
|  | ||||
|         for (int64_t i = 0; OB_SUCC(ret) && i < insert_stmt->get_insert_table_info().column_exprs_.count(); ++i) { | ||||
|           ObColumnRefRawExpr *col = insert_stmt->get_insert_table_info().column_exprs_.at(i); | ||||
|       for (int64_t count = 0; OB_SUCC(ret) && count < table_info_arr.count(); ++count) { | ||||
|         ObInsertTableInfo *table_info = table_info_arr.at(count); | ||||
|         for (int64_t i = 0; OB_SUCC(ret) && i < table_info->column_exprs_.count(); ++i) { | ||||
|           ObColumnRefRawExpr *col = table_info->column_exprs_.at(i); | ||||
|           if (col->is_xml_column()) { | ||||
|             if (OB_FAIL(set_hidd_col_not_null_attr(*col, insert_stmt->get_insert_table_info().column_exprs_))) { | ||||
|             if (OB_FAIL(set_hidd_col_not_null_attr(*col, table_info->column_exprs_))) { | ||||
|               LOG_WARN("failed to set hidden column not null attr", K(ret)); | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|  | ||||
|         for (int64_t i = 0; OB_SUCC(ret) && i < insert_stmt->get_values_desc().count(); ++i) { | ||||
|           ObColumnRefRawExpr *value_desc = insert_stmt->get_values_desc().at(i); | ||||
|         for (int64_t i = 0; OB_SUCC(ret) && i < table_info->values_desc_.count(); ++i) { | ||||
|           ObColumnRefRawExpr *value_desc = table_info->values_desc_.at(i); | ||||
|           if (value_desc->is_xml_column()) { | ||||
|             ObColumnRefRawExpr *hidd_col = NULL; | ||||
|             bool need_transform = false; | ||||
| @ -6960,8 +6973,8 @@ int ObTransformPreProcess::transform_udt_columns(const ObIArray<ObParentDMLStmt> | ||||
|               LOG_WARN("failed to create udt hidden exprs", K(ret)); | ||||
|             } else if (need_transform == false) { | ||||
|               // do nothing | ||||
|             } else if (OB_FAIL(transform_udt_column_conv_function(insert_stmt->get_insert_table_info(), | ||||
|                                                                   insert_stmt->get_column_conv_exprs(), | ||||
|             } else if (OB_FAIL(transform_udt_column_conv_function(*table_info, | ||||
|                                                                   table_info->column_conv_exprs_, | ||||
|                                                                   *value_desc, *hidd_col))) { | ||||
|               LOG_WARN("failed to push back column conv exprs", K(ret)); | ||||
|             } | ||||
| @ -6969,8 +6982,8 @@ int ObTransformPreProcess::transform_udt_columns(const ObIArray<ObParentDMLStmt> | ||||
|         } | ||||
|         // process returning exprs | ||||
|         if (OB_SUCC(ret) && insert_stmt->is_returning()) { | ||||
|           ObIArray<ObRawExpr*> &column_convert = insert_stmt->get_column_conv_exprs(); | ||||
|           const ObIArray<ObColumnRefRawExpr *> &table_columns = insert_stmt->get_insert_table_info().column_exprs_; | ||||
|           ObIArray<ObRawExpr*> &column_convert = table_info->column_conv_exprs_; | ||||
|           const ObIArray<ObColumnRefRawExpr *> &table_columns = table_info->column_exprs_; | ||||
|           ObSEArray<std::pair<int64_t, int64_t>, 8> xml_col_idxs; // use pair to store xml col idx and its hidden col idx | ||||
|           for (int64_t i = 0; OB_SUCC(ret) && i < table_columns.count(); i++) { | ||||
|             ObColumnRefRawExpr *ref_col = table_columns.at(i); | ||||
| @ -7009,6 +7022,7 @@ int ObTransformPreProcess::transform_udt_columns(const ObIArray<ObParentDMLStmt> | ||||
|           } | ||||
|         } // end if | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev