mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge poseidon.ndb.mysql.com:/home/tomas/mysql-5.0
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
This commit is contained in:
@ -330,3 +330,8 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
|
||||
min max avg
|
||||
10.00 10.00 10
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a char(10), b char(10));
|
||||
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
|
||||
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
DROP TABLE t1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
drop table if exists t0, t1, t2, t3,t4;
|
||||
drop table if exists t0, t1, t2, t3, t4;
|
||||
create table t0
|
||||
(
|
||||
key1 int not null,
|
||||
@ -335,4 +335,55 @@ key1 key2 key3 key4 key5 key6 key7 key8
|
||||
select count(*) from t0;
|
||||
count(*)
|
||||
1021
|
||||
drop table t4;
|
||||
create table t4 (a int);
|
||||
insert into t4 values (1),(4),(3);
|
||||
set @save_join_buffer_size=@@join_buffer_size;
|
||||
set join_buffer_size= 4000;
|
||||
show variables like 'join_buffer_size';
|
||||
Variable_name Value
|
||||
join_buffer_size 8228
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
and (B.key1 < 500000 or B.key2 < 3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1016 Using sort_union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1016 Using sort_union(i1,i2); Using where
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
and (B.key1 < 500000 or B.key2 < 3);
|
||||
max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
10240
|
||||
update t0 set key1=1;
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
and (B.key1 = 1 or B.key2 = 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1020 Using union(i1,i2); Using where
|
||||
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1020 Using union(i1,i2); Using where
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
and (B.key1 = 1 or B.key2 = 1);
|
||||
max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
8194
|
||||
alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200);
|
||||
update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A, t0 as B
|
||||
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
|
||||
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A index_merge i1,i2,i3,i4,i5,i6,i7,i8 i2,i3,i4,i5,i6,i8 4,4,4,4,4,4 NULL 16 Using union(intersect(i2,i3,i4,i5,i6),i8); Using where
|
||||
1 SIMPLE B index_merge i1,i2,i3,i4,i5,i6,i7,i8 i2,i3,i4,i5,i6,i8 4,4,4,4,4,4 NULL 16 Using union(intersect(i2,i3,i4,i5,i6),i8); Using where
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A, t0 as B
|
||||
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
|
||||
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
|
||||
max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
8186
|
||||
set join_buffer_size= @save_join_buffer_size;
|
||||
drop table t0, t1, t2, t3, t4;
|
||||
|
@ -853,4 +853,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (a int, b int);
|
||||
insert into t2 values (1,1), (2,2);
|
||||
select * from t2 right join t1 on t2.a=t1.a;
|
||||
a b a b
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
NULL NULL 3 3
|
||||
select straight_join * from t2 right join t1 on t2.a=t1.a;
|
||||
a b a b
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
NULL NULL 3 3
|
||||
DROP TABLE t0,t1,t2,t3;
|
||||
|
@ -214,3 +214,16 @@ CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) N
|
||||
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Test for bug #7413 "Subquery with non-scalar results participating in
|
||||
# select list of derived table crashes server" aka "VIEW with sub query can
|
||||
# cause the MySQL server to crash". If we have encountered problem during
|
||||
# filling of derived table we should report error and perform cleanup
|
||||
# properly.
|
||||
#
|
||||
CREATE TABLE t1 (a char(10), b char(10));
|
||||
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
|
||||
--error 1242
|
||||
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
|
||||
DROP TABLE t1;
|
||||
|
@ -1,9 +1,8 @@
|
||||
#
|
||||
# Index merge tests
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t0, t1, t2, t3,t4;
|
||||
drop table if exists t0, t1, t2, t3, t4;
|
||||
--enable_warnings
|
||||
|
||||
# Create and fill a table with simple keys
|
||||
@ -278,4 +277,48 @@ delete from t0 where key1 < 3 or key2 < 4;
|
||||
select * from t0 where key1 < 3 or key2 < 4;
|
||||
select count(*) from t0;
|
||||
|
||||
drop table t0, t1, t2, t3, t4;
|
||||
# Test for BUG#4177
|
||||
drop table t4;
|
||||
create table t4 (a int);
|
||||
insert into t4 values (1),(4),(3);
|
||||
set @save_join_buffer_size=@@join_buffer_size;
|
||||
set join_buffer_size= 4000;
|
||||
show variables like 'join_buffer_size';
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
and (B.key1 < 500000 or B.key2 < 3);
|
||||
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 < 500000 or A.key2 < 3)
|
||||
and (B.key1 < 500000 or B.key2 < 3);
|
||||
|
||||
update t0 set key1=1;
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
and (B.key1 = 1 or B.key2 = 1);
|
||||
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
|
||||
where (A.key1 = 1 or A.key2 = 1)
|
||||
and (B.key1 = 1 or B.key2 = 1);
|
||||
|
||||
alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200);
|
||||
update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
|
||||
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A, t0 as B
|
||||
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
|
||||
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
|
||||
|
||||
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
|
||||
from t0 as A, t0 as B
|
||||
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
|
||||
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
|
||||
|
||||
set join_buffer_size= @save_join_buffer_size;
|
||||
# Test for BUG#4177 ends
|
||||
|
||||
drop table t0, t1, t2, t3, t4;
|
||||
|
||||
|
@ -606,4 +606,14 @@ INSERT INTO t1 VALUES (0);
|
||||
SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1;
|
||||
EXPLAIN SELECT * FROM t0, t1 LEFT JOIN (t2,t3) ON a1=5 WHERE a0=a1 AND a0=1;
|
||||
|
||||
# Test for BUG#4480
|
||||
drop table t1,t2;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (a int, b int);
|
||||
insert into t2 values (1,1), (2,2);
|
||||
|
||||
select * from t2 right join t1 on t2.a=t1.a;
|
||||
select straight_join * from t2 right join t1 on t2.a=t1.a;
|
||||
|
||||
DROP TABLE t0,t1,t2,t3;
|
||||
|
Reference in New Issue
Block a user