summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-04-22 17:10:42 -0700
committerIgor Babaev <igor@askmonty.org>2019-04-22 17:11:07 -0700
commit279a907fd0dea30be6d11fc4a5d63b1b98d0b329 (patch)
tree23cf9722a9aaf85b2dee4fbb9419c93cc7d3f89e /sql/sql_show.cc
parenta4f7d859322ab771289abf13f50752266af43187 (diff)
downloadmariadb-git-279a907fd0dea30be6d11fc4a5d63b1b98d0b329.tar.gz
MDEV-17605 Statistics for InnoDB table is wrong if persistent statistics is used
The command SHOW INDEXES ignored setting of the system variable use_stat_tables to the value of 'preferably' and and showed statistical data received from the engine. Similarly queries over the table STATISTICS from INFORMATION_SCHEMA ignored this setting. It happened because the function fill_schema_table_by_open() did not read any data from statistical tables.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 73f0f564c4c..46914ea14c4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4273,6 +4273,7 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
'only_view_structure()'.
*/
lex->sql_command= SQLCOM_SHOW_FIELDS;
+ thd->force_read_stats= get_schema_table_idx(schema_table) == SCH_STATISTICS;
result= (open_temporary_tables(thd, table_list) ||
open_normal_and_derived_tables(thd, table_list,
(MYSQL_OPEN_IGNORE_FLUSH |
@@ -4280,6 +4281,10 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
(can_deadlock ?
MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)),
DT_PREPARE | DT_CREATE));
+
+ (void) read_statistics_for_tables_if_needed(thd, table_list);
+ thd->force_read_stats= false;
+
/*
Restore old value of sql_command back as it is being looked at in
process_table() function.