mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge bk-internal:/home/bk/mysql-4.0
into sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.0
This commit is contained in:
@ -27,6 +27,8 @@ PRIMARY KEY (userID)
|
||||
INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (4,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
INSERT INTO t2 VALUES (5,'name','pass','mail','Y','v','n','adr','1','1','1');
|
||||
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid;
|
||||
userid MIN(t1.score)
|
||||
1 1
|
||||
@ -47,8 +49,12 @@ userid MIN(t1.score+0.0)
|
||||
2 2.0
|
||||
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
|
||||
userid MIN(t1.score+0.0)
|
||||
1 1.0
|
||||
2 2.0
|
||||
1 1.0
|
||||
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
|
||||
t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
|
||||
drop table test.t1,test.t2;
|
||||
CREATE TABLE t1 (
|
||||
PID int(10) unsigned NOT NULL auto_increment,
|
||||
@ -242,34 +248,32 @@ score smallint(5) unsigned,
|
||||
key (spid),
|
||||
key (score)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3);
|
||||
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3);
|
||||
explain select userid,count(*) from t1 group by userid desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
|
||||
t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
|
||||
explain select userid,count(*) from t1 group by userid desc order by null;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
t1 ALL NULL NULL NULL NULL 8 Using temporary
|
||||
select userid,count(*) from t1 group by userid desc;
|
||||
userid count(*)
|
||||
3 3
|
||||
3 5
|
||||
2 1
|
||||
1 2
|
||||
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
|
||||
userid count(*)
|
||||
3 3
|
||||
1 2
|
||||
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
|
||||
userid count(*)
|
||||
3 3
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range spID spID 5 NULL 2 Using where; Using index
|
||||
t1 range spID spID 5 NULL 3 Using where; Using index
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range spID spID 5 NULL 2 Using where; Using index
|
||||
t1 range spID spID 5 NULL 3 Using where; Using index
|
||||
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range spID spID 5 NULL 2 Using where; Using index
|
||||
t1 range spID spID 5 NULL 3 Using where; Using index
|
||||
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
|
||||
spid count(*)
|
||||
1 1
|
||||
@ -280,12 +284,14 @@ spid count(*)
|
||||
1 1
|
||||
explain select sql_big_result spid,sum(userid) from t1 group by spid desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 6 Using filesort
|
||||
t1 ALL NULL NULL NULL NULL 8 Using filesort
|
||||
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 6
|
||||
t1 ALL NULL NULL NULL NULL 8
|
||||
select sql_big_result spid,sum(userid) from t1 group by spid desc;
|
||||
spid sum(userid)
|
||||
7 3
|
||||
6 3
|
||||
5 3
|
||||
4 3
|
||||
3 3
|
||||
@ -293,13 +299,13 @@ spid sum(userid)
|
||||
1 1
|
||||
explain select sql_big_result score,count(*) from t1 group by score desc;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL score 3 NULL 6 Using index
|
||||
t1 index NULL score 3 NULL 8 Using index
|
||||
explain select sql_big_result score,count(*) from t1 group by score desc order by null;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 index NULL score 3 NULL 6 Using index
|
||||
t1 index NULL score 3 NULL 8 Using index
|
||||
select sql_big_result score,count(*) from t1 group by score desc;
|
||||
score count(*)
|
||||
3 3
|
||||
3 5
|
||||
2 1
|
||||
1 2
|
||||
drop table t1;
|
||||
@ -535,15 +541,7 @@ t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
t2 ALL a NULL NULL NULL 4 Using where
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1, 4);
|
||||
insert into t1 values (10, 40);
|
||||
insert into t1 values (1, 4);
|
||||
insert into t1 values (10, 43);
|
||||
insert into t1 values (1, 4);
|
||||
insert into t1 values (10, 41);
|
||||
insert into t1 values (1, 4);
|
||||
insert into t1 values (10, 43);
|
||||
insert into t1 values (1, 4);
|
||||
insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4);
|
||||
select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a;
|
||||
a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000)
|
||||
1 4 2
|
||||
|
@ -1201,3 +1201,74 @@ a b
|
||||
8 5
|
||||
9 5
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) type=innodb;
|
||||
create table t2 (a int not null auto_increment primary key, b int);
|
||||
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (b) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
29267
|
||||
explain select a from t1 where a between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range PRIMARY PRIMARY 4 NULL 14790 Using where; Using index
|
||||
explain select * from t1 where a between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range PRIMARY PRIMARY 4 NULL 14790 Using where
|
||||
explain select * from t1 where c between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range c c 5 NULL 1 Using where
|
||||
update t1 set c=a;
|
||||
explain select * from t1 where c between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL c NULL NULL NULL 29537 Using where
|
||||
drop table t1,t2;
|
||||
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
|
||||
insert into t1 (id) values (null),(null),(null),(null),(null);
|
||||
update t1 set fk=69 where fk is null order by id limit 1;
|
||||
SELECT * from t1;
|
||||
id fk
|
||||
2 NULL
|
||||
3 NULL
|
||||
4 NULL
|
||||
5 NULL
|
||||
1 69
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null, key (a));
|
||||
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
|
||||
SET @tmp=0;
|
||||
update t1 set b=(@tmp:=@tmp+1) order by a;
|
||||
update t1 set b=99 where a=1 order by b asc limit 1;
|
||||
update t1 set b=100 where a=1 order by b desc limit 2;
|
||||
update t1 set a=a+10+b where a=1 order by b;
|
||||
select * from t1 order by a,b;
|
||||
a b
|
||||
2 4
|
||||
2 5
|
||||
2 6
|
||||
3 7
|
||||
3 8
|
||||
3 9
|
||||
3 10
|
||||
3 11
|
||||
3 12
|
||||
13 2
|
||||
111 100
|
||||
111 100
|
||||
drop table t1;
|
||||
|
@ -373,10 +373,10 @@ Thimble Smith Happy 3 3 3
|
||||
drop table t1,t2;
|
||||
create table t1 (id int not null, str char(10), index(str));
|
||||
insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar");
|
||||
select * from t1 where str is not null;
|
||||
select * from t1 where str is not null order by id;
|
||||
id str
|
||||
4 bar
|
||||
3 foo
|
||||
4 bar
|
||||
select * from t1 where str is null;
|
||||
id str
|
||||
1 NULL
|
||||
|
@ -286,7 +286,7 @@ a b
|
||||
107 7
|
||||
108 8
|
||||
109 9
|
||||
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b where t1.b between 3 and 5;
|
||||
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t2.a=t1.a-100;
|
||||
select * from t1;
|
||||
a b
|
||||
201 1
|
||||
@ -300,13 +300,13 @@ a b
|
||||
109 9
|
||||
select * from t2;
|
||||
a b
|
||||
1 3
|
||||
2 3
|
||||
3 3
|
||||
4 3
|
||||
5 3
|
||||
6 3
|
||||
7 3
|
||||
8 3
|
||||
9 3
|
||||
1 1
|
||||
2 2
|
||||
3 13
|
||||
4 14
|
||||
5 15
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
drop table t1,t2;
|
||||
|
@ -84,7 +84,7 @@ table type possible_keys key key_len ref rows Extra
|
||||
t1 range a,b a 5 NULL 5 Using where
|
||||
explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range a,b a 5 NULL 4 Using where
|
||||
t1 ALL a,b NULL NULL NULL 12 Using where
|
||||
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref a,b a 5 const 3 Using where
|
||||
|
@ -1,6 +1,6 @@
|
||||
drop table if exists t1;
|
||||
SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
|
||||
create table t1 (a int primary key, b char(20));
|
||||
create table t1 (a int auto_increment primary key, b char(20));
|
||||
insert into t1 values(1,"test");
|
||||
SELECT SQL_BUFFER_RESULT * from t1;
|
||||
a b
|
||||
@ -30,10 +30,34 @@ You are using safe update mode and you tried to update a table without a WHERE t
|
||||
delete from t1 where a+0=1;
|
||||
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
|
||||
select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
|
||||
The SELECT would examine too many records and probably take a very long time. Check your WHERE and use SET OPTION SQL_BIG_SELECTS=1 if the SELECT is ok
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
update t1 set b="a" limit 1;
|
||||
update t1 set b="a" where b="b" limit 2;
|
||||
delete from t1 where b="test" limit 1;
|
||||
delete from t1 where a+0=1 limit 2;
|
||||
SET MAX_JOIN_SIZE=2;
|
||||
SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS;
|
||||
@@max_join_size @@sql_big_selects
|
||||
2 0
|
||||
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
|
||||
SELECT * from t1;
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
SET SQL_BIG_SELECTS=1;
|
||||
SELECT * from t1;
|
||||
a b
|
||||
3 a
|
||||
2 test2
|
||||
4 a
|
||||
5 a
|
||||
SET MAX_JOIN_SIZE=2;
|
||||
SELECT * from t1;
|
||||
The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
|
||||
SET MAX_JOIN_SIZE=DEFAULT;
|
||||
SELECT * from t1;
|
||||
a b
|
||||
3 a
|
||||
2 test2
|
||||
4 a
|
||||
5 a
|
||||
drop table t1;
|
||||
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
|
||||
|
@ -102,13 +102,39 @@ select status from t1;
|
||||
status
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null);
|
||||
insert into t1 values (1,1),(1,2),(1,3);
|
||||
update t1 set b=4 where a=1 order by b asc limit 1;
|
||||
update t1 set b=4 where a=1 order by b desc limit 1;
|
||||
select * from t1;
|
||||
create table t1 (a int not null, b int not null, key (a));
|
||||
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
|
||||
SET @tmp=0;
|
||||
update t1 set b=(@tmp:=@tmp+1) order by a;
|
||||
update t1 set b=99 where a=1 order by b asc limit 1;
|
||||
select * from t1 order by a,b;
|
||||
a b
|
||||
1 4
|
||||
1 2
|
||||
1 4
|
||||
1 3
|
||||
1 99
|
||||
2 4
|
||||
2 5
|
||||
2 6
|
||||
3 7
|
||||
3 8
|
||||
3 9
|
||||
3 10
|
||||
3 11
|
||||
3 12
|
||||
update t1 set b=100 where a=1 order by b desc limit 2;
|
||||
update t1 set a=a+10+b where a=1 order by b;
|
||||
select * from t1 order by a,b;
|
||||
a b
|
||||
2 4
|
||||
2 5
|
||||
2 6
|
||||
3 7
|
||||
3 8
|
||||
3 9
|
||||
3 10
|
||||
3 11
|
||||
3 12
|
||||
13 2
|
||||
111 100
|
||||
111 100
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user