~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/limit.test

  • Committer: Brian Aker
  • Date: 2008-08-18 04:35:40 UTC
  • mfrom: (342 codestyle)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: brian@tangent.org-20080818043540-numg7vydi7b0bzcd
Mering Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Test of update and delete with limit
3
 
#
4
 
 
5
 
--disable_warnings
6
 
drop table if exists t1;
7
 
--enable_warnings
8
 
 
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;
13
 
select * from t1;
14
 
update t1 set b=2 where b=1 limit 2;
15
 
select * from t1;
16
 
update t1 set b=4 where b=1;
17
 
select * from t1;
18
 
delete from t1 where b=2 limit 1;
19
 
select * from t1;
20
 
delete from t1 limit 1;
21
 
select * from t1;
22
 
drop table t1;
23
 
 
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;
30
 
select * from t1;
31
 
drop table t1;
32
 
 
33
 
# LIMIT 0
34
 
 
35
 
select 0 limit 0;
36
 
 
37
 
#
38
 
# Test with DELETE, ORDER BY and limit (bug #1024)
39
 
#
40
 
 
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;
45
 
SELECT * FROM t1; 
46
 
DELETE FROM t1 WHERE id2 = 0 ORDER BY id LIMIT 1; 
47
 
# should have deleted WHERE id=2 
48
 
SELECT * FROM t1; 
49
 
DELETE FROM t1 WHERE id2 = 0 ORDER BY id desc LIMIT 1; 
50
 
SELECT * FROM t1;
51
 
DROP TABLE t1;
52
 
 
53
 
#
54
 
# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
55
 
#
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;
62
 
drop table t1;
63
 
# End of 4.1 tests
64
 
 
65
 
--echo End of 5.0 tests