6
drop table if exists t1;
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;
20
# The following should give errors:
24
update t1 set b="a" where b="test";
28
delete from t1 where b="test";
30
delete from t1 where a+0=1;
32
select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
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;
40
# Test SQL_BIG_SELECTS
42
alter table t1 add key b (b);
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");
47
SELECT * from t1 order by a;
48
SET SQL_BIG_SELECTS=1;
49
SELECT * from t1 order by a;
53
SET MAX_JOIN_SIZE=DEFAULT;
57
# Test MAX_SEEKS_FOR_KEY
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;
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;
75
set local max_join_size=8;
77
select * from (select * from t1) x;
79
set local max_join_size=1;
81
select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
83
set local max_join_size=1;
85
select * from (select 1 union select 2 union select 3) x;
88
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;