Commit 808237b0 authored by unknown's avatar unknown
Browse files

This changeset belongs to

      WL#3397 Refactoring storage engine test cases (for falcon)
    It contains also fixes according to code review.
    Contents: Testcases which were in history dedicated to InnoDB or MyISAM only.
    Modifications:
    1. Shift the main testing code into include/<testing field>.inc
       Introduce $variables which can be used to omit tests for features which are not supported by
       certain storage engines.
    2. The storage engine to be tested is assigned within the toplevel script (t/<whatever>_<engine>.test)
       via variable $engine_type and the the main testing code is sourced from 
       include/<testing field>.inc
    3. Some toplevel testscripts have to be renamed to
       - avoid immediate or future namespace clashes
       - show via filename which storage engine is tested
    4. Minor code cleanup like remove trailing spaces, some additional comments ....


mysql-test/t/unsafe_binlog_innodb-master.opt:
  Rename: mysql-test/t/innodb_unsafe_binlog-master.opt -> mysql-test/t/unsafe_binlog_innodb-master.opt
mysql-test/r/read_many_rows_innodb.result:
  Rename: mysql-test/r/innodb-big.result -> mysql-test/r/read_many_rows_innodb.result
mysql-test/t/cache_innodb-master.opt:
  Rename: mysql-test/t/innodb_cache-master.opt -> mysql-test/t/cache_innodb-master.opt
mysql-test/t/concurrent_innodb-master.opt:
  Rename: mysql-test/t/innodb_concurrent-master.opt -> mysql-test/t/concurrent_innodb-master.opt
BitKeeper/deleted/.del-index_merge.result:
  Delete: mysql-test/r/index_merge.result
BitKeeper/deleted/.del-index_merge_innodb.result:
  Delete: mysql-test/r/index_merge_innodb.result
BitKeeper/deleted/.del-index_merge_innodb2.result:
  Delete: mysql-test/r/index_merge_innodb2.result
BitKeeper/deleted/.del-index_merge_ror.result:
  Delete: mysql-test/r/index_merge_ror.result
BitKeeper/deleted/.del-index_merge_ror_cpk.result:
  Delete: mysql-test/r/index_merge_ror_cpk.result
mysql-test/r/index_merge_innodb.result:
  BitKeeper file /home/matthias/Arbeit/mysql-5.1-engines/src-1/mysql-test/r/index_merge_innodb.result
mysql-test/t/index_merge_innodb.test:
  BitKeeper file /home/matthias/Arbeit/mysql-5.1-engines/src-1/mysql-test/t/index_merge_innodb.test
mysql-test/t/index_merge_myisam.test:
  BitKeeper file /home/matthias/Arbeit/mysql-5.1-engines/src-1/mysql-test/t/index_merge_myisam.test
mysql-test/include/concurrent.inc:
  1. This file contains now the main testing code of the former t/innodb_concurrent.test.
  2. It is now sourced by t/concurrent_innodb.test.
mysql-test/include/deadlock.inc:
  1. This file contains now the main testing code of the former t/innodb-deadlock.test
  2. It is now sourced by t/deadlock_innodb.test.
mysql-test/include/handler.inc:
  1. This file contains now the main testing code of the former t/innodb_handler.test + t/handler.test.
  2. It is now sourced by t/handler_myisam.test and t/handler_innodb.test.
mysql-test/include/index_merge1.inc:
  1. This file contains now the main testing code of the former t/index_merge.test.
  2. It is now sourced by t/index_merge_myisam.test.
mysql-test/include/index_merge2.inc:
  1. This file contains now the main code of t/index_merge_innodb.test.
  2. It is sourced by t/index_merge_myisam.test and t/index_merge_innodb.test.
mysql-test/include/index_merge_2sweeps.inc:
  1. This file contains now the main code of the former t/index_merge_innodb2.test.
  2. It is sourced by t/index_merge_myisam.test and t/index_merge_innodb.test.
mysql-test/include/index_merge_ror.inc:
  1. This file contains now the main code of the former t/index_merge_ror.test.
  2. It is sourced by t/index_merge_myisam.test.
mysql-test/include/index_merge_ror_cpk.inc:
  1. This file contains now the main testing code of the former t/index_merge_ror_cpk.test.
  2. It is now sourced by t/index_merge_myisam.test and t/index_merge_innodb.test.
mysql-test/include/mix1.inc:
  1. This file contains now the main testing code of the t/innodb_mysql.test
  2. The name mix1.inc was used because the test contains subtests for different fields.
  3. It is sourced by t/innodb_mysql.test.
  4. Fixes:
      - Assign $other_engine_type instead of hardcoded MyISAM.
      - improve comment
      - remove redundant subtest
      - analyze table t4 instead of wrong table t1
      - remove not needed "eval set storage_engine = $engine_type;"
mysql-test/include/mix2.inc:
  1. This file is a copy of the main testing code of the t/innodb.test
     A copy has to be used, because t/innodb.test is to be maintained by INNOBASE only.
  2. The name mix2.inc was used because the test contains subtests for different fields.
  3. It is sourced by t/mix2_myisam.test.
  4. Fixes:
      - improved comment
      - additional "eval SET SESSION STORAGE_ENGINE = $other_engine_type;" at beginning of tests
      - assign $other_engine_type instead of hardcoded MyISAM or HEAP
      - assign $other_engine_type where it is needed to preserve test logics
      - correct logical bugs
      - improve(extend) "checksum table" test
mysql-test/include/query_cache.inc:
  1. This file contains now the main testing code of the former t/innodb_cache.test.
  2. It is now sourced by t/cache_innodb.test
mysql-test/include/read_many_rows.inc:
  1. This file contains now the main testing code of the former t/innodb_big.test.
  2. It is now sourced by t/read_many_rows_innodb.test.
mysql-test/include/rowid_order.inc:
  1. This file contains now the main testing code of t/rowid_order_innodb.test.
  2. It is now sourced by t/rowid_order_innodb.test.
mysql-test/include/unsafe_binlog.inc:
  1. This file contains now the main testing code of the former t/innodb_unsafe_binlog.test.
  2. It is now sourced by t/unsafe_binlog_innodb.test.
mysql-test/r/cache_innodb.result:
  Updated result
mysql-test/r/concurrent_innodb.result:
  Updated result
mysql-test/r/deadlock_innodb.result:
  Updated result
mysql-test/r/handler_innodb.result:
  Updated result
mysql-test/r/handler_myisam.result:
  Updated result
mysql-test/r/index_merge_myisam.result:
  Updated result
mysql-test/r/innodb_mysql.result:
  Updated result
mysql-test/r/mix2_myisam.result:
  Updated result
mysql-test/r/rowid_order_innodb.result:
  Updated result
mysql-test/r/unsafe_binlog_innodb.result:
  Updated result
mysql-test/t/cache_innodb.test:
  1. Renaming of t/innodb_cache.test to t/cache_innodb.test
  2. Main code is now sourced from include/query_cache.inc.
mysql-test/t/concurrent_innodb.test:
  1. Renaming of t/innodb_concurrent.test to t/concurrent_innodb.test
  2. Main code is now sourced from include/concurrent.inc.
     Attention: This test fails even in the old version. (BUG#21579).
                --> added to t/disabled.def
mysql-test/t/deadlock_innodb.test:
  1. Renaming of t/innodb_deadlock.test to t/deadlock_innodb.test
  2. Main code is now sourced from include/deadlock.inc.
mysql-test/t/disabled.def:
  Add the test concurrent_innodb because of 
  BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
mysql-test/t/handler_innodb.test:
  1. Renaming of t/innodb_handler.test to t/handler_innodb.test
  2. Main code is now sourced from include/handler.inc.
     include/handler.inc = united code of former t/handler.test and t/innodb_handler.test
mysql-test/t/handler_myisam.test:
  1. Renaming of t/handler.test to t/handler_myisam.test
  2. Main code is now sourced from include/handler.inc.
     include/handler.inc = united code of former t/handler.test and t/handler_innodb.test.
mysql-test/t/innodb_mysql.test:
  1. Main code is now sourced from include/mix1.inc.
  2. Test was not renamed because t/innodb.test refers to it.
mysql-test/t/mix2_myisam.test:
  New test: MyISAM variant of mix2 ( = t/innodb.test)
mysql-test/t/read_many_rows_innodb.test:
  1. Renaming of t/innodb_big.test to t/read_many_rows_innodb.test
  2. Main code is now sourced from include/read_many_rows.inc.
mysql-test/t/rowid_order_innodb.test:
  Main code is now sourced from t/rowid_order.inc.
mysql-test/t/unsafe_binlog_innodb.test:
  1. Renaming of t/innodb_unsafe_binlog.test to t/unsafe_binlog_innodb.test
  2. Main code is now sourced from include/unsafe_binlog.inc.
parent 829d70d0
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
# include/concurrent.inc
#
# Concurrent InnoDB tests, mainly in UPDATE's
# Concurrent tests for transactional storage engines, mainly in UPDATE's
# Bug#3300
# Designed and tested by Sinisa Milivojevic, sinisa@mysql.com
#
# two non-interfering UPDATE's not changing result set
#

# test takes circa 5 minutes to run, so it's big
-- source include/big_test.inc
# The variable
#     $engine_type       -- storage engine to be tested
# has to be set before sourcing this script.
#
# Last update:
# 2006-08-02 ML test refactored
#               old name was t/innodb_concurrent.test
#               main code went into include/concurrent.inc
#

connection default;
eval SET SESSION STORAGE_ENGINE = $engine_type;
--disable_warnings
drop table if exists t1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
--enable_warnings
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
connect (thread1, localhost, mysqltest,,);
connection thread1;
eval SET SESSION STORAGE_ENGINE = $engine_type;
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -57,7 +68,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -103,7 +114,7 @@ drop table t1;

#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1 (a int not null, b int not null) engine=innodb;
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(2,1),(3,1),(4,1);
select get_lock("hello2",1000);
#connect (thread2, localhost, mysqltest,,);
@@ -132,7 +143,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -175,7 +186,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -218,7 +229,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -261,7 +272,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -305,7 +316,7 @@ drop table t1;
#
#connect (thread1, localhost, mysqltest,,);
connection thread1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+147 −0
Original line number Diff line number Diff line
-- source include/have_innodb.inc
# Can't test this with embedded server
-- source include/not_embedded.inc
# include/deadlock.inc
#
# The variable
#     $engine_type       -- storage engine to be tested
# has to be set before sourcing this script.
#
# Last update:
# 2006-07-26 ML refactoring + print when connection is switched
#               old name was t/innodb-deadlock.test
#               main code went into include/deadlock.inc
#

--echo # Establish connection con1 (user=root)
connect (con1,localhost,root,,);
--echo # Establish connection con2 (user=root)
connect (con2,localhost,root,,);

--disable_warnings
@@ -13,29 +23,34 @@ drop table if exists t1,t2;
# Testing of FOR UPDATE
#

--echo # Switch to connection con1
connection con1;
create table t1 (id integer, x integer) engine=INNODB;
eval create table t1 (id integer, x integer) engine = $engine_type;
insert into t1 values(0, 0);
set autocommit=0;
SELECT * from t1 where id = 0 FOR UPDATE;

--echo # Switch to connection con2
connection con2;
set autocommit=0;

# The following query should hang because con1 is locking the page
# The following query should hang because con1 is locking the record
--send
update t1 set x=2 where id = 0;
--sleep 2

--echo # Switch to connection con1
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;

--echo # Switch to connection con2
connection con2;
reap;
commit;

--echo # Switch to connection con1
connection con1;
select * from t1;
commit;
@@ -45,9 +60,10 @@ drop table t1;
# Testing of FOR UPDATE
#

--echo # Switch to connection con1
connection con1;
create table t1 (id integer, x integer) engine=INNODB;
create table t2 (b integer, a integer) engine=INNODB;
eval create table t1 (id integer, x integer) engine = $engine_type;
eval create table t2 (b integer, a integer) engine = $engine_type;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 10), (1, 20), (2, 30);
commit;
@@ -57,61 +73,75 @@ update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
select * from t2;
select * from t1;

--echo # Switch to connection con2
connection con2;
set autocommit=0;

# The following query should hang because con1 is locking the page
# The following query should hang because con1 is locking the record
--send
update t1 set x=2 where id = 0;
--sleep 2

--echo # Switch to connection con1
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;

--echo # Switch to connection con2
connection con2;
reap;
commit;

--echo # Switch to connection con1
connection con1;
select * from t1;
commit;

drop table t1, t2;
create table t1 (id integer, x integer) engine=INNODB;
create table t2 (b integer, a integer) engine=INNODB;
eval create table t1 (id integer, x integer) engine = $engine_type;
eval create table t2 (b integer, a integer) engine = $engine_type;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 0), (1, 20), (2, 30);
commit;

--echo # Switch to connection con1
connection con1;
select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
select * from t2;
select * from t1;

--echo # Switch to connection con2
connection con2;

# The following query should hang because con1 is locking the page
# The following query should hang because con1 is locking the record
update t2 set a=2 where b = 0;
select * from t2;
--send
update t1 set x=2 where id = 0;
--sleep 2

--echo # Switch to connection con1
connection con1;
update t1 set x=1 where id = 0;
select * from t1;
commit;

--echo # Switch to connection con2
connection con2;
reap;
commit;

--echo # Switch to connection con1
connection con1;
select * from t1;
commit;

# Cleanup
--echo # Switch to connection default + disconnect con1 and con2
connection default;
disconnect con1;
disconnect con2;
drop table t1, t2;

# End of 4.1 tests
+34 −2
Original line number Diff line number Diff line
# include/handler.inc
#
# The variable
#     $engine_type       -- storage engine to be tested
# has to be set before sourcing this script.
#
# test of HANDLER ...
#
# Last update:
# 2006-07-31 ML test refactored (MySQL 5.1)
#               code of t/handler.test and t/innodb_handler.test united
#               main testing code put into include/handler.inc
#

# should work in embedded server after mysqltest is fixed
-- source include/not_embedded.inc
eval SET SESSION STORAGE_ENGINE = $engine_type;

--disable_warnings
drop table if exists t1,t3,t4,t5;
@@ -73,6 +82,22 @@ handler t2 read next;
handler t2 read last;
handler t2 close;

handler t1 open;
handler t1 read a next; # this used to crash as a bug#5373
handler t1 read a next;
handler t1 close;

handler t1 open;
handler t1 read a prev; # this used to crash as a bug#5373
handler t1 read a prev;
handler t1 close;

handler t1 open as t2;
handler t2 read first;
eval alter table t1 engine = $engine_type;
--error 1109
handler t2 read first;

#
# DROP TABLE / ALTER TABLE
#
@@ -378,6 +403,13 @@ reap;
connection default;
drop table t1;

CREATE TABLE t1 (  no1 smallint(5) NOT NULL default '0',  no2 int(10) NOT NULL default '0',  PRIMARY KEY  (no1,no2));
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
HANDLER t1 OPEN;
HANDLER t1 READ `primary` = (1, 1000);
HANDLER t1 READ `primary` PREV;
DROP TABLE t1;

# End of 4.1 tests

#
+78 −54
Original line number Diff line number Diff line
# include/index_merge1.inc
#
# Index merge tests
#
# The variables
#     $engine_type         -- storage engine to be tested
#     $merge_table_support -- 1 storage engine supports merge tables
#                          -- 0 storage engine does not support merge tables
# have to be set before sourcing this script.
#
# Note: The comments/expectations refer to MyISAM.
#       They might be not valid for other storage engines.
#
# Last update:
# 2006-08-02 ML test refactored
#               old name was t/index_merge.test
#               main code went into include/index_merge1.inc
#

--echo #---------------- Index merge test 1 -------------------------------------------

eval SET SESSION STORAGE_ENGINE = $engine_type;

--disable_warnings
drop table if exists t0, t1, t2, t3, t4;
--enable_warnings
@@ -48,6 +68,7 @@ explain select * from t0 where key1 < 3 or key2 <4;

explain
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);

# 3. Check that index_merge doesn't break "ignore/force/use index"
@@ -186,10 +207,8 @@ create table t4 (
  key2_1 int not null,
  key2_2 int not null,
  key3  int not null,
  
  index i1a (key1a, key1b),
  index i1b (key1b, key1a),
  
  index i2_1(key2, key2_1),
  index i2_2(key2, key2_1)
);
@@ -268,9 +287,11 @@ select * from t3 where

# Test for Bug#3183
explain select * from t0 where key1 < 3 or key2 < 4;
# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
select * from t0 where key1 < 3 or key2 < 4;

update t0 set key8=123 where key1 < 3 or key2 < 4;
# Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
select * from t0 where key1 < 3 or key2 < 4;

delete from t0 where key1 < 3 or key2 < 4;
@@ -357,6 +378,8 @@ explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
drop table t1;

if ($merge_table_support)
{
#
# BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables
#
@@ -383,3 +406,4 @@ explain select * from t3 where a=1 and b=1;

drop table t3;
drop table t0, t1, t2;
}
+318 −0
Original line number Diff line number Diff line
# include/index_merge2.inc
#
# Index merge tests
#
# The variable
#     $engine_type       -- storage engine to be tested
# has to be set before sourcing this script.
#
# Note: The comments/expectations refer to InnoDB.
#       They might be not valid for other storage engines.
#
# Last update:
# 2006-08-02 ML test refactored
#               old name was t/index_merge_innodb.test
#               main code went into include/index_merge2.inc
#

--echo #---------------- Index merge test 2 -------------------------------------------

eval SET SESSION STORAGE_ENGINE = $engine_type;

--disable_warnings
drop table if exists t1,t2;
--enable_warnings

create table t1
(
  key1 int not null,
  key2 int not null,

  INDEX i1(key1),
  INDEX i2(key2)
);

--disable_query_log
let $1=200;
while ($1)
{
  eval insert into t1 values (200-$1, $1);
  dec $1;
}
--enable_query_log

# No primary key
explain select * from t1 where key1 < 5 or key2 > 197;

select * from t1 where key1 < 5 or key2 > 197;

explain select * from t1 where key1 < 3 or key2 > 195;
select * from t1 where key1 < 3 or key2 > 195;

# Primary key as case-sensitive string with \0s.
# also make primary key be longer then max. index length of MyISAM.
alter table t1 add str1 char (255) not null,
                add zeroval int not null default 0,
                add str2 char (255) not null,
                add str3 char (255) not null;

update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));

alter table t1 add primary key (str1, zeroval, str2, str3);

explain select * from t1 where key1 < 5 or key2 > 197;

select * from t1 where key1 < 5 or key2 > 197;

explain select * from t1 where key1 < 3 or key2 > 195;
select * from t1 where key1 < 3 or key2 > 195;

# Test for BUG#5401
drop table t1;
create table t1 (
  pk    integer not null auto_increment primary key,
  key1  integer,
  key2  integer not null,
  filler char  (200),
  index (key1),
  index (key2)
);
show warnings;
--disable_query_log
let $1=30;
while ($1)
{
  eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
  dec $1;
}
--enable_query_log
explain select pk from t1 where key1 = 1 and key2 = 1;
select pk from t1 where key2 = 1 and key1 = 1;
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;

# More tests for BUG#5401.
drop table t1;
create table t1 (
  pk int primary key auto_increment,
  key1a  int,
  key2a  int,
  key1b  int,
  key2b  int,
  dummy1 int,
  dummy2 int,
  dummy3 int,
  dummy4 int,
  key3a  int,
  key3b  int,
  filler1 char (200),
  index i1(key1a, key1b),
  index i2(key2a, key2b),
  index i3(key3a, key3b)
);

create table t2 (a int);
insert into t2 values (0),(1),(2),(3),(4),(NULL);

insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
  select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D;
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
  select key1a, key1b, key2a, key2b, key3a, key3b from t1;
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
  select key1a, key1b, key2a, key2b, key3a, key3b from t1;
analyze table t1;
select count(*) from t1;

explain select count(*) from t1 where
  key1a = 2 and key1b is null and  key2a = 2 and key2b is null;

select count(*) from t1 where
  key1a = 2 and key1b is null and key2a = 2 and key2b is null;

explain select count(*) from t1 where
  key1a = 2 and key1b is null and key3a = 2 and key3b is null;

select count(*) from t1 where
  key1a = 2 and key1b is null and key3a = 2 and key3b is null;

drop table t1,t2;

# Test for BUG#8441
create table t1 (
  id1 int,
  id2 date ,
  index idx2 (id1,id2),
  index idx1 (id2)
);
insert into t1 values(1,'20040101'), (2,'20040102');
select * from t1  where id1 = 1  and id2= '20040101';
drop table t1;

# Test for BUG#12720
--disable_warnings
drop view if exists v1;
--enable_warnings
CREATE TABLE t1 (
  `oid` int(11) unsigned NOT NULL auto_increment,
  `fk_bbk_niederlassung` int(11) unsigned NOT NULL,
  `fk_wochentag` int(11) unsigned NOT NULL,
  `uhrzeit_von` time NOT NULL COMMENT 'HH:MM',
  `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM',
  `geloescht` tinyint(4) NOT NULL,
  `version` int(5) NOT NULL,
  PRIMARY KEY  (`oid`),
  KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`),
  KEY `fk_wochentag` (`fk_wochentag`),
  KEY `ix_version` (`version`)
) DEFAULT CHARSET=latin1;

insert  into t1 values
(1, 38, 1, '08:00:00', '13:00:00', 0, 1),
(2, 38, 2, '08:00:00', '13:00:00', 0, 1),
(3, 38, 3, '08:00:00', '13:00:00', 0, 1),
(4, 38, 4, '08:00:00', '13:00:00', 0, 1),
(5, 38, 5, '08:00:00', '13:00:00', 0, 1),
(6, 38, 5, '08:00:00', '13:00:00', 1, 2),
(7, 38, 3, '08:00:00', '13:00:00', 1, 2),
(8, 38, 1, '08:00:00', '13:00:00', 1, 2),
(9, 38, 2, '08:00:00', '13:00:00', 1, 2),
(10, 38, 4, '08:00:00', '13:00:00', 1, 2),
(11, 38, 1, '08:00:00', '13:00:00', 0, 3),
(12, 38, 2, '08:00:00', '13:00:00', 0, 3),
(13, 38, 3, '08:00:00', '13:00:00', 0, 3),
(14, 38, 4, '08:00:00', '13:00:00', 0, 3),
(15, 38, 5, '08:00:00', '13:00:00', 0, 3),
(16, 38, 4, '08:00:00', '13:00:00', 0, 4),
(17, 38, 5, '08:00:00', '13:00:00', 0, 4),
(18, 38, 1, '08:00:00', '13:00:00', 0, 4),
(19, 38, 2, '08:00:00', '13:00:00', 0, 4),
(20, 38, 3, '08:00:00', '13:00:00', 0, 4),
(21, 7, 1, '08:00:00', '13:00:00', 0, 1),
(22, 7, 2, '08:00:00', '13:00:00', 0, 1),
(23, 7, 3, '08:00:00', '13:00:00', 0, 1),
(24, 7, 4, '08:00:00', '13:00:00', 0, 1),
(25, 7, 5, '08:00:00', '13:00:00', 0, 1);

create view v1 as
select
  zeit1.oid AS oid,
  zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung,
  zeit1.fk_wochentag AS fk_wochentag,
  zeit1.uhrzeit_von AS uhrzeit_von,
  zeit1.uhrzeit_bis AS uhrzeit_bis,
  zeit1.geloescht AS geloescht,
  zeit1.version AS version
from
  t1 zeit1
where
(zeit1.version =
  (select max(zeit2.version) AS `max(version)`
   from t1 zeit2
   where
     ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and
      (zeit1.fk_wochentag = zeit2.fk_wochentag) and
      (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and
      (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis)
     )
  )
)
and (zeit1.geloescht = 0);

select * from v1 where oid = 21;
drop view v1;
drop table t1;
##
CREATE TABLE t1(
  t_cpac varchar(2) NOT NULL,
  t_vers varchar(4) NOT NULL,
  t_rele varchar(2) NOT NULL,
  t_cust varchar(4) NOT NULL,
  filler1 char(250) default NULL,
  filler2 char(250) default NULL,
  PRIMARY KEY (t_cpac,t_vers,t_rele,t_cust),
  UNIQUE KEY IX_4 (t_cust,t_cpac,t_vers,t_rele),
  KEY IX_5 (t_vers,t_rele,t_cust)
);

insert into t1 values
('tm','2.5 ','a ','    ','',''), ('tm','2.5U','a ','stnd','',''),
('da','3.3 ','b ','    ','',''), ('da','3.3U','b ','stnd','',''),
('tl','7.6 ','a ','    ','',''), ('tt','7.6 ','a ','    ','',''),
('bc','B61 ','a ','    ','',''), ('bp','B61 ','a ','    ','',''),
('ca','B61 ','a ','    ','',''), ('ci','B61 ','a ','    ','',''),
('cp','B61 ','a ','    ','',''), ('dm','B61 ','a ','    ','',''),
('ec','B61 ','a ','    ','',''), ('ed','B61 ','a ','    ','',''),
('fm','B61 ','a ','    ','',''), ('nt','B61 ','a ','    ','',''),
('qm','B61 ','a ','    ','',''), ('tc','B61 ','a ','    ','',''),
('td','B61 ','a ','    ','',''), ('tf','B61 ','a ','    ','',''),
('tg','B61 ','a ','    ','',''), ('ti','B61 ','a ','    ','',''),
('tp','B61 ','a ','    ','',''), ('ts','B61 ','a ','    ','',''),
('wh','B61 ','a ','    ','',''), ('bc','B61U','a ','stnd','',''),
('bp','B61U','a ','stnd','',''), ('ca','B61U','a ','stnd','',''),
('ci','B61U','a ','stnd','',''), ('cp','B61U','a ','stnd','',''),
('dm','B61U','a ','stnd','',''), ('ec','B61U','a ','stnd','',''),
('fm','B61U','a ','stnd','',''), ('nt','B61U','a ','stnd','',''),
('qm','B61U','a ','stnd','',''), ('tc','B61U','a ','stnd','',''),
('td','B61U','a ','stnd','',''), ('tf','B61U','a ','stnd','',''),
('tg','B61U','a ','stnd','',''), ('ti','B61U','a ','stnd','',''),
('tp','B61U','a ','stnd','',''), ('ts','B61U','a ','stnd','',''),
('wh','B61U','a ','stnd','','');
show create table t1;

select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6';
select t_vers,t_rele,t_cust,filler1 from t1 where t_vers = '7.6'
  and t_rele='a' and t_cust = ' ';

drop table t1;

# BUG#19021: Crash in index_merge/ROR-intersection optimizer under
# specific circumstances.
create table t1 (
  pk int(11) not null auto_increment,
  a int(11) not null default '0',
  b int(11) not null default '0',
  c int(11) not null default '0',

  filler1 datetime, filler2 varchar(15),
  filler3 longtext,

  kp1 varchar(4), kp2 varchar(7),
  kp3 varchar(2), kp4 varchar(4),
  kp5 varchar(7),
  filler4 char(1),

  primary key (pk),
  key idx1(a,b,c),
  key idx2(c),
  key idx3(kp1,kp2,kp3,kp4,kp5)
) default charset=latin1;
--disable_query_log
set @fill= uncompress(unhex(concat(
'F91D0000789CDD993D6FDB301086F7FE0A6D4E0105B8E3F1335D5BA028DA0EEDE28E1D320408',
'52A0713BF4D7571FB62C51A475924839080307B603E77DEE787C8FA41F9E9EEF7F1F8A87A7C3',
'AFE280C5DF9F8F7FEE9F8B1B2CB114D6902E918455245DB91300FA16E42D5201FA4EE29DA05D',
'B9FB3718A33718A3FA8C30AEFAFDE1F317D016AA67BA7A60FDE45BF5F8BA7B5BDE8812AA9F1A',
'069DB03C9804346644F3A3A6A1338DB572756A3C4D1BCC804CABF912C654AE9BB855A2B85962',
'3A479259CAE6A86C0411D01AE5483581EDCBD9A39C45252D532E533979EB9F82E971D979BDB4',
'8531105670740AFBFD1E34AAB0029E4AD0A1D46A6D0946A21A16038A5CD965CD2D524673F712',
'20C304477315CE18405EAF9BD0AFFEAC74FDA14F1FBF5BD34C769D73FBBEDF4750ADD4E5A99C',
'5C8DC04934AFA275D483D536D174C11B12AF27F8F888B41B6FC9DBA569E1FD7BD72D698130B7',
'91B23A98803512B3D31881E8DCDA2AC1754E3644C4BB3A8466750B911681274A39E35E8624B7',
'444A42AC1213F354758E3CF1A4CDD5A688C767CF1B11ABC5867CB15D8A18E0B91E9EC275BB94',
'58F33C2936F64690D55BC29E4A293D95A798D84217736CEAAA538CE1354269EE2162053FBC66',
'496D90CB53323CB279D3A6AF651B4B22B9E430743D83BE48E995A09D4FC9871C22D8D189B945',
'706911BCB8C3C774B9C08D2FC6ED853ADACA37A14A4CB2E027630E5B80ECACD939431B1CDF62',
'7D71487536EA2C678F59685E91F4B6C144BCCB94C1EBA9FA6F5552DDCA4E4539BE326A2720CB',
'45ED028EB3616AC93C46E775FEA9FA6DA7CFCEC6DEBA5FCD1F915EED4D983BDDB881528AD9AB',
'43C1576F29AAB35BDFBC21D422F52B307D350589D45225A887AC46C8EDD72D99EC3ED2E1BCEF',
'7AF26FC4C74097B6768A5EDAFA660CC64278F7E63F99AC954B')));
prepare x from @fill;
execute x;
deallocate prepare x;
--enable_query_log
set @fill=NULL;
SELECT COUNT(*) FROM t1 WHERE b = 0 AND a = 0 AND c = 13286427 AND
 kp1='279' AND kp2='ELM0678' AND kp3='6' AND kp4='10' AND  kp5 = 'R        ';

drop table t1;

Loading