~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# test of safe selects
3
#
4
5
--disable_warnings
6
drop table if exists t1;
7
--enable_warnings
8
9
SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
10
create table t1 (a int auto_increment primary key, b char(20));
11
insert into t1 values(1,"test");
12
SELECT SQL_BUFFER_RESULT * from t1;
13
update t1 set b="a" where a=1;
14
delete from t1 where a=1;
15
insert into t1 values(1,"test"),(2,"test2");
16
SELECT SQL_BUFFER_RESULT * from t1;
17
update t1 set b="a" where a=1;
18
select 1 from t1,t1 as t2,t1 as t3;
19
20
# The following should give errors:
21
--error 1175
22
update t1 set b="a";
23
--error 1175
24
update t1 set b="a" where b="test";
25
--error 1175
26
delete from t1;
27
--error 1175
28
delete from t1 where b="test";
29
--error 1175
30
delete from t1 where a+0=1;
31
--error 1104
32
select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
33
34
# The following should be ok:
35
update t1 set b="a" limit 1;
36
update t1 set b="a" where b="b" limit 2; 
37
delete from t1 where b="test" limit 1;
38
delete from t1 where a+0=1 limit 2;
39
40
# Test SQL_BIG_SELECTS
41
42
alter table t1 add key b (b);
43
SET MAX_JOIN_SIZE=2;
44
SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS;
45
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
46
--error 1104
47
SELECT * from t1 order by a;
48
SET SQL_BIG_SELECTS=1;
49
SELECT * from t1 order by a;
50
SET MAX_JOIN_SIZE=2;
51
--error 1104
52
SELECT * from t1;
53
SET MAX_JOIN_SIZE=DEFAULT;
54
SELECT * from t1;
55
56
#
57
# Test MAX_SEEKS_FOR_KEY
58
#
59
analyze table t1;
60
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
61
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
62
set MAX_SEEKS_FOR_KEY=1;
63
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
64
SET MAX_SEEKS_FOR_KEY=DEFAULT;
65
66
drop table t1;
67
68
# BUG#8726
69
create table t1 (a int);
70
insert into t1 values (1),(2),(3),(4),(5);
71
insert into t1 select * from t1;
72
insert into t1 select * from t1;
73
insert into t1 select * from t1;
74
75
set local  max_join_size=8;
76
--error 1104
77
select * from (select * from t1) x;
78
79
set local  max_join_size=1;
80
--error 1104
81
select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
82
83
set local  max_join_size=1;
84
--error 1104
85
select * from (select 1 union select 2 union select 3) x;
86
drop table t1;
87
88
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
89
90
# End of 4.1 tests