diff --git a/src/pl/sys_package/ob_dbms_stats.cpp b/src/pl/sys_package/ob_dbms_stats.cpp index b84c36214c..a68d5ebca2 100644 --- a/src/pl/sys_package/ob_dbms_stats.cpp +++ b/src/pl/sys_package/ob_dbms_stats.cpp @@ -3217,6 +3217,7 @@ int ObDbmsStats::parse_table_part_info(ObExecContext &ctx, LOG_WARN("table schema is null", K(ret), K(table_schema), K(param.db_name_), K(param.tab_name_)); LOG_USER_ERROR(OB_TABLE_NOT_EXIST, to_cstring(param.db_name_), to_cstring(param.tab_name_)); } else if (OB_FAIL(get_table_part_infos(table_schema, + *param.allocator_, param.part_infos_, param.subpart_infos_))) { LOG_WARN("failed to get table part infos", K(ret)); @@ -3268,6 +3269,7 @@ int ObDbmsStats::parse_table_part_info(ObExecContext &ctx, } else if (OB_UNLIKELY(table_schema->is_view_table())) { ret = OB_TABLE_NOT_EXIST; } else if (OB_FAIL(get_table_part_infos(table_schema, + *param.allocator_, param.part_infos_, param.subpart_infos_))) { LOG_WARN("failed to get table part infos", K(ret)); @@ -3333,6 +3335,7 @@ int ObDbmsStats::parse_index_part_info(ObExecContext &ctx, param.data_table_name_))) { LOG_WARN("failed to write string", K(ret)); } else if (OB_FAIL(get_table_part_infos(index_schema, + *param.allocator_, param.part_infos_, param.subpart_infos_))) { LOG_WARN("failed to get table part infos", K(ret)); @@ -3652,6 +3655,7 @@ int ObDbmsStats::parse_set_partition_name(ObExecContext &ctx, ret = OB_ERR_NOT_PARTITIONED; LOG_WARN("the target table is not partitioned", K(ret)); } else if (OB_FAIL(get_table_part_infos(table_schema, + *param.allocator_, param.part_infos_, param.subpart_infos_))) { LOG_WARN("failed to get table part infos", K(ret)); @@ -4658,6 +4662,7 @@ int ObDbmsStats::check_is_valid_col(const ObString &src_str, } int ObDbmsStats::get_table_part_infos(const share::schema::ObTableSchema *table_schema, + ObIAllocator &allocator, ObIArray &part_infos, ObIArray &subpart_infos, OSGPartMap *part_map/*default NULL*/) @@ -4672,6 +4677,7 @@ int ObDbmsStats::get_table_part_infos(const share::schema::ObTableSchema *table_ /*do notthing*/ LOG_TRACE("table is not part table", K(table_schema->get_part_level())); } else if (OB_FAIL(ObDbmsStatsUtils::get_part_infos(*table_schema, + allocator, part_infos, subpart_infos, part_ids, @@ -4699,6 +4705,7 @@ int ObDbmsStats::get_part_ids_from_schema(const ObTableSchema *table_schema, ObSEArray dummy_subpart_infos; ObSEArray part_ids; ObSEArray subpart_ids; + ObArenaAllocator tmp_alloc("GetPartIds"); if (OB_ISNULL(table_schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret), K(table_schema)); @@ -4706,6 +4713,7 @@ int ObDbmsStats::get_part_ids_from_schema(const ObTableSchema *table_schema, /*do notthing*/ LOG_TRACE("table is not part table", K(table_schema->get_part_level())); } else if (OB_FAIL(ObDbmsStatsUtils::get_part_infos(*table_schema, + tmp_alloc, dummy_part_infos, dummy_subpart_infos, part_ids, @@ -5607,13 +5615,14 @@ int ObDbmsStats::get_user_partition_table_stale_percent( int64_t inc_modified_count = 0; int64_t row_cnt = 0; ObSEArray partition_infos; + ObArenaAllocator tmp_alloc("GetPartStale", OB_MALLOC_NORMAL_BLOCK_SIZE, tenant_id); if (OB_UNLIKELY(!table_schema.is_user_table() || -1 != global_part_id)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected error", K(ret), K(table_schema.is_user_table()), K(global_part_id)); } else if (stat_table.partition_stat_infos_.empty()) { // do not have any statistics stat_table.stale_percent_ = -1.0; - } else if (OB_FAIL(get_table_partition_infos(table_schema, partition_infos))) { + } else if (OB_FAIL(get_table_partition_infos(table_schema, tmp_alloc, partition_infos))) { LOG_WARN("failed to get table subpart infos", K(ret)); } else if (OB_FAIL(ObBasicStatsEstimator::estimate_stale_partition(ctx, tenant_id, @@ -6031,12 +6040,14 @@ int ObDbmsStats::set_param_global_part_id(ObExecContext &ctx, } int ObDbmsStats::get_table_partition_infos(const ObTableSchema &table_schema, + ObIAllocator &allocator, ObIArray &partition_infos) { int ret = OB_SUCCESS; ObSEArray part_infos; ObSEArray subpart_infos; if (OB_FAIL(get_table_part_infos(&table_schema, + allocator, part_infos, subpart_infos))) { LOG_WARN("failed to get table part infos", K(ret)); @@ -6050,25 +6061,6 @@ int ObDbmsStats::get_table_partition_infos(const ObTableSchema &table_schema, return ret; } -int ObDbmsStats::get_table_partition_map(const ObTableSchema &table_schema, - OSGPartMap &part_map) -{ - int ret = OB_SUCCESS; - if (PARTITION_LEVEL_TWO != table_schema.get_part_level() - && PARTITION_LEVEL_ONE != table_schema.get_part_level()) { - } else { - ObSEArray part_infos; - ObSEArray subpart_infos; - if (OB_FAIL(get_table_part_infos(&table_schema, - part_infos, - subpart_infos, - &part_map))) { - LOG_WARN("failed to get table part infos", K(ret)); - } - } - return ret; -} - bool ObDbmsStats::is_func_index(const ObTableStatParam &index_param) { bool is_true = false; diff --git a/src/pl/sys_package/ob_dbms_stats.h b/src/pl/sys_package/ob_dbms_stats.h index 40af60e124..b756a02dcf 100644 --- a/src/pl/sys_package/ob_dbms_stats.h +++ b/src/pl/sys_package/ob_dbms_stats.h @@ -383,6 +383,7 @@ public: const MethodOptSizeConf &size_conf); static int get_table_part_infos(const share::schema::ObTableSchema *table_schema, + ObIAllocator &allocator, common::ObIArray &part_infos, common::ObIArray &subpart_infos, OSGPartMap *part_map = NULL); @@ -491,9 +492,6 @@ public: share::schema::ObPartitionLevel data_table_level = share::schema::ObPartitionLevel::PARTITION_LEVEL_ZERO); - static int get_table_partition_map(const ObTableSchema &table_schema, - OSGPartMap &part_map); - static int init_gather_task_info(ObExecContext &ctx, ObOptStatGatherType type, int64_t start_time, @@ -586,6 +584,7 @@ private: ObIArray &index_infos); static int get_table_partition_infos(const ObTableSchema &table_schema, + ObIAllocator &allocator, ObIArray &partition_infos); static int get_index_schema(sql::ObExecContext &ctx, diff --git a/src/share/stat/ob_dbms_stats_utils.cpp b/src/share/stat/ob_dbms_stats_utils.cpp index e71d8b642c..233ee384c0 100644 --- a/src/share/stat/ob_dbms_stats_utils.cpp +++ b/src/share/stat/ob_dbms_stats_utils.cpp @@ -690,6 +690,7 @@ bool ObDbmsStatsUtils::is_part_id_valid(const ObTableStatParam ¶m, } int ObDbmsStatsUtils::get_part_infos(const ObTableSchema &table_schema, + ObIAllocator &allocator, ObIArray &part_infos, ObIArray &subpart_infos, ObIArray &part_ids, @@ -708,10 +709,11 @@ int ObDbmsStatsUtils::get_part_infos(const ObTableSchema &table_schema, LOG_WARN("get null partition", K(ret), K(part)); } else { PartInfo part_info; - part_info.part_name_ = part->get_part_name(); part_info.part_id_ = part->get_part_id(); part_info.tablet_id_ = part->get_tablet_id(); - if (OB_NOT_NULL(part_map)) { + if (OB_FAIL(ob_write_string(allocator, part->get_part_name(), part_info.part_name_))) { + LOG_WARN("failed to write string", K(ret)); + } else if (OB_NOT_NULL(part_map)) { OSGPartInfo part_info; part_info.part_id_ = part->get_part_id(); part_info.tablet_id_ = part->get_tablet_id(); @@ -726,7 +728,7 @@ int ObDbmsStatsUtils::get_part_infos(const ObTableSchema &table_schema, } else if (OB_FAIL(part_ids.push_back(part_info.part_id_))) { LOG_WARN("failed to push back part id", K(ret)); } else if (is_twopart && - OB_FAIL(get_subpart_infos(table_schema, part, subpart_infos, subpart_ids, part_map))) { + OB_FAIL(get_subpart_infos(table_schema, part, allocator, subpart_infos, subpart_ids, part_map))) { LOG_WARN("failed to get subpart info", K(ret)); } else { part_infos.at(part_infos.count() - 1).subpart_cnt_ = subpart_infos.count() - origin_cnt; @@ -741,6 +743,7 @@ int ObDbmsStatsUtils::get_part_infos(const ObTableSchema &table_schema, int ObDbmsStatsUtils::get_subpart_infos(const ObTableSchema &table_schema, const ObPartition *part, + ObIAllocator &allocator, ObIArray &subpart_infos, ObIArray &subpart_ids, OSGPartMap *part_map/*default NULL*/) @@ -764,7 +767,9 @@ int ObDbmsStatsUtils::get_subpart_infos(const ObTableSchema &table_schema, subpart_info.part_id_ = subpart->get_sub_part_id(); // means object_id subpart_info.tablet_id_ = subpart->get_tablet_id(); subpart_info.first_part_id_ = part->get_part_id(); - if (OB_NOT_NULL(part_map)) { + if (OB_FAIL(ob_write_string(allocator, subpart->get_part_name(), subpart_info.part_name_))) { + LOG_WARN("failed to write string", K(ret)); + } else if (OB_NOT_NULL(part_map)) { OSGPartInfo part_info; part_info.part_id_ = part->get_part_id(); part_info.tablet_id_ = subpart->get_tablet_id(); diff --git a/src/share/stat/ob_dbms_stats_utils.h b/src/share/stat/ob_dbms_stats_utils.h index 0a33b4b351..37c8873995 100644 --- a/src/share/stat/ob_dbms_stats_utils.h +++ b/src/share/stat/ob_dbms_stats_utils.h @@ -115,6 +115,7 @@ public: static bool is_part_id_valid(const ObTableStatParam ¶m, const ObObjectID part_id); static int get_part_infos(const ObTableSchema &table_schema, + ObIAllocator &allocator, ObIArray &part_infos, ObIArray &subpart_infos, ObIArray &part_ids, @@ -123,6 +124,7 @@ public: static int get_subpart_infos(const share::schema::ObTableSchema &table_schema, const share::schema::ObPartition *part, + ObIAllocator &allocator, ObIArray &subpart_infos, ObIArray &subpart_ids, OSGPartMap *part_map = NULL); diff --git a/src/share/stat/ob_incremental_stat_estimator.cpp b/src/share/stat/ob_incremental_stat_estimator.cpp index dd451b9f04..69c296d027 100644 --- a/src/share/stat/ob_incremental_stat_estimator.cpp +++ b/src/share/stat/ob_incremental_stat_estimator.cpp @@ -947,6 +947,7 @@ int ObIncrementalStatEstimator::gen_opt_stat_param_by_direct_load(ObExecContext ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected error", K(ret)); } else if (OB_FAIL(ObDbmsStatsUtils::get_part_infos(*table_schema, + alloc, param.part_infos_, param.subpart_infos_, part_ids, diff --git a/src/sql/engine/px/exchange/ob_px_receive_op.cpp b/src/sql/engine/px/exchange/ob_px_receive_op.cpp index 7555e0a5b4..52ba9448a1 100644 --- a/src/sql/engine/px/exchange/ob_px_receive_op.cpp +++ b/src/sql/engine/px/exchange/ob_px_receive_op.cpp @@ -824,6 +824,7 @@ int ObPxFifoReceiveOp::fetch_rows(const int64_t row_cnt) } } else { LOG_WARN("fail get row from channels", K(ret)); + break; } } while (OB_EAGAIN == ret); } diff --git a/src/sql/optimizer/ob_dynamic_sampling.cpp b/src/sql/optimizer/ob_dynamic_sampling.cpp index ba83c7dca7..2071a475aa 100644 --- a/src/sql/optimizer/ob_dynamic_sampling.cpp +++ b/src/sql/optimizer/ob_dynamic_sampling.cpp @@ -1426,6 +1426,7 @@ int ObDynamicSamplingUtils::get_ds_table_part_info(ObOptimizerContext &ctx, (is_virtual_table(ref_table_id) && !share::is_oracle_mapping_real_virtual_table(ref_table_id))) { /*do nothing*/ } else if (OB_FAIL(ObDbmsStatsUtils::get_part_infos(*table_schema, + ctx.get_allocator(), tmp_part_infos, tmp_subpart_infos, tmp_part_ids, diff --git a/src/sql/resolver/ddl/ob_analyze_stmt_resolver.cpp b/src/sql/resolver/ddl/ob_analyze_stmt_resolver.cpp index 36b5193f11..20bfea94d5 100644 --- a/src/sql/resolver/ddl/ob_analyze_stmt_resolver.cpp +++ b/src/sql/resolver/ddl/ob_analyze_stmt_resolver.cpp @@ -322,15 +322,16 @@ int ObAnalyzeStmtResolver::inner_resolve_partition_info(const ParseNode *part_no bool is_subpart_name = false; ObString &partition_name = table_info.get_partition_name(); - if (OB_ISNULL(schema_checker_)) { + if (OB_ISNULL(schema_checker_) || OB_ISNULL(params_.allocator_)) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("null schema checker", K(schema_checker_), K(ret)); + LOG_WARN("null schema checker", K(schema_checker_), K(params_.allocator_), K(ret)); } else if (OB_FAIL(schema_checker_->get_table_schema(tenant_id, table_id, table_schema))) { LOG_WARN("failed to get table schema", K(tenant_id), K(table_id), K(ret)); } else if (OB_ISNULL(table_schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("null table schema", K(ret)); } else if (OB_FAIL(ObDbmsStatsUtils::get_part_infos(*table_schema, + *params_.allocator_, part_infos, subpart_infos, part_ids,