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#8023 - limit on UNION with from DUAL, causes syntax error
56
create table t1 (a integer);
57
insert into t1 values (1);
58
# both queries must return one row
59
select 1 as a from t1 union all select 1 from dual limit 1;
60
(select 1 as a from t1) union all (select 1 from dual) limit 1;
64
# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
66
create table t1 (a int);
67
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
68
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
69
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
70
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
71
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
76
# Bug #28464: a string argument to 'limit ?' PS
79
prepare s from "select 1 limit ?";
83
--error ER_WRONG_ARGUMENTS
85
prepare s from "select 1 limit 1, ?";
86
--error ER_WRONG_ARGUMENTS
88
prepare s from "select 1 limit ?, ?";
89
--error ER_WRONG_ARGUMENTS
90
execute s using @a, @a;
91
set @a=14632475938453979136;
92
execute s using @a, @a;
93
set @a=-14632475938453979136;
94
--error ER_WRONG_ARGUMENTS
95
execute s using @a, @a;
97
--echo End of 5.0 tests