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;
16
update t1 set b=4 where b=1;
18
delete from t1 where b=2 limit 1;
20
delete from t1 limit 1;
24
create table t1 (i int);
25
insert into t1 (i) values(1),(1),(1);
26
delete from t1 limit 1;
27
update t1 set i=2 limit 1;
28
delete from t1 limit 0;
29
update t1 set i=3 limit 0;
38
# Test with DELETE, ORDER BY and limit (bug #1024)
41
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
42
INSERT INTO t1 (id2) values (0),(0),(0);
43
DELETE FROM t1 WHERE id=1;
44
INSERT INTO t1 SET id2=0;
46
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
47
# should have deleted WHERE id=2
49
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
54
# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
56
create table t1 (a int);
57
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
58
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
59
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
60
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
61
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
65
--echo End of 5.0 tests