summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-05-22 15:58:30 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-05-22 15:58:30 +0300
commit0174c9f1f80aa12883481bdada5d244f6d8ff7f6 (patch)
tree08d9d02d66f614e32a6d645cfda994fa73990360 /mysql-test
parent7b1fff4e35ae0c0c9d67f30a98a2fca8895cc6c9 (diff)
downloadmariadb-git-0174c9f1f80aa12883481bdada5d244f6d8ff7f6.tar.gz
Bug #28476: force index on a disabled myisam index gives error 124
When processing the USE/FORCE index hints the optimizer was not checking if the indexes specified are enabled (see ALTER TABLE). Fixed by: Backporting the fix for bug 20604 to 5.0 mysql-test/r/key.result: Test for BUG 20604. The important part of the test is the explain output that tests what indexes are used. mysql-test/r/myisam.result: Bug #28476: test cases mysql-test/t/key.test: Bug 20604: The minimal test case that reveals the bug. The optimizer for aggregates relies on keys disabled with ALTER TABLE ... DISABLE KEYS not being in the set TABLE::keys_in_use_for_query. When the execution engine tries to use a disabled index, MyISAM returns an error. mysql-test/t/myisam.test: Bug #28476: test cases sql/sql_base.cc: Bug #28476: - Ignore disabled indexes in USE/FORCE index sql/sql_select.cc: Bug 20604 : The intersection operation between table->s->keys_in_use and table->keys_in_use_for_query is no longer necessary. We can trust that the latter is a subset of the former. sql/table.h: Bug 20604: Added comments to TABLE_SHARE::keys_in_use and TABLE::keys_in_use_for_query.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/key.result8
-rw-r--r--mysql-test/r/myisam.result26
-rw-r--r--mysql-test/t/key.test12
-rw-r--r--mysql-test/t/myisam.test16
4 files changed, 62 insertions, 0 deletions
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index ec15eaa97f5..3abc95ec3bf 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -455,3 +455,11 @@ ORDER BY c.b, c.d
a b c d e f g h i j a b c d
2 2 1 2004-11-30 12:00:00 1 0 0 0 0 0 2 3388000 -553000 NULL
DROP TABLE t1, t2;
+CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES( 1 );
+ALTER TABLE t1 DISABLE KEYS;
+EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+DROP TABLE t1;
+End of 5.0 tests.
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 94f2f1f72b3..7fc29cd13ca 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -1780,4 +1780,30 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1
drop table t1, t2, t3;
+CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
+INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+ALTER TABLE t1 DISABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
+a
+1
+SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
+b
+1
+SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
+b
+1
+SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
+a
+1
+ALTER TABLE t1 ENABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+a
+1
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index e84b2071ab1..3d0e68dc0f3 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -432,3 +432,15 @@ ORDER BY c.b, c.d
;
DROP TABLE t1, t2;
+
+
+#
+# Bug #20604: Test for disabled keys with aggregate functions and FORCE INDEX.
+#
+CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM;
+INSERT INTO t1 VALUES( 1 );
+ALTER TABLE t1 DISABLE KEYS;
+EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 82d10059c65..12b9423be21 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1145,4 +1145,20 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
drop table t1, t2, t3;
+#
+# Bug#28476: force index on a disabled myisam index gives error 124
+#
+CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
+INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+SELECT a FROM t1 USE INDEX (inx) WHERE a=1;
+SELECT b FROM t1 FORCE INDEX (uinx) WHERE b=1;
+SELECT b FROM t1 USE INDEX (uinx) WHERE b=1;
+SELECT a FROM t1 FORCE INDEX (inx,uinx) WHERE a=1;
+ALTER TABLE t1 ENABLE KEYS;
+SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
+DROP TABLE t1;
+
--echo End of 5.0 tests