summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-09-11 22:36:04 -0700
committerIgor Babaev <igor@askmonty.org>2012-09-11 22:36:04 -0700
commit2bbcec41488ff4506cb848357086e8fb07a9648c (patch)
tree32adff3114bf43b9c1cb029bfdf9d35e309cd0e0 /mysql-test
parentff36e9fc518a4f8b463a09aeb9499c4552a27534 (diff)
downloadmariadb-git-2bbcec41488ff4506cb848357086e8fb07a9648c.tar.gz
Fixed bug mdev-518.
If some statistical tables are corrupted the server should use the conventional statistical data.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/stat_tables.result16
-rw-r--r--mysql-test/r/stat_tables_innodb.result16
-rw-r--r--mysql-test/t/stat_tables.test24
3 files changed, 56 insertions, 0 deletions
diff --git a/mysql-test/r/stat_tables.result b/mysql-test/r/stat_tables.result
index 3cc650e7050..169266fea25 100644
--- a/mysql-test/r/stat_tables.result
+++ b/mysql-test/r/stat_tables.result
@@ -364,4 +364,20 @@ ANALYZE TABLE t1;
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;
diff --git a/mysql-test/r/stat_tables_innodb.result b/mysql-test/r/stat_tables_innodb.result
index bb0497ee331..699df08225e 100644
--- a/mysql-test/r/stat_tables_innodb.result
+++ b/mysql-test/r/stat_tables_innodb.result
@@ -391,6 +391,22 @@ ANALYZE TABLE t1;
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;
diff --git a/mysql-test/t/stat_tables.test b/mysql-test/t/stat_tables.test
index 3ef5b4e9b92..e3712c8d022 100644
--- a/mysql-test/t/stat_tables.test
+++ b/mysql-test/t/stat_tables.test
@@ -180,4 +180,28 @@ ANALYZE TABLE t1;
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;
+