diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 4033996b239..006b507d409 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -611,3 +611,35 @@ a b 5 2 6 2 drop table t1; +create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null, +key(a,b,d), key(c,b,a)); +create table t2 like t1; +insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3); +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +set @row=10; +insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10; +select * from t1 where a=1 and b in (1) order by c, b, a; +a b c d +1 1 2 0 +1 1 12 -1 +1 1 52 -5 +1 1 92 -9 +select * from t1 where a=1 and b in (1); +a b c d +1 1 92 -9 +1 1 52 -5 +1 1 12 -1 +1 1 2 0 +drop table t1, t2; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index bbb0046b47f..2cd8dbbb95a 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -393,3 +393,28 @@ select * from t1 where b=1 or b is null order by a; explain select * from t1 where b=2 or b is null order by a; select * from t1 where b=2 or b is null order by a; drop table t1; + +# +# Bug #3155 +# + +create table t1 (a int not null auto_increment, b int not null, c int not null, d int not null, +key(a,b,d), key(c,b,a)); +create table t2 like t1; +insert into t1 values (NULL, 1, 2, 0), (NULL, 2, 1, 1), (NULL, 3, 4, 2), (NULL, 4, 3, 3); +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +insert into t2 select null, b, c, d from t1; +insert into t1 select null, b, c, d from t2; +optimize table t1; +set @row=10; +insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10; +select * from t1 where a=1 and b in (1) order by c, b, a; +select * from t1 where a=1 and b in (1); +drop table t1, t2;