[Commits] Rev 3372: Fixed bug mdev-518. in file:///home/igor/maria/maria-5.5-mwl248-bugs/

Igor Babaev igor at askmonty.org
Wed Sep 12 08:36:05 EEST 2012


At file:///home/igor/maria/maria-5.5-mwl248-bugs/

------------------------------------------------------------
revno: 3372
revision-id: igor at askmonty.org-20120912053604-e48joj9k8bs5ub9i
parent: igor at askmonty.org-20120911052257-dwvlkqef3qvyc70o
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.5-mwl248-bugs
timestamp: Tue 2012-09-11 22:36:04 -0700
message:
  Fixed bug mdev-518.
  If some statistical tables are corrupted the server should use
  the conventional statistical data.
-------------- next part --------------
=== modified file 'mysql-test/r/stat_tables.result'
--- a/mysql-test/r/stat_tables.result	2012-08-27 21:19:25 +0000
+++ b/mysql-test/r/stat_tables.result	2012-09-12 05:36:04 +0000
@@ -364,4 +364,20 @@
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	OK
 DROP TABLE t1;
+#
+# Bug mdev-518: corrupted/missing statistical tables
+# 
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+FLUSH TABLE t1;
+SET use_stat_tables='never';
+EXPLAIN SELECT * FROM t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+FLUSH TABLES;
+SET use_stat_tables='preferably';
+EXPLAIN SELECT * FROM t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+DROP TABLE t1;
 set use_stat_tables=@save_use_stat_tables;

=== modified file 'mysql-test/r/stat_tables_innodb.result'
--- a/mysql-test/r/stat_tables_innodb.result	2012-08-27 21:19:25 +0000
+++ b/mysql-test/r/stat_tables_innodb.result	2012-09-12 05:36:04 +0000
@@ -391,6 +391,22 @@
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	OK
 DROP TABLE t1;
+#
+# Bug mdev-518: corrupted/missing statistical tables
+# 
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+FLUSH TABLE t1;
+SET use_stat_tables='never';
+EXPLAIN SELECT * FROM t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+FLUSH TABLES;
+SET use_stat_tables='preferably';
+EXPLAIN SELECT * FROM t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
+DROP TABLE t1;
 set use_stat_tables=@save_use_stat_tables;
 set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
 SET SESSION STORAGE_ENGINE=DEFAULT;

=== modified file 'mysql-test/t/stat_tables.test'
--- a/mysql-test/t/stat_tables.test	2012-08-27 21:19:25 +0000
+++ b/mysql-test/t/stat_tables.test	2012-09-12 05:36:04 +0000
@@ -180,4 +180,28 @@
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug mdev-518: corrupted/missing statistical tables
+--echo # 
+
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+
+FLUSH TABLE t1;
+SET use_stat_tables='never';
+EXPLAIN SELECT * FROM t1;
+
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD.save
+
+FLUSH TABLES;
+SET use_stat_tables='preferably';
+--disable_warnings
+EXPLAIN SELECT * FROM t1;
+--enable_warnings
+
+# Cleanup
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD.save $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD
+DROP TABLE t1;
+
 set use_stat_tables=@save_use_stat_tables;
+

=== modified file 'sql/sql_statistics.cc'
--- a/sql/sql_statistics.cc	2012-09-11 05:22:57 +0000
+++ b/sql/sql_statistics.cc	2012-09-12 05:36:04 +0000
@@ -2908,15 +2908,17 @@
 {
   uint use_stat_table_mode= thd->variables.use_stat_tables;
   table->used_stat_records= 
-    (use_stat_table_mode <= 1 || !table->s->read_stats ||
-      table->s->read_stats->cardinality_is_null) ?
+    (use_stat_table_mode <= 1 ||
+     !table->s->stats_is_read || !table->s->read_stats ||
+     table->s->read_stats->cardinality_is_null) ?
     table->file->stats.records : table->s->read_stats->cardinality;
   KEY *key_info, *key_info_end;
   for (key_info= table->key_info, key_info_end= key_info+table->s->keys;
        key_info < key_info_end; key_info++)
   {
     key_info->is_statistics_from_stat_tables=
-      (use_stat_table_mode > 1  && key_info->read_stats &&
+      (use_stat_table_mode > 1  && table->s->stats_is_read &&
+       key_info->read_stats &&
        key_info->read_stats->avg_frequency_is_inited() &&
        key_info->read_stats->get_avg_frequency(0) > 0.5);
   }



More information about the commits mailing list