From deb20fb751f663f1f4b95656535e7368fe5cfa8e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 16 Nov 2024 18:17:08 +0100 Subject: [PATCH] MDEV-32919 Cannot select particular field from IS.tables in case table needs upgrade from MySQL 5.7 use the same condition in fill_schema_table_from_frm() when open_table_from_share() fails, as in fill_schema_table_from_frm() when tdc_aquire_share() fails and as in fill_schema_table_from_open() when open_table_from_share() fails --- mysql-test/main/mysql_json_table_recreate.result | 9 +++++++++ mysql-test/main/mysql_json_table_recreate.test | 3 +++ sql/sql_show.cc | 13 ++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/mysql_json_table_recreate.result b/mysql-test/main/mysql_json_table_recreate.result index a61377fe21d..c8c53c9036a 100644 --- a/mysql-test/main/mysql_json_table_recreate.result +++ b/mysql-test/main/mysql_json_table_recreate.result @@ -20,6 +20,15 @@ show create table tempty; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! select * from tempty; ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! +select table_name, table_comment from information_schema.tables where table_schema='test' and table_comment!='VIEW'; +table_name table_comment +mysql_json_test Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +mysql_json_test_big Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test_big` FORCE" or dump/reload to fix it! +tempty Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! +Warnings: +Warning 1707 Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test_big` FORCE" or dump/reload to fix it! +Warning 1707 Table rebuild required. Please do "ALTER TABLE `test.mysql_json_test` FORCE" or dump/reload to fix it! +Warning 1707 Table rebuild required. Please do "ALTER TABLE `test.tempty` FORCE" or dump/reload to fix it! alter table tempty force; show create table tempty; Table Create Table diff --git a/mysql-test/main/mysql_json_table_recreate.test b/mysql-test/main/mysql_json_table_recreate.test index a6f1d3194ae..94477d4f328 100644 --- a/mysql-test/main/mysql_json_table_recreate.test +++ b/mysql-test/main/mysql_json_table_recreate.test @@ -43,6 +43,9 @@ show create table tempty; --error ER_TABLE_NEEDS_REBUILD select * from tempty; +--sorted_result +select table_name, table_comment from information_schema.tables where table_schema='test' and table_comment!='VIEW'; + alter table tempty force; show create table tempty; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1653e7d5973..0a3a3209d26 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5078,10 +5078,17 @@ static int fill_schema_table_from_frm(THD *thd, MEM_ROOT *mem_root, goto end_share; } - if (!open_table_from_share(thd, share, table_name, 0, - (EXTRA_RECORD | OPEN_FRM_FILE_ONLY), - thd->open_options, &tbl, FALSE)) + res= open_table_from_share(thd, share, table_name, 0, + EXTRA_RECORD | OPEN_FRM_FILE_ONLY, + thd->open_options, &tbl, FALSE); + if (res && hide_object_error(thd->get_stmt_da()->sql_errno())) + res= 0; + else { + char buf[NAME_CHAR_LEN + 1]; + if (unlikely(res)) + get_table_engine_for_i_s(thd, buf, &table_list, db_name, table_name); + tbl.s= share; table_list.table= &tbl; table_list.view= (LEX*) share->is_view;