diff options
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r-- | sql/partition_info.cc | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 5c2237fb3d2..19f077136cb 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -829,12 +829,10 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) { DBUG_ASSERT(!vers_info->interval.is_set()); ha_partition *hp= (ha_partition*)(table->file); - partition_element *next= NULL; + partition_element *next; List_iterator<partition_element> it(partitions); - while (next != vers_info->hist_part) - next= it++; - DBUG_ASSERT(bitmap_is_set(&read_partitions, next->id)); - ha_rows records= hp->part_records(next); + ha_rows records= 0; + vers_info->hist_part= partitions.head(); while ((next= it++) != vers_info->now_part) { DBUG_ASSERT(bitmap_is_set(&read_partitions, next->id)); @@ -850,14 +848,11 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) { if (auto_hist) *create_count= 1; - else - my_error(WARN_VERS_PART_FULL, MYF(ME_WARNING|ME_ERROR_LOG), - table->s->db.str, table->s->table_name.str, - vers_info->hist_part->partition_name, "LIMIT"); } else vers_info->hist_part= next; } + return 0; } else if (vers_info->interval.is_set() && vers_info->hist_part->range_value <= thd->query_start()) @@ -927,7 +922,7 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) bool vers_create_partitions(THD *thd, TABLE_LIST* tl, uint num_parts) { bool result= true; - HA_CREATE_INFO create_info; + Table_specification_st create_info; Alter_info alter_info; partition_info *save_part_info= thd->work_part_info; Query_tables_list save_query_tables; @@ -1039,6 +1034,43 @@ exit: } +/** + Warn at the end of DML command if the last history partition is out of LIMIT. +*/ +void partition_info::vers_check_limit(THD *thd) +{ + if (vers_info->auto_hist || !vers_info->limit || + vers_info->hist_part->id + 1 < vers_info->now_part->id) + return; + + /* + NOTE: at this point read_partitions bitmap is already pruned by DML code, + we have to set read bits for working history partition. We could use + bitmap_set_all(), but this is not optimal since there can be quite a number + of partitions. + */ + const uint32 sub_factor= num_subparts ? num_subparts : 1; + uint32 part_id= vers_info->hist_part->id * sub_factor; + const uint32 part_id_end= part_id + sub_factor; + DBUG_ASSERT(part_id_end <= num_parts * sub_factor); + + ha_partition *hp= (ha_partition*)(table->file); + ha_rows hist_rows= hp->part_records(vers_info->hist_part); + if (hist_rows >= vers_info->limit) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + WARN_VERS_PART_FULL, + ER_THD(thd, WARN_VERS_PART_FULL), + table->s->db.str, table->s->table_name.str, + vers_info->hist_part->partition_name, "LIMIT"); + + sql_print_warning(ER_THD(thd, WARN_VERS_PART_FULL), + table->s->db.str, table->s->table_name.str, + vers_info->hist_part->partition_name, "LIMIT"); + } +} + + /* Check that the partition/subpartition is setup to use the correct storage engine |