summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2022-04-25 13:58:41 +0300
committerAleksey Midenkov <midenok@gmail.com>2022-04-29 13:31:42 +0300
commitddc416c60698e1f8939faff0cb09c5b5af8e03a7 (patch)
treeff1fc268b37abe33a4bc0955ec9ec02b763584e5 /sql/ha_partition.cc
parentea2f09979fc74a8fa7fb1e74c874e00df757c6db (diff)
downloadmariadb-git-ddc416c60698e1f8939faff0cb09c5b5af8e03a7.tar.gz
MDEV-20077 Warning on full history partition is delayed until next DML statement
Moved LIMIT warning from vers_set_hist_part() to new call vers_check_limit() at table unlock phase. At that point read_partitions bitmap is already pruned by DML code (see prune_partitions(), find_used_partitions()) so we have to set corresponding bits for working history partition. Also we don't do my_error(ME_WARNING|ME_ERROR_LOG), because at that point it doesn't update warnings number, so command reports 0 warnings (but warning list is still updated). Instead we do push_warning_printf() and sql_print_warning() separately. Under LOCK TABLES external_lock(F_UNLCK) is not executed. There is start_stmt(), but no corresponding "stop_stmt()". So for that mode we call vers_check_limit() directly from close_thread_tables(). Test result has been changed according to new LIMIT and warning printing algorithm. For convenience all LIMIT warnings are marked with "You see warning above ^". TODO MDEV-20345 fixed. Now vers_history_generating() contains fine-grained list of DML-commands that can generate history (and TODO mechanism worked well).
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc17
1 files changed, 4 insertions, 13 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index b1645a9c4a7..48c479070a5 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -4008,6 +4008,8 @@ int ha_partition::external_lock(THD *thd, int lock_type)
if (lock_type == F_UNLCK)
{
bitmap_clear_all(used_partitions);
+ if (m_lock_type == F_WRLCK && m_part_info->vers_require_hist_part(thd))
+ m_part_info->vers_check_limit(thd);
}
else
{
@@ -4028,14 +4030,7 @@ int ha_partition::external_lock(THD *thd, int lock_type)
{
if (m_part_info->part_expr)
m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0);
- if (m_part_info->part_type == VERSIONING_PARTITION &&
- /* TODO: MDEV-20345 exclude more inapproriate commands like INSERT
- These commands may be excluded because working history partition is needed
- only for versioned DML. */
- thd->lex->sql_command != SQLCOM_SELECT &&
- thd->lex->sql_command != SQLCOM_INSERT_SELECT &&
- thd->lex->sql_command != SQLCOM_ALTER_TABLE &&
- (error= m_part_info->vers_set_hist_part(thd)))
+ if ((error= m_part_info->vers_set_hist_part(thd)))
goto err_handler;
}
DBUG_RETURN(0);
@@ -4188,11 +4183,7 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type)
case TL_WRITE_ONLY:
if (m_part_info->part_expr)
m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0);
- if (m_part_info->part_type == VERSIONING_PARTITION &&
- // TODO: MDEV-20345 (see above)
- thd->lex->sql_command != SQLCOM_SELECT &&
- thd->lex->sql_command != SQLCOM_INSERT_SELECT)
- error= m_part_info->vers_set_hist_part(thd);
+ error= m_part_info->vers_set_hist_part(thd);
default:;
}
DBUG_RETURN(error);