mirror of
https://github.com/MariaDB/server.git
synced 2025-08-31 22:22:30 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into bodhi.local:/opt/local/work/mysql-5.0-runtime
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
SHOW COLLATION LIKE 'cp1250_czech_cs';
|
||||
Collation Charset Id Default Compiled Sortlen
|
||||
cp1250_czech_cs cp1250 34 Yes 2
|
||||
|
@@ -171,8 +171,8 @@ create table t1 (a char(10) character set koi8r, b text character set koi8r);
|
||||
insert into t1 values ('test','test');
|
||||
insert into t1 values ('<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1265 Data truncated for column 'b' at row 1
|
||||
Warning 1366 Incorrect string value: '\xCA\xC3\xD5\xCB' for column 'a' at row 1
|
||||
Warning 1366 Incorrect string value: '\xCA\xC3\xD5\xCB' for column 'b' at row 1
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set cp1251);
|
||||
|
@@ -723,6 +723,28 @@ lily
|
||||
river
|
||||
drop table t1;
|
||||
deallocate prepare stmt;
|
||||
create table t1 (
|
||||
a char(10) unicode not null,
|
||||
index a (a)
|
||||
) engine=myisam;
|
||||
insert into t1 values (repeat(0x201f, 10));
|
||||
insert into t1 values (repeat(0x2020, 10));
|
||||
insert into t1 values (repeat(0x2021, 10));
|
||||
explain select hex(a) from t1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 20 NULL 3 Using index
|
||||
select hex(a) from t1 order by a;
|
||||
hex(a)
|
||||
201F201F201F201F201F201F201F201F201F201F
|
||||
2020202020202020202020202020202020202020
|
||||
2021202120212021202120212021202120212021
|
||||
alter table t1 drop index a;
|
||||
select hex(a) from t1 order by a;
|
||||
hex(a)
|
||||
201F201F201F201F201F201F201F201F201F201F
|
||||
2020202020202020202020202020202020202020
|
||||
2021202120212021202120212021202120212021
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
|
||||
INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
|
||||
SELECT id, MIN(s) FROM t1 GROUP BY id;
|
||||
|
@@ -197,7 +197,7 @@ drop table t1;
|
||||
create table t1 (s1 char(10) character set utf8);
|
||||
insert into t1 values (0x41FF);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 's1' at row 1
|
||||
Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1
|
||||
select hex(s1) from t1;
|
||||
hex(s1)
|
||||
41
|
||||
@@ -205,7 +205,7 @@ drop table t1;
|
||||
create table t1 (s1 varchar(10) character set utf8);
|
||||
insert into t1 values (0x41FF);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 's1' at row 1
|
||||
Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1
|
||||
select hex(s1) from t1;
|
||||
hex(s1)
|
||||
41
|
||||
@@ -213,7 +213,7 @@ drop table t1;
|
||||
create table t1 (s1 text character set utf8);
|
||||
insert into t1 values (0x41FF);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 's1' at row 1
|
||||
Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1
|
||||
select hex(s1) from t1;
|
||||
hex(s1)
|
||||
41
|
||||
@@ -1536,6 +1536,32 @@ set @a:=null;
|
||||
execute my_stmt using @a;
|
||||
a b
|
||||
drop table if exists t1;
|
||||
drop table if exists t1;
|
||||
drop view if exists v1, v2;
|
||||
set names utf8;
|
||||
create table t1(col1 varchar(12) character set utf8 collate utf8_unicode_ci);
|
||||
insert into t1 values('t1_val');
|
||||
create view v1 as select 'v1_val' as col1;
|
||||
select coercibility(col1), collation(col1) from v1;
|
||||
coercibility(col1) collation(col1)
|
||||
4 utf8_general_ci
|
||||
create view v2 as select col1 from v1 union select col1 from t1;
|
||||
select coercibility(col1), collation(col1)from v2;
|
||||
coercibility(col1) collation(col1)
|
||||
2 utf8_unicode_ci
|
||||
2 utf8_unicode_ci
|
||||
drop view v1, v2;
|
||||
create view v1 as select 'v1_val' collate utf8_swedish_ci as col1;
|
||||
select coercibility(col1), collation(col1) from v1;
|
||||
coercibility(col1) collation(col1)
|
||||
0 utf8_swedish_ci
|
||||
create view v2 as select col1 from v1 union select col1 from t1;
|
||||
select coercibility(col1), collation(col1) from v2;
|
||||
coercibility(col1) collation(col1)
|
||||
0 utf8_swedish_ci
|
||||
0 utf8_swedish_ci
|
||||
drop view v1, v2;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
colA int(11) NOT NULL,
|
||||
colB varchar(255) character set utf8 NOT NULL,
|
||||
|
@@ -372,10 +372,10 @@ t collation(t) FORMAT(MATCH t AGAINST ('Osnabruck'),6)
|
||||
aus Osnabr<62>ck utf8_general_ci 1.591140
|
||||
alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 't' at row 3
|
||||
Warning 1265 Data truncated for column 't' at row 4
|
||||
Warning 1265 Data truncated for column 't' at row 5
|
||||
Warning 1265 Data truncated for column 't' at row 6
|
||||
Warning 1366 Incorrect string value: '\xD0\xAD\xD1\x82\xD0\xBE...' for column 't' at row 3
|
||||
Warning 1366 Incorrect string value: '\xD0\x9E\xD1\x82\xD0\xBB...' for column 't' at row 4
|
||||
Warning 1366 Incorrect string value: '\xD0\x9D\xD0\xB5 \xD0...' for column 't' at row 5
|
||||
Warning 1366 Incorrect string value: '\xD0\xB8 \xD0\xB1\xD1...' for column 't' at row 6
|
||||
SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
t collation(t)
|
||||
aus Osnabr<62>ck latin1_german2_ci
|
||||
|
@@ -658,3 +658,73 @@ GROUP_CONCAT(a) x
|
||||
2 1,2
|
||||
1 2,3
|
||||
DROP TABLE t1;
|
||||
set names utf8;
|
||||
create table t1
|
||||
(
|
||||
x text character set utf8 not null,
|
||||
y integer not null
|
||||
);
|
||||
insert into t1 values (repeat('a', 1022), 0), (repeat(_utf8 0xc3b7, 4), 0);
|
||||
set group_concat_max_len= 1022 + 10;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1032 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 9;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1031 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 8;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1030 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 7;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1029 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 6;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1028 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 5;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1027 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 4;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1026 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 3;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1025 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 2;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1024 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
set group_concat_max_len= 1022 + 1;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1023 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
drop table t1;
|
||||
set group_concat_max_len=1024;
|
||||
set names latin1;
|
||||
create table t1 (f1 int unsigned, f2 varchar(255));
|
||||
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
|
||||
select f2,group_concat(f1) from t1 group by f2;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
|
||||
def group_concat(f1) 252 1024 1 Y 128 0 63
|
||||
f2 group_concat(f1)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
|
||||
drop table t1;
|
||||
|
@@ -1029,3 +1029,29 @@ t1 CREATE TABLE `t1` (
|
||||
`stddev(0)` double(8,4) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
|
||||
INSERT INTO t1 SELECT a, b+8 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+16 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+32 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+64 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+128 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+256 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+512 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+1024 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+2048 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+4096 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+8192 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+16384 FROM t1;
|
||||
INSERT INTO t1 SELECT a, b+32768 FROM t1;
|
||||
SELECT a,COUNT(DISTINCT b) AS cnt FROM t1 GROUP BY a HAVING cnt > 50;
|
||||
a cnt
|
||||
1 65536
|
||||
SELECT a,SUM(DISTINCT b) AS sumation FROM t1 GROUP BY a HAVING sumation > 50;
|
||||
a sumation
|
||||
1 2147516416
|
||||
SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50;
|
||||
a average
|
||||
1 32768.5000
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
@@ -873,3 +873,11 @@ SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
|
||||
1
|
||||
1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
|
||||
INSERT INTO t1(foo) VALUES (NULL);
|
||||
ERROR 23000: Column 'foo' cannot be null
|
||||
INSERT INTO t1() VALUES ();
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
INSERT INTO t1(foo) VALUES ('');
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
DROP TABLE t1;
|
||||
|
@@ -1254,3 +1254,18 @@ COLUMN_NAME MD5(COLUMN_DEFAULT) LENGTH(COLUMN_DEFAULT) COLUMN_DEFAULT=get_value(
|
||||
fld1 7cf7a6782be951a1f2464a350da926a5 65532 1
|
||||
DROP TABLE bug23037;
|
||||
DROP FUNCTION get_value;
|
||||
create view v1 as
|
||||
select table_schema as object_schema,
|
||||
table_name as object_name,
|
||||
table_type as object_type
|
||||
from information_schema.tables
|
||||
order by object_schema;
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED tables ALL NULL NULL NULL NULL 2 Using filesort
|
||||
explain select * from (select table_name from information_schema.tables) as a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED tables ALL NULL NULL NULL NULL 2
|
||||
drop view v1;
|
||||
|
@@ -84,3 +84,27 @@ create table t2 like T1;
|
||||
drop table t1, t2;
|
||||
show tables;
|
||||
Tables_in_test
|
||||
set names utf8;
|
||||
drop table if exists İ,İİ;
|
||||
create table İ (s1 int);
|
||||
show create table İ;
|
||||
Table Create Table
|
||||
İ CREATE TABLE `i` (
|
||||
`s1` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show tables;
|
||||
Tables_in_test
|
||||
i
|
||||
drop table İ;
|
||||
create table İİ (s1 int);
|
||||
show create table İİ;
|
||||
Table Create Table
|
||||
İİ CREATE TABLE `ii` (
|
||||
`s1` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
show tables;
|
||||
Tables_in_test
|
||||
ii
|
||||
drop table İİ;
|
||||
set names latin1;
|
||||
End of 5.0 tests
|
||||
|
@@ -96,3 +96,37 @@ i
|
||||
2
|
||||
affected rows: 1
|
||||
affected rows: 0
|
||||
create table t1 (id int(10));
|
||||
insert into t1 values (1);
|
||||
CREATE VIEW v1 AS select t1.id as id from t1;
|
||||
CREATE VIEW v2 AS select t1.id as renamed from t1;
|
||||
CREATE VIEW v3 AS select t1.id + 12 as renamed from t1;
|
||||
select * from v1 group by id limit 1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 v1 id id 3 10 1 Y 32768 0 63
|
||||
id
|
||||
1
|
||||
select * from v1 group by id limit 0;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 v1 id id 3 10 0 Y 32768 0 63
|
||||
id
|
||||
select * from v1 where id=1000 group by id;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 v1 id id 3 10 0 Y 32768 0 63
|
||||
id
|
||||
select * from v1 where id=1 group by id;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 v1 id id 3 10 1 Y 32768 0 63
|
||||
id
|
||||
1
|
||||
select * from v2 where renamed=1 group by renamed;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 v2 id renamed 3 10 1 Y 32768 0 63
|
||||
renamed
|
||||
1
|
||||
select * from v3 where renamed=1 group by renamed;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def v3 renamed 8 12 0 Y 32896 0 63
|
||||
renamed
|
||||
drop table t1;
|
||||
drop view v1,v2,v3;
|
||||
|
@@ -760,13 +760,6 @@ xxxxxxxxxxxxxxxxxxxaa
|
||||
xxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxz
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null, c int not null);
|
||||
insert t1 values (1,1,1),(1,1,2),(1,2,1);
|
||||
select a, b from t1 group by a, b order by sum(c);
|
||||
a b
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
`sid` decimal(8,0) default null,
|
||||
`wnid` varchar(11) not null default '',
|
||||
@@ -854,6 +847,40 @@ b a
|
||||
20 1
|
||||
10 2
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT a + 1 AS num FROM t1 ORDER BY 30 - num;
|
||||
num
|
||||
3
|
||||
2
|
||||
SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
|
||||
str
|
||||
test1
|
||||
test2
|
||||
SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
|
||||
num
|
||||
3
|
||||
2
|
||||
SELECT a + 1 AS num FROM t1 HAVING 30 - num;
|
||||
num
|
||||
2
|
||||
3
|
||||
SELECT a + 1 AS num, num + 1 FROM t1;
|
||||
ERROR 42S22: Unknown column 'num' in 'field list'
|
||||
SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
|
||||
num (select num + 2 FROM t1 LIMIT 1)
|
||||
2 4
|
||||
3 5
|
||||
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
|
||||
ERROR 42S22: Unknown column 'num' in 'on clause'
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int not null, b int not null, c int not null);
|
||||
insert t1 values (1,1,1),(1,1,2),(1,2,1);
|
||||
select a, b from t1 group by a, b order by sum(c);
|
||||
a b
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
|
||||
explain SELECT t1.b as a, t2.b as c FROM
|
||||
|
@@ -1273,3 +1273,51 @@ Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
drop table t1;
|
||||
SET GLOBAL query_cache_size=0;
|
||||
set global query_cache_size=1024*1024;
|
||||
flush status;
|
||||
create table t1 (a int);
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
create table t2 like t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
insert into t2 select * from t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 3
|
||||
drop table t1, t2;
|
||||
create table t1(c1 int);
|
||||
create table t2(c1 int);
|
||||
create table t3(c1 int);
|
||||
create view v1 as select t3.c1 as c1 from t3,t2 where t3.c1 = t2.c1;
|
||||
start transaction;
|
||||
insert into t1(c1) select c1 from v1;
|
||||
drop table t1, t2, t3;
|
||||
drop view v1;
|
||||
set global query_cache_size=0;
|
||||
|
@@ -6,7 +6,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
create table t1 (a int not null, key(a)) engine=innodb;
|
||||
create table t2 (a int not null, key(a)) engine=innodb;
|
||||
create table t3 (a int) engine=innodb;
|
||||
create table t3 (a int unique) engine=innodb;
|
||||
create table t4 (a int) engine=innodb;
|
||||
show variables like 'slave_transaction_retries';
|
||||
Variable_name Value
|
||||
@@ -35,14 +35,14 @@ begin;
|
||||
select * from t1 for update;
|
||||
a
|
||||
start slave;
|
||||
insert into t2 values(22);
|
||||
insert into t2 values(201);
|
||||
commit;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
22
|
||||
201
|
||||
show slave status;
|
||||
Slave_IO_State #
|
||||
Master_Host 127.0.0.1
|
||||
@@ -50,7 +50,7 @@ Master_User root
|
||||
Master_Port MASTER_MYPORT
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos 18911
|
||||
Read_Master_Log_Pos 18918
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
@@ -65,7 +65,7 @@ Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos 18911
|
||||
Exec_Master_Log_Pos 18918
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
@@ -78,12 +78,16 @@ Master_SSL_Cipher
|
||||
Master_SSL_Key
|
||||
Seconds_Behind_Master #
|
||||
stop slave;
|
||||
change master to master_log_pos=532;
|
||||
delete from t3;
|
||||
change master to master_log_pos=539;
|
||||
begin;
|
||||
select * from t2 for update;
|
||||
a
|
||||
22
|
||||
201
|
||||
start slave;
|
||||
select count(*) from t3 /* must be zero */;
|
||||
count(*)
|
||||
0
|
||||
commit;
|
||||
select * from t1;
|
||||
a
|
||||
@@ -91,7 +95,7 @@ a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
22
|
||||
201
|
||||
show slave status;
|
||||
Slave_IO_State #
|
||||
Master_Host 127.0.0.1
|
||||
@@ -99,7 +103,7 @@ Master_User root
|
||||
Master_Port MASTER_MYPORT
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos 18911
|
||||
Read_Master_Log_Pos 18918
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
@@ -114,7 +118,7 @@ Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos 18911
|
||||
Exec_Master_Log_Pos 18918
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
@@ -128,12 +132,16 @@ Master_SSL_Key
|
||||
Seconds_Behind_Master #
|
||||
set global max_relay_log_size=0;
|
||||
stop slave;
|
||||
change master to master_log_pos=532;
|
||||
delete from t3;
|
||||
change master to master_log_pos=539;
|
||||
begin;
|
||||
select * from t2 for update;
|
||||
a
|
||||
22
|
||||
201
|
||||
start slave;
|
||||
select count(*) from t3 /* must be zero */;
|
||||
count(*)
|
||||
0
|
||||
commit;
|
||||
select * from t1;
|
||||
a
|
||||
@@ -142,7 +150,7 @@ a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
22
|
||||
201
|
||||
show slave status;
|
||||
Slave_IO_State #
|
||||
Master_Host 127.0.0.1
|
||||
@@ -150,7 +158,7 @@ Master_User root
|
||||
Master_Port MASTER_MYPORT
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos 18911
|
||||
Read_Master_Log_Pos 18918
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
@@ -165,7 +173,7 @@ Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos 18911
|
||||
Exec_Master_Log_Pos 18918
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
|
@@ -14,3 +14,19 @@ SELECT * FROM t4;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t4;
|
||||
DROP TABLE IF EXISTS t5;
|
||||
CREATE TABLE t5 (
|
||||
word varchar(50) collate utf8_unicode_ci NOT NULL default ''
|
||||
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
SET @@session.character_set_client=33,@@session.collation_connection=192;
|
||||
CREATE TEMPORARY TABLE tmptbl504451f4258$1 (id INT NOT NULL) ENGINE=MEMORY;
|
||||
INSERT INTO t5 (word) VALUES ('TEST’');
|
||||
SELECT HEX(word) FROM t5;
|
||||
HEX(word)
|
||||
54455354E28099
|
||||
SELECT HEX(word) FROM t5;
|
||||
HEX(word)
|
||||
54455354E28099
|
||||
SELECT * FROM tmptbl504451f4258$1;
|
||||
ERROR 42S02: Table 'test.tmptbl504451f4258$1' doesn't exist
|
||||
DROP TABLE t5;
|
||||
|
17
mysql-test/r/rpl_packet.result
Normal file
17
mysql-test/r/rpl_packet.result
Normal file
@@ -0,0 +1,17 @@
|
||||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
drop database if exists DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
|
||||
create database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
|
||||
select @@net_buffer_length, @@max_allowed_packet;
|
||||
@@net_buffer_length @@max_allowed_packet
|
||||
1024 1024
|
||||
create table `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
|
||||
INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1023');
|
||||
select count(*) from `DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________`.`t1` /* must be 1 */;
|
||||
count(*)
|
||||
1
|
||||
drop database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
|
@@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@@ -1,3 +1,4 @@
|
||||
drop table if exists t1;
|
||||
set @org_mode=@@sql_mode;
|
||||
create table t1
|
||||
(
|
||||
|
@@ -744,7 +744,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 AS `1` having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 AS `3` having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))
|
||||
Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 AS `1` having trigcond((<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1))) union select 3 AS `3` having trigcond((<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))))
|
||||
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
|
||||
id
|
||||
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
|
||||
@@ -907,7 +907,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and trigcond(((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a float);
|
||||
select 10.5 IN (SELECT * from t1 LIMIT 1);
|
||||
@@ -2816,19 +2816,19 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'0') and ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) having (<is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`)))) AS `test` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'0') and trigcond((((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))))) having trigcond((<is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
|
||||
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`))))
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'N') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`))))))
|
||||
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = _latin1'0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)) and <is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`)))) AS `test` from `test`.`t1`
|
||||
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = _latin1'0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having trigcond((((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)) and <is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1`
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a char(5), b char(5));
|
||||
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');
|
||||
@@ -3001,6 +3001,38 @@ field1 field2
|
||||
1 1
|
||||
1 3
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1(a int, INDEX (a));
|
||||
INSERT INTO t1 VALUES (1), (3), (5), (7);
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
CREATE TABLE t2(a int);
|
||||
INSERT INTO t2 VALUES (1),(2),(3);
|
||||
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index
|
||||
SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
a a IN (SELECT a FROM t1)
|
||||
1 1
|
||||
2 NULL
|
||||
3 1
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a DATETIME);
|
||||
INSERT INTO t1 VALUES ('1998-09-23'), ('2003-03-25');
|
||||
CREATE TABLE t2 AS SELECT
|
||||
(SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
|
||||
FROM t1 WHERE a > '2000-01-01';
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`sub_a` datetime default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
CREATE TABLE t3 AS (SELECT a FROM t1 WHERE a < '2000-01-01') UNION (SELECT a FROM t1 WHERE a > '2000-01-01');
|
||||
SHOW CREATE TABLE t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` datetime default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1,t2,t3;
|
||||
create table t1 (df decimal(5,1));
|
||||
insert into t1 values(1.1);
|
||||
insert into t1 values(2.2);
|
||||
@@ -3544,3 +3576,19 @@ FROM t1 GROUP BY t1.a LIMIT 1)
|
||||
2
|
||||
2
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b));
|
||||
CREATE TABLE t2 (x int auto_increment, y int, z int,
|
||||
PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b));
|
||||
SET SESSION sort_buffer_size = 32 * 1024;
|
||||
SELECT SQL_NO_CACHE COUNT(*)
|
||||
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
|
||||
FROM t1) t;
|
||||
COUNT(*)
|
||||
3000
|
||||
SET SESSION sort_buffer_size = 8 * 1024 * 1024;
|
||||
SELECT SQL_NO_CACHE COUNT(*)
|
||||
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
|
||||
FROM t1) t;
|
||||
COUNT(*)
|
||||
3000
|
||||
DROP TABLE t1,t2;
|
||||
|
153
mysql-test/r/subselect3.result
Normal file
153
mysql-test/r/subselect3.result
Normal file
@@ -0,0 +1,153 @@
|
||||
drop table if exists t0, t1, t2, t3, t4;
|
||||
create table t1 (oref int, grp int, ie int) ;
|
||||
insert into t1 (oref, grp, ie) values
|
||||
(1, 1, 1),
|
||||
(1, 1, 1),
|
||||
(1, 2, NULL),
|
||||
(2, 1, 3),
|
||||
(3, 1, 4),
|
||||
(3, 2, NULL);
|
||||
create table t2 (oref int, a int);
|
||||
insert into t2 values
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, NULL),
|
||||
(2, NULL);
|
||||
select a, oref, a in (select max(ie)
|
||||
from t1 where oref=t2.oref group by grp) from t2;
|
||||
a oref a in (select max(ie)
|
||||
from t1 where oref=t2.oref group by grp)
|
||||
1 1 1
|
||||
2 2 0
|
||||
3 3 NULL
|
||||
NULL 4 0
|
||||
NULL 2 NULL
|
||||
explain extended
|
||||
select a, oref, a in (select max(ie)
|
||||
from t1 where oref=t2.oref group by grp) from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `a in (select max(ie)
|
||||
from t1 where oref=t2.oref group by grp)` from `test`.`t2`
|
||||
explain extended
|
||||
select a, oref from t2
|
||||
where a in (select max(ie) from t1 where oref=t2.oref group by grp);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))
|
||||
create table t3 (a int);
|
||||
insert into t3 values (NULL), (NULL);
|
||||
flush status;
|
||||
select a in (select max(ie) from t1 where oref=4 group by grp) from t3;
|
||||
a in (select max(ie) from t1 where oref=4 group by grp)
|
||||
0
|
||||
0
|
||||
show status like 'Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 11
|
||||
select ' ^ This must show 11' Z;
|
||||
Z
|
||||
^ This must show 11
|
||||
explain extended select a in (select max(ie) from t1 where oref=4 group by grp) from t3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select <in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) AS `max(ie)` from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3`
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int, oref int, key(a));
|
||||
insert into t1 values
|
||||
(1, 1),
|
||||
(1, NULL),
|
||||
(2, 3),
|
||||
(2, NULL),
|
||||
(3, NULL);
|
||||
create table t2 (a int, oref int);
|
||||
insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4);
|
||||
select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
|
||||
oref a Z
|
||||
1 1 1
|
||||
2 2 0
|
||||
3 NULL NULL
|
||||
4 NULL 0
|
||||
explain extended
|
||||
select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 4
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`)))) AS `Z` from `test`.`t2`
|
||||
flush status;
|
||||
select oref, a from t2 where a in (select a from t1 where oref=t2.oref);
|
||||
oref a
|
||||
1 1
|
||||
show status like '%Handler_read_rnd_next';
|
||||
Variable_name Value
|
||||
Handler_read_rnd_next 5
|
||||
delete from t2;
|
||||
insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0);
|
||||
flush status;
|
||||
select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
|
||||
oref a Z
|
||||
0 NULL 0
|
||||
0 NULL 0
|
||||
0 NULL 0
|
||||
0 NULL 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_next 29
|
||||
select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z;
|
||||
Z
|
||||
No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, primary key (a));
|
||||
insert into t1 values (1,1), (3,1),(100,1);
|
||||
create table t2 (a int, b int);
|
||||
insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0);
|
||||
select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ;
|
||||
a b Z
|
||||
1 1 1
|
||||
2 1 0
|
||||
NULL 1 NULL
|
||||
NULL 0 0
|
||||
drop table t1, t2;
|
||||
create table t1 (a int, b int, key(a));
|
||||
insert into t1 values
|
||||
(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
update t2 set b=1;
|
||||
create table t3 (a int, oref int);
|
||||
insert into t3 values (1, 1), (NULL,1), (NULL,0);
|
||||
select a, oref,
|
||||
t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z
|
||||
from t3;
|
||||
a oref Z
|
||||
1 1 1
|
||||
NULL 1 NULL
|
||||
NULL 0 0
|
||||
explain extended
|
||||
select a, oref,
|
||||
t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z
|
||||
from t3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 ref_or_null a a 5 func 4 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 't3.oref' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))) AS `Z` from `test`.`t3`
|
||||
drop table t1, t2, t3;
|
@@ -179,3 +179,15 @@ a
|
||||
2006-06-06 15:55:55
|
||||
DROP PREPARE s;
|
||||
DROP TABLE t1;
|
||||
SELECT CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6));
|
||||
CAST(CAST('2006-08-10' AS DATE) AS DECIMAL(20,6))
|
||||
20060810.000000
|
||||
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6));
|
||||
CAST(CAST('2006-08-10 10:11:12' AS DATETIME) AS DECIMAL(20,6))
|
||||
20060810101112.000000
|
||||
SELECT CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6));
|
||||
CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMAL(20,6))
|
||||
20060810101112.000014
|
||||
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
|
||||
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
|
||||
101112.098700
|
||||
|
@@ -1410,3 +1410,16 @@ i2 count(distinct j)
|
||||
1.0 2
|
||||
2.0 2
|
||||
drop table t1;
|
||||
create table t1(f1 decimal(20,6));
|
||||
insert into t1 values (CAST('10:11:12' AS date) + interval 14 microsecond);
|
||||
insert into t1 values (CAST('10:11:12' AS time));
|
||||
select * from t1;
|
||||
f1
|
||||
20101112000000.000014
|
||||
101112.000000
|
||||
drop table t1;
|
||||
select cast(19999999999999999999 as unsigned);
|
||||
cast(19999999999999999999 as unsigned)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Error 1292 Truncated incorrect DECIMAL value: ''
|
||||
|
@@ -105,6 +105,85 @@ explain select myfunc_int(f1) from t1 order by 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
drop table t1;
|
||||
CREATE TABLE t1(a INT, b INT);
|
||||
INSERT INTO t1 values (1,1),(2,2);
|
||||
CREATE FUNCTION fn(a int) RETURNS int DETERMINISTIC
|
||||
BEGIN
|
||||
RETURN a;
|
||||
END
|
||||
||
|
||||
CREATE VIEW v1 AS SELECT a, fn(MIN(b)) as c FROM t1 GROUP BY a;
|
||||
SELECT myfunc_int(a AS attr_name) FROM t1;
|
||||
myfunc_int(a AS attr_name)
|
||||
1
|
||||
2
|
||||
EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
Warnings:
|
||||
Note 1003 select myfunc_int(`test`.`t1`.`a` AS `attr_name`) AS `myfunc_int(a AS attr_name)` from `test`.`t1`
|
||||
EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
Warnings:
|
||||
Note 1003 select myfunc_int(`test`.`t1`.`a` AS `a`) AS `myfunc_int(a)` from `test`.`t1`
|
||||
SELECT a,c FROM v1;
|
||||
a c
|
||||
1 1
|
||||
2 2
|
||||
SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx) as c FROM t1 GROUP BY a' at line 1
|
||||
SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx)) as c FROM t1 GROUP BY a' at line 1
|
||||
SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx)) as c FROM t1 GROUP BY a' at line 1
|
||||
SELECT myfunc_int(fn(MIN(b)) xx) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
SELECT myfunc_int(test.fn(MIN(b)) xx) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
EXPLAIN EXTENDED SELECT myfunc_int(MIN(b) xx) as c FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select myfunc_int(min(`test`.`t1`.`b`) AS `xx`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`
|
||||
EXPLAIN EXTENDED SELECT test.fn(MIN(b)) as c FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`fn`(min(`test`.`t1`.`b`)) AS `c` from `test`.`t1` group by `test`.`t1`.`a`
|
||||
EXPLAIN EXTENDED SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select myfunc_int(`test`.`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`
|
||||
EXPLAIN EXTENDED SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select myfunc_int(`test`.`fn`(min(`test`.`t1`.`b`)) AS `test.fn(MIN(b))`) AS `c` from `test`.`t1` group by `test`.`t1`.`a`
|
||||
SELECT myfunc_int(MIN(b) xx) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
SELECT test.fn(MIN(b)) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a;
|
||||
c
|
||||
1
|
||||
2
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
DROP FUNCTION fn;
|
||||
End of 5.0 tests.
|
||||
DROP FUNCTION metaphon;
|
||||
DROP FUNCTION myfunc_double;
|
||||
|
Reference in New Issue
Block a user