From 96b7671b056034b465c7ae7b66b315bd524d4b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 23 May 2025 14:51:38 +0300 Subject: [PATCH] MDEV-34388 fixup: Stack usage in rename_table_in_stat_tables() rename_table_in_stat_tables(): Allocate TABLE_LIST[STATISTICS_TABLES] from the heap instead of the stack, to pass -Wframe-larger-than=16384 in an optimized CMAKE_BUILD_TYPE=RelWithDebInfo build. --- sql/sql_statistics.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 306f9768dc2..8e12fe7362f 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -4023,16 +4023,24 @@ int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, int err; enum_binlog_format save_binlog_format; TABLE *stat_table; - TABLE_LIST tables[STATISTICS_TABLES]; int rc= 0; DBUG_ENTER("rename_table_in_stat_tables"); - + + TABLE_LIST *tables= + static_cast(my_malloc(PSI_NOT_INSTRUMENTED, + STATISTICS_TABLES * sizeof *tables, + MYF(MY_WME))); + if (!tables) + DBUG_RETURN(1); + start_new_trans new_trans(thd); if (open_stat_tables(thd, tables, TRUE)) { + func_exit: + my_free(tables); new_trans.restore_old_transaction(); - DBUG_RETURN(0); + DBUG_RETURN(rc); } save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); @@ -4093,9 +4101,7 @@ int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, thd->restore_stmt_binlog_format(save_binlog_format); if (thd->commit_whole_transaction_and_close_tables()) rc= 1; - - new_trans.restore_old_transaction(); - DBUG_RETURN(rc); + goto func_exit; }