From 46751d4b81c0e423759be07ee1f7f9d15627c42c Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 3 May 2024 10:27:35 +0300 Subject: [PATCH] MDEV-34060 Unexpected behavior upon reading I_S.ALL_PLUGINS under limited tmp space. --- mysql-test/main/tmp_space_usage.result | 14 ++++++++ mysql-test/main/tmp_space_usage.test | 16 +++++++++ sql/sql_select.cc | 5 ++- sql/sql_show.cc | 48 ++++++++++++++++++++++---- 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/tmp_space_usage.result b/mysql-test/main/tmp_space_usage.result index 6ca102a1a37..d0d00687c34 100644 --- a/mysql-test/main/tmp_space_usage.result +++ b/mysql-test/main/tmp_space_usage.result @@ -199,4 +199,18 @@ set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage; SET max_tmp_session_space_usage= 64*1024; SELECT MIN(VARIABLE_VALUE) OVER (), NTILE(1) OVER (), MAX(VARIABLE_NAME) OVER () FROM information_schema.SESSION_STATUS; ERROR HY000: Local temporary space limit reached +# +# MDEV-34060 Unexpected behavior upon reading I_S.ALL_PLUGINS under +# limited tmp space +# +connect c1, localhost, root,,; +set @@binlog_format=row; +CREATE OR REPLACE TABLE t1 (a DATETIME) ENGINE=MyISAM; +INSERT INTO t1 SELECT NOW() FROM seq_1_to_6000; +SET max_tmp_session_space_usage = 64*1024; +SELECT * FROM information_schema.ALL_PLUGINS LIMIT 2; +ERROR HY000: Local temporary space limit reached +drop table t1; +connection default; +disconnect c1; # End of 11.5 tests diff --git a/mysql-test/main/tmp_space_usage.test b/mysql-test/main/tmp_space_usage.test index 581e9d13c7d..1f4de53d8eb 100644 --- a/mysql-test/main/tmp_space_usage.test +++ b/mysql-test/main/tmp_space_usage.test @@ -259,4 +259,20 @@ SET max_tmp_session_space_usage= 64*1024; --error 200 SELECT MIN(VARIABLE_VALUE) OVER (), NTILE(1) OVER (), MAX(VARIABLE_NAME) OVER () FROM information_schema.SESSION_STATUS; +--echo # +--echo # MDEV-34060 Unexpected behavior upon reading I_S.ALL_PLUGINS under +--echo # limited tmp space +--echo # + +connect(c1, localhost, root,,); +set @@binlog_format=row; +CREATE OR REPLACE TABLE t1 (a DATETIME) ENGINE=MyISAM; +INSERT INTO t1 SELECT NOW() FROM seq_1_to_6000; +SET max_tmp_session_space_usage = 64*1024; +--error 200 +SELECT * FROM information_schema.ALL_PLUGINS LIMIT 2; +drop table t1; +connection default; +disconnect c1; + --echo # End of 11.5 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 07061eeac8c..c410ea2fe50 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4972,7 +4972,10 @@ int JOIN::exec_inner() if ((this->select_lex->options & OPTION_SCHEMA_TABLE) && get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC)) - DBUG_RETURN(0); + { + error= thd->is_error(); + DBUG_RETURN(error); + } if (select_options & SELECT_DESCRIBE) { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c7cc6217cb7..d10d4b0813b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -345,11 +345,32 @@ int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond) } +/* Ignore common errors from plugin load */ + +class plugin_show_error_handler : public Internal_error_handler +{ +public: + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl) + { + if (sql_errno == ER_CANT_FIND_DL_ENTRY) + return true; + return false; + } +}; + + int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond) { DBUG_ENTER("fill_all_plugins"); TABLE *table= tables->table; LOOKUP_FIELD_VALUES lookup; + plugin_show_error_handler err_handler; + const char *wstr, *wend; if (get_lookup_field_values(thd, cond, true, tables, &lookup)) DBUG_RETURN(0); @@ -364,10 +385,16 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_RETURN(1); } - if (!lookup.db_value.str) - plugin_dl_foreach(thd, 0, show_plugins, table); + thd->push_internal_handler(&err_handler); - const char *wstr= lookup.db_value.str, *wend= wstr + lookup.db_value.length; + if (!lookup.db_value.str) + { + if (plugin_dl_foreach(thd, 0, show_plugins, table) && thd->is_error()) + goto end; + } + + wstr= lookup.db_value.str; + wend= wstr + lookup.db_value.length; for (size_t i=0; i < dirp->number_of_files; i++) { FILEINFO *file= dirp->dir_entry+i; @@ -394,12 +421,14 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond) } } - plugin_dl_foreach(thd, &dl, show_plugins, table); - thd->clear_error(); + if (plugin_dl_foreach(thd, &dl, show_plugins, table) && thd->is_error()) + break; } +end: + thd->pop_internal_handler(); my_dirend(dirp); - DBUG_RETURN(0); + DBUG_RETURN(thd->is_error()); } @@ -4810,10 +4839,15 @@ fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root, && thd->get_stmt_da()->sql_errno() != ER_WRONG_OBJECT && thd->get_stmt_da()->sql_errno() != ER_NOT_SEQUENCE; if (!run) + { thd->clear_error(); + result= false; + } else if (!ext_error_handling) + { convert_error_to_warning(thd); - result= false; + result= false; + } } }