~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/r/limit.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1;
 
2
create table t1 (a int not null default 0 primary key, b int not null default 0);
 
3
insert into t1 () values ();
 
4
insert into t1 values (1,1),(2,1),(3,1);
 
5
update t1 set a=4 where b=1 limit 1;
 
6
select * from t1;
 
7
a       b
 
8
0       0
 
9
4       1
 
10
2       1
 
11
3       1
 
12
update t1 set b=2 where b=1 limit 2;
 
13
select * from t1;
 
14
a       b
 
15
0       0
 
16
4       2
 
17
2       2
 
18
3       1
 
19
update t1 set b=4 where b=1;
 
20
select * from t1;
 
21
a       b
 
22
0       0
 
23
4       2
 
24
2       2
 
25
3       4
 
26
delete from t1 where b=2 limit 1;
 
27
select * from t1;
 
28
a       b
 
29
0       0
 
30
2       2
 
31
3       4
 
32
delete from t1 limit 1;
 
33
select * from t1;
 
34
a       b
 
35
2       2
 
36
3       4
 
37
drop table t1;
 
38
create table t1 (i int);
 
39
insert into t1 (i) values(1),(1),(1);
 
40
delete from t1 limit 1;
 
41
update t1 set i=2 limit 1;
 
42
delete from t1 limit 0;
 
43
update t1 set i=3 limit 0;
 
44
select * from t1;
 
45
i
 
46
2
 
47
1
 
48
drop table t1;
 
49
select 0 limit 0;
 
50
0
 
51
CREATE TABLE t1(id int auto_increment primary key, id2 int, index(id2));
 
52
INSERT INTO t1 (id2) values (0),(0),(0);
 
53
DELETE FROM t1 WHERE id=1;
 
54
INSERT INTO t1 SET id2=0;
 
55
SELECT * FROM t1;
 
56
id      id2
 
57
4       0
 
58
2       0
 
59
3       0
 
60
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1;
 
61
SELECT * FROM t1;
 
62
id      id2
 
63
4       0
 
64
3       0
 
65
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1;
 
66
SELECT * FROM t1;
 
67
id      id2
 
68
3       0
 
69
DROP TABLE t1;
 
70
create table t1 (a integer);
 
71
insert into t1 values (1);
 
72
select 1 as a from t1 union all select 1 from dual limit 1;
 
73
a
 
74
1
 
75
(select 1 as a from t1) union all (select 1 from dual) limit 1;
 
76
a
 
77
1
 
78
drop table t1;
 
79
create table t1 (a int);
 
80
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
 
81
explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
 
82
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
83
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    7       Using where; Using temporary
 
84
select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
 
85
c
 
86
7
 
87
explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
 
88
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
89
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    7       Using where; Using temporary
 
90
select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
 
91
c
 
92
28
 
93
drop table t1;
 
94
prepare s from "select 1 limit ?";
 
95
set @a='qwe';
 
96
execute s using @a;
 
97
1
 
98
set @a=-1;
 
99
execute s using @a;
 
100
ERROR HY000: Incorrect arguments to EXECUTE
 
101
prepare s from "select 1 limit 1, ?";
 
102
execute s using @a;
 
103
ERROR HY000: Incorrect arguments to EXECUTE
 
104
prepare s from "select 1 limit ?, ?";
 
105
execute s using @a, @a;
 
106
ERROR HY000: Incorrect arguments to EXECUTE
 
107
set @a=14632475938453979136;
 
108
execute s using @a, @a;
 
109
1
 
110
set @a=-14632475938453979136;
 
111
execute s using @a, @a;
 
112
ERROR HY000: Incorrect arguments to EXECUTE
 
113
End of 5.0 tests
 
114
select 1 as a limit 4294967296,10;
 
115
a
 
116
End of 5.1 tests