summaryrefslogtreecommitdiff
path: root/sql/partition_info.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-05-10 11:53:59 +0200
committerSergei Golubchik <serg@mariadb.org>2022-05-10 14:01:23 +0200
commit3bc98a4ec4e7e7493ee93048dddfad87ceb3d8ff (patch)
treead189995a78fdc6068059e65b8455d3d4e61e719 /sql/partition_info.cc
parentf4d671bff2c4dcfe1bb2af6d40122576e4fcfa91 (diff)
parentfe3d07cab82b2215dc64f52ac93122072c33d021 (diff)
downloadmariadb-git-3bc98a4ec4e7e7493ee93048dddfad87ceb3d8ff.tar.gz
Merge branch '10.5' into 10.6
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r--sql/partition_info.cc63
1 files changed, 47 insertions, 16 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 74b9b64217f..d96c6a82617 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -822,6 +822,9 @@ bool partition_info::has_unique_name(partition_element *element)
*/
int partition_info::vers_set_hist_part(THD *thd)
{
+ if (!vers_require_hist_part(thd))
+ return 0;
+
if (table->pos_in_table_list &&
table->pos_in_table_list->partition_names)
{
@@ -830,12 +833,10 @@ int partition_info::vers_set_hist_part(THD *thd)
if (vers_info->limit)
{
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));
@@ -845,17 +846,8 @@ int partition_info::vers_set_hist_part(THD *thd)
vers_info->hist_part= next;
records= next_records;
}
- if (records >= vers_info->limit)
- {
- if (next == vers_info->now_part)
- {
- 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;
- }
+ if (records >= vers_info->limit && next != vers_info->now_part)
+ vers_info->hist_part= next;
return 0;
}
@@ -880,6 +872,45 @@ int partition_info::vers_set_hist_part(THD *thd)
}
+/**
+ 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->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);
+ for (; part_id < part_id_end; ++part_id)
+ bitmap_set_bit(&read_partitions, part_id);
+
+ 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