From 4681b6f2d8c82b4ec5cf115e83698251963d80d5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 14 Apr 2022 21:45:20 +0200 Subject: MDEV-26281 ASAN use-after-poison when complex conversion is involved in blob the bug was that in_vector array in Item_func_in was allocated in the statement arena, not in the table->expr_arena. revert part of the 5acd391e8b2d. Instead, change the arena correctly in fix_all_session_vcol_exprs(). Remove TABLE_ARENA, that was introduced in 5acd391e8b2d to force item tree changes to be rolled back (because they were allocated in the wrong arena and didn't persist. now they do) --- sql/sql_base.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a6c07600591..ce6fd4cbe64 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5010,16 +5010,13 @@ static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables) if (!table->placeholder() && t->s->vcols_need_refixing && table->lock_type >= TL_WRITE_ALLOW_WRITE) { - Query_arena *stmt_backup= thd->stmt_arena; - if (thd->stmt_arena->is_conventional()) - thd->stmt_arena= t->expr_arena; + Query_arena backup_arena; + thd->set_n_backup_active_arena(t->expr_arena, &backup_arena); if (table->security_ctx) thd->security_ctx= table->security_ctx; - error= t->fix_vcol_exprs(thd); - thd->security_ctx= save_security_ctx; - thd->stmt_arena= stmt_backup; + thd->restore_active_arena(t->expr_arena, &backup_arena); } } DBUG_RETURN(error); -- cgit v1.2.1 From ddc416c60698e1f8939faff0cb09c5b5af8e03a7 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 25 Apr 2022 13:58:41 +0300 Subject: 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). --- sql/sql_base.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f12ba831c7d..88eaf1bc0a5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -750,7 +750,12 @@ void close_thread_tables(THD *thd) DBUG_PRINT("tcache", ("table: '%s' query_id: %lu", table->s->table_name.str, (ulong) table->query_id)); if (thd->locked_tables_mode) + { + if (table->part_info && table->part_info->vers_require_hist_part(thd) && + !thd->stmt_arena->is_stmt_prepare()) + table->part_info->vers_check_limit(thd); table->vcol_cleanup_expr(thd); + } if (thd->locked_tables_mode <= LTM_LOCK_TABLES || table->query_id == thd->query_id) { -- cgit v1.2.1 From 182b8a29e7a1a0f0fbffeed39518c2c9dc026e13 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Fri, 29 Apr 2022 17:36:48 +0300 Subject: MDEV-20077 compilation fix --- sql/sql_base.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 88eaf1bc0a5..e825c247fc1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -751,9 +751,11 @@ void close_thread_tables(THD *thd) table->s->table_name.str, (ulong) table->query_id)); if (thd->locked_tables_mode) { +#ifdef WITH_PARTITION_STORAGE_ENGINE if (table->part_info && table->part_info->vers_require_hist_part(thd) && !thd->stmt_arena->is_stmt_prepare()) table->part_info->vers_check_limit(thd); +#endif table->vcol_cleanup_expr(thd); } if (thd->locked_tables_mode <= LTM_LOCK_TABLES || -- cgit v1.2.1