2
# Test of update and delete with limit
6
drop table if exists t1;
9
create table t1 (a int not null default 0 primary key, b int not null default 0);
10
insert into t1 () values (); # Testing default values
11
insert into t1 values (1,1),(2,1),(3,1);
12
update t1 set a=4 where b=1 limit 1;
14
update t1 set b=2 where b=1 limit 2;
17
update t1 set b=4 where b=1;
20
delete from t1 where b=2 limit 1;
23
delete from t1 limit 1;
28
create table t1 (i int);
29
insert into t1 (i) values(1),(1),(1);
30
delete from t1 limit 1;
31
update t1 set i=2 limit 1;
32
delete from t1 limit 0;
33
update t1 set i=3 limit 0;
43
# Test with DELETE, ORDER BY and limit (bug #1024)
46
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
47
INSERT INTO t1 (id2) values (0),(0),(0);
48
DELETE FROM t1 WHERE id=1;
49
INSERT INTO t1 SET id2=0;
51
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
52
# should have deleted WHERE id=2
54
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
59
# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
61
create table t1 (a int);
62
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
63
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
64
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
65
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
66
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
70
--echo End of 5.0 tests