[CP] fix gather stats core caused by access invalid ptr
This commit is contained in:
		@ -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<PartInfo> &part_infos,
 | 
			
		||||
                                      ObIArray<PartInfo> &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<PartInfo, 4> dummy_subpart_infos;
 | 
			
		||||
      ObSEArray<int64_t, 4> part_ids;
 | 
			
		||||
      ObSEArray<int64_t, 4> 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<PartInfo, 4> 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<PartInfo> &partition_infos)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  ObSEArray<PartInfo, 4> part_infos;
 | 
			
		||||
  ObSEArray<PartInfo, 4> 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<PartInfo, 4> part_infos;
 | 
			
		||||
    ObSEArray<PartInfo, 4> 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;
 | 
			
		||||
 | 
			
		||||
@ -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<PartInfo> &part_infos,
 | 
			
		||||
                                  common::ObIArray<PartInfo> &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<ObAuxTableMetaInfo> &index_infos);
 | 
			
		||||
 | 
			
		||||
  static int get_table_partition_infos(const ObTableSchema &table_schema,
 | 
			
		||||
                                       ObIAllocator &allocator,
 | 
			
		||||
                                       ObIArray<PartInfo> &partition_infos);
 | 
			
		||||
 | 
			
		||||
  static int get_index_schema(sql::ObExecContext &ctx,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user