mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/tmp_merge-5.0-opt-mysql client/mysql.cc: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/func_str.result: Auto merged mysql-test/t/date_formats.test: Auto merged mysql-test/t/func_str.test: Auto merged mysql-test/t/udf.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/item_strfunc.cc: Auto merged sql/mysql_priv.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/time.cc: Auto merged mysql-test/r/sp.result: Manual merge mysql-test/t/sp.test: Manual merge
This commit is contained in:
commit
c102fe94ad
47 changed files with 955 additions and 65 deletions
|
@ -452,7 +452,7 @@ t2 CREATE TABLE `t2` (
|
|||
`ifnull(h,h)` decimal(5,4) default NULL,
|
||||
`ifnull(i,i)` year(4) default NULL,
|
||||
`ifnull(j,j)` date default NULL,
|
||||
`ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ifnull(k,k)` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||
`ifnull(l,l)` datetime default NULL,
|
||||
`ifnull(m,m)` varchar(1) default NULL,
|
||||
`ifnull(n,n)` varchar(3) default NULL,
|
||||
|
|
|
@ -641,3 +641,16 @@ select charset(group_concat(c1 order by c2)) from t1;
|
|||
charset(group_concat(c1 order by c2))
|
||||
latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
|
||||
SET GROUP_CONCAT_MAX_LEN = 20000000;
|
||||
INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
SELECT a, CHAR_LENGTH(b) FROM t1;
|
||||
a CHAR_LENGTH(b)
|
||||
1 120000
|
||||
2 120000
|
||||
SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
|
||||
CHAR_LENGTH( GROUP_CONCAT(b) )
|
||||
240001
|
||||
SET GROUP_CONCAT_MAX_LEN = 1024;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -988,3 +988,14 @@ SUM(a)
|
|||
6
|
||||
DROP TABLE t1;
|
||||
set div_precision_increment= @sav_dpi;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t1 VALUES (1,1), (2,2);
|
||||
CREATE TABLE t2 (a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t2 VALUES (1,1), (3,3);
|
||||
SELECT SQL_NO_CACHE
|
||||
(SELECT SUM(c.a) FROM t1 ttt, t2 ccc
|
||||
WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid
|
||||
FROM t1 t, t2 c WHERE t.a = c.b;
|
||||
minid
|
||||
NULL
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -1056,6 +1056,34 @@ a c
|
|||
abc abc abc
|
||||
xyz xyz xyz
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (s varchar(10));
|
||||
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > _latin1'ab')
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
|
||||
DROP TABLE t1;
|
||||
End of 4.1 tests
|
||||
create table t1 (d decimal default null);
|
||||
insert into t1 values (null);
|
||||
|
|
|
@ -796,3 +796,28 @@ aaa
|
|||
show warnings;
|
||||
Level Code Message
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a));
|
||||
INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'),
|
||||
(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France');
|
||||
CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b));
|
||||
INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25),
|
||||
(17,25), (10,54), (5,62),(3,68);
|
||||
CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1;
|
||||
explain
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index b b 2 NULL 10 Using index
|
||||
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 1 test.t2.b 1
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
a b real_b
|
||||
1 ----- -----
|
||||
6 Allemagne Allemagne
|
||||
17 Autriche Autriche
|
||||
25 Belgique Belgique
|
||||
54 Danemark Danemark
|
||||
62 Espagne Espagne
|
||||
68 France France
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -2099,3 +2099,46 @@ SOUTH EAST SOUTH EAST
|
|||
SOUTH WEST SOUTH WEST
|
||||
WESTERN WESTERN
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id1 INT, id2 INT);
|
||||
CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);
|
||||
CREATE TABLE t3 (id3 INT, id4 INT);
|
||||
CREATE TABLE t4 (id4 INT);
|
||||
CREATE TABLE t5 (id5 INT, id6 INT);
|
||||
CREATE TABLE t6 (id6 INT);
|
||||
INSERT INTO t1 VALUES(1,1);
|
||||
INSERT INTO t2 VALUES(1,1,1);
|
||||
INSERT INTO t3 VALUES(1,1);
|
||||
INSERT INTO t4 VALUES(1);
|
||||
INSERT INTO t5 VALUES(1,1);
|
||||
INSERT INTO t6 VALUES(1);
|
||||
SELECT * FROM
|
||||
t1
|
||||
NATURAL JOIN
|
||||
(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
|
||||
id2 id1 id3 id5 id4 id3 id6 id5
|
||||
1 1 1 1 1 1 1 1
|
||||
SELECT * FROM
|
||||
t1
|
||||
NATURAL JOIN
|
||||
(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
|
||||
id2 id1 id4 id3 id6 id5 id3 id5
|
||||
1 1 1 1 1 1 1 1
|
||||
SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
|
||||
id2 id1 id3 id4 id6 id5 id3 id5
|
||||
1 1 1 1 1 1 1 1
|
||||
SELECT * FROM
|
||||
(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
|
||||
NATURAL JOIN
|
||||
t1;
|
||||
id2 id3 id5 id4 id3 id6 id5 id1
|
||||
1 1 1 1 1 1 1 1
|
||||
SELECT * FROM
|
||||
(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
|
||||
NATURAL JOIN
|
||||
t1;
|
||||
id2 id3 id5 id4 id3 id6 id5 id1
|
||||
1 1 1 1 1 1 1 1
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6;
|
||||
|
|
|
@ -1170,3 +1170,73 @@ f1()
|
|||
DROP FUNCTION f1;
|
||||
DROP PROCEDURE p1;
|
||||
DROP USER mysql_bug20230@localhost;
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = t.table_schema AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = 'information_schema' AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
table_name column_name
|
||||
CHARACTER_SETS CHARACTER_SET_NAME
|
||||
COLLATIONS COLLATION_NAME
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
|
||||
COLUMNS TABLE_SCHEMA
|
||||
COLUMN_PRIVILEGES TABLE_SCHEMA
|
||||
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
|
||||
ROUTINES ROUTINE_SCHEMA
|
||||
SCHEMATA SCHEMA_NAME
|
||||
SCHEMA_PRIVILEGES TABLE_SCHEMA
|
||||
STATISTICS TABLE_SCHEMA
|
||||
TABLES TABLE_SCHEMA
|
||||
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
|
||||
TABLE_PRIVILEGES TABLE_SCHEMA
|
||||
TRIGGERS TRIGGER_SCHEMA
|
||||
USER_PRIVILEGES GRANTEE
|
||||
VIEWS TABLE_SCHEMA
|
||||
SELECT MAX(table_name) FROM information_schema.tables;
|
||||
MAX(table_name)
|
||||
VIEWS
|
||||
SELECT table_name from information_schema.tables
|
||||
WHERE table_name=(SELECT MAX(table_name)
|
||||
FROM information_schema.tables);
|
||||
table_name
|
||||
VIEWS
|
||||
|
|
|
@ -1473,8 +1473,8 @@ Error 1146 Table 'test.t4' doesn't exist
|
|||
drop table t1,t2,t3;
|
||||
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
|
||||
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
|
||||
select name2 from t1 union all select name from t1 union all select id from t1;
|
||||
name2
|
||||
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
|
||||
trim(name2)
|
||||
fff
|
||||
sss
|
||||
ttt
|
||||
|
|
|
@ -2736,6 +2736,81 @@ SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
|
|||
i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')
|
||||
0 1 1 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
|
||||
CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
|
||||
INSERT INTO t2 VALUES (1,NULL), (2,10);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index b b 5 NULL 2 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
a b a b
|
||||
1 NULL 1 1
|
||||
1 NULL 2 1
|
||||
1 NULL 4 10
|
||||
2 10 4 10
|
||||
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index b b 5 NULL 2 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
a b a b
|
||||
1 NULL 1 1
|
||||
1 NULL 2 1
|
||||
1 NULL 4 10
|
||||
2 10 4 10
|
||||
DROP TABLE IF EXISTS t1,t2;
|
||||
CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
|
||||
CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
|
||||
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
|
||||
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
|
||||
explain select max(key1) from t1 where key1 <= 0.6158;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select max(key2) from t2 where key2 <= 1.6158;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select min(key1) from t1 where key1 >= 0.3762;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select min(key2) from t2 where key2 >= 1.3762;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select max(key1), min(key2) from t1, t2
|
||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.61580002307892
|
||||
select max(key2) from t2 where key2 <= 1.6158;
|
||||
max(key2)
|
||||
1.6158000230789
|
||||
select min(key1) from t1 where key1 >= 0.3762;
|
||||
min(key1)
|
||||
0.37619999051094
|
||||
select min(key2) from t2 where key2 >= 1.3762;
|
||||
min(key2)
|
||||
1.3761999607086
|
||||
select max(key1), min(key2) from t1, t2
|
||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||
max(key1) min(key2)
|
||||
0.61580002307892 1.3761999607086
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
0.61580002307892
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
0.37619999051094
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
|
||||
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
|
||||
|
|
|
@ -5057,6 +5057,25 @@ concat('data was: /', var1, '/')
|
|||
data was: /1/
|
||||
drop table t3|
|
||||
drop procedure bug15217|
|
||||
drop procedure if exists bug19862|
|
||||
CREATE TABLE t11 (a INT)|
|
||||
CREATE TABLE t12 (a INT)|
|
||||
CREATE FUNCTION bug19862(x INT) RETURNS INT
|
||||
BEGIN
|
||||
INSERT INTO t11 VALUES (x);
|
||||
RETURN x+1;
|
||||
END|
|
||||
INSERT INTO t12 VALUES (1), (2)|
|
||||
SELECT bug19862(a) FROM t12 ORDER BY 1|
|
||||
bug19862(a)
|
||||
2
|
||||
3
|
||||
SELECT * FROM t11|
|
||||
a
|
||||
1
|
||||
2
|
||||
DROP TABLE t11, t12|
|
||||
DROP FUNCTION bug19862|
|
||||
drop table if exists t3|
|
||||
drop database if exists mysqltest1|
|
||||
create table t3 (a int)|
|
||||
|
|
|
@ -2888,6 +2888,33 @@ select 1 from dual where 1 < any (select 2 from dual);
|
|||
select 1 from dual where 1 < all (select 2 from dual where 1!=1);
|
||||
1
|
||||
1
|
||||
create table t1 (s1 char);
|
||||
insert into t1 values (1),(2);
|
||||
select * from t1 where (s1 < any (select s1 from t1));
|
||||
s1
|
||||
1
|
||||
select * from t1 where not (s1 < any (select s1 from t1));
|
||||
s1
|
||||
2
|
||||
select * from t1 where (s1 < ALL (select s1+1 from t1));
|
||||
s1
|
||||
1
|
||||
select * from t1 where not(s1 < ALL (select s1+1 from t1));
|
||||
s1
|
||||
2
|
||||
select * from t1 where (s1+1 = ANY (select s1 from t1));
|
||||
s1
|
||||
1
|
||||
select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
|
||||
s1
|
||||
2
|
||||
select * from t1 where (s1 = ALL (select s1/s1 from t1));
|
||||
s1
|
||||
1
|
||||
select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
|
||||
s1
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (df decimal(5,1));
|
||||
insert into t1 values(1.1);
|
||||
insert into t1 values(2.2);
|
||||
|
|
|
@ -132,3 +132,15 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where
|
||||
6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 func 1 Using index; Using where
|
||||
drop table t1, t2, t3, t4;
|
||||
CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t2 VALUES (1);
|
||||
CREATE TABLE t3 (a int(10), b int(10), c int(10),
|
||||
PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t3 VALUES (1,2,1);
|
||||
SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a
|
||||
and t2.a='1' AND t1.a=t3.b) > 0;
|
||||
a
|
||||
2
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
|
|
@ -93,6 +93,12 @@ NULL
|
|||
0R
|
||||
FR
|
||||
DROP TABLE bug19904;
|
||||
create table t1(f1 int);
|
||||
insert into t1 values(1),(2);
|
||||
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;
|
||||
End of 5.0 tests.
|
||||
DROP FUNCTION metaphon;
|
||||
DROP FUNCTION myfunc_double;
|
||||
|
|
|
@ -691,9 +691,9 @@ t1 CREATE TABLE `t1` (
|
|||
`da` datetime default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT dt from t2 UNION select sc from t2;
|
||||
select * from t1;
|
||||
dt
|
||||
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
|
||||
select trim(dt) from t1;
|
||||
trim(dt)
|
||||
1972-10-22 11:50:00
|
||||
testc
|
||||
show create table t1;
|
||||
|
@ -732,7 +732,7 @@ tetetetetest
|
|||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`dt` longblob
|
||||
`dt` blob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT sv from t2 UNION select b from t2;
|
||||
|
@ -743,7 +743,7 @@ tetetetetest
|
|||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`sv` longblob
|
||||
`sv` blob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
|
||||
|
@ -755,7 +755,7 @@ tetetetetest
|
|||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` longblob
|
||||
`i` blob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT sv from t2 UNION select tx from t2;
|
||||
|
@ -766,7 +766,7 @@ teeeeeeeeeeeest
|
|||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`sv` longtext
|
||||
`sv` text
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT b from t2 UNION select tx from t2;
|
||||
|
@ -777,7 +777,7 @@ teeeeeeeeeeeest
|
|||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` longblob
|
||||
`b` blob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
create table t1 select 1 union select -1;
|
||||
|
@ -1306,6 +1306,21 @@ id
|
|||
5
|
||||
99
|
||||
drop table t1;
|
||||
create table t1(f1 char(1), f2 char(5), f3 binary(1), f4 binary(5), f5 timestamp, f6 varchar(1) character set utf8 collate utf8_general_ci, f7 text);
|
||||
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`f1` char(1) default NULL,
|
||||
`f2` char(5) default NULL,
|
||||
`f3` binary(1) default NULL,
|
||||
`f4` binary(5) default NULL,
|
||||
`f5` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||
`f6` varchar(1) character set utf8 default NULL,
|
||||
`f7` text,
|
||||
`f8` text character set utf8
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1, t2;
|
||||
(select avg(1)) union (select avg(1)) union (select avg(1)) union
|
||||
(select avg(1)) union (select avg(1)) union (select avg(1)) union
|
||||
(select avg(1)) union (select avg(1)) union (select avg(1)) union
|
||||
|
|
|
@ -2774,3 +2774,49 @@ Field Type Null Key Default Extra
|
|||
COALESCE(i,j) int(11) YES NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (s varchar(10));
|
||||
INSERT INTO t1 VALUES ('yadda'), ('yady');
|
||||
SELECT TRIM(BOTH 'y' FROM s) FROM t1;
|
||||
TRIM(BOTH 'y' FROM s)
|
||||
adda
|
||||
ad
|
||||
CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
TRIM(BOTH 'y' FROM s)
|
||||
adda
|
||||
ad
|
||||
DROP VIEW v1;
|
||||
SELECT TRIM(LEADING 'y' FROM s) FROM t1;
|
||||
TRIM(LEADING 'y' FROM s)
|
||||
adda
|
||||
ady
|
||||
CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
TRIM(LEADING 'y' FROM s)
|
||||
adda
|
||||
ady
|
||||
DROP VIEW v1;
|
||||
SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
|
||||
TRIM(TRAILING 'y' FROM s)
|
||||
yadda
|
||||
yad
|
||||
CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
TRIM(TRAILING 'y' FROM s)
|
||||
yadda
|
||||
yad
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (s1 char);
|
||||
INSERT INTO t1 VALUES ('Z');
|
||||
CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
|
||||
CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
|
||||
INSERT INTO v1 (col) VALUES ('b');
|
||||
INSERT INTO v2 (col) VALUES ('c');
|
||||
SELECT s1 FROM t1;
|
||||
s1
|
||||
Z
|
||||
b
|
||||
c
|
||||
DROP VIEW v1, v2;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -433,3 +433,17 @@ create table t1 (c1 varchar(10), c2 int);
|
|||
select charset(group_concat(c1 order by c2)) from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #16712: group_concat returns odd string instead of intended result
|
||||
#
|
||||
CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
|
||||
|
||||
SET GROUP_CONCAT_MAX_LEN = 20000000;
|
||||
|
||||
INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
|
||||
SELECT a, CHAR_LENGTH(b) FROM t1;
|
||||
SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
|
||||
SET GROUP_CONCAT_MAX_LEN = 1024;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -660,3 +660,18 @@ SELECT SUM(a) FROM t1 GROUP BY b/c;
|
|||
DROP TABLE t1;
|
||||
set div_precision_increment= @sav_dpi;
|
||||
|
||||
#
|
||||
# Bug #20868: Client connection is broken on SQL query error
|
||||
#
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t1 VALUES (1,1), (2,2);
|
||||
|
||||
CREATE TABLE t2 (a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t2 VALUES (1,1), (3,3);
|
||||
|
||||
SELECT SQL_NO_CACHE
|
||||
(SELECT SUM(c.a) FROM t1 ttt, t2 ccc
|
||||
WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid
|
||||
FROM t1 t, t2 c WHERE t.a = c.b;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -706,6 +706,21 @@ SELECT a, CONCAT(a,' ',a) AS c FROM t1
|
|||
INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#17526: WRONG PRINT for TRIM FUNCTION with two arguments
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (s varchar(10));
|
||||
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
|
||||
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
|
||||
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 4.1 tests
|
||||
|
||||
|
|
|
@ -632,3 +632,26 @@ group by t1.c1;
|
|||
show warnings;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug #20466: a view is mixing data when there's a trigger on the table
|
||||
#
|
||||
CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a));
|
||||
|
||||
INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'),
|
||||
(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France');
|
||||
|
||||
CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b));
|
||||
|
||||
INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25),
|
||||
(17,25), (10,54), (5,62),(3,68);
|
||||
|
||||
CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1;
|
||||
|
||||
explain
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
|
||||
where t2.b=v1.a GROUP BY t2.b;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -746,3 +746,51 @@ EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
|||
SELECT DISTINCT a,a FROM t1 ORDER BY a;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #21007: NATURAL JOIN (any JOIN (2 x NATURAL JOIN)) crashes the server
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id1 INT, id2 INT);
|
||||
CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);
|
||||
CREATE TABLE t3 (id3 INT, id4 INT);
|
||||
CREATE TABLE t4 (id4 INT);
|
||||
CREATE TABLE t5 (id5 INT, id6 INT);
|
||||
CREATE TABLE t6 (id6 INT);
|
||||
|
||||
INSERT INTO t1 VALUES(1,1);
|
||||
INSERT INTO t2 VALUES(1,1,1);
|
||||
INSERT INTO t3 VALUES(1,1);
|
||||
INSERT INTO t4 VALUES(1);
|
||||
INSERT INTO t5 VALUES(1,1);
|
||||
INSERT INTO t6 VALUES(1);
|
||||
|
||||
-- original bug query
|
||||
SELECT * FROM
|
||||
t1
|
||||
NATURAL JOIN
|
||||
(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
|
||||
|
||||
-- inner join swapped
|
||||
SELECT * FROM
|
||||
t1
|
||||
NATURAL JOIN
|
||||
(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
|
||||
|
||||
-- one join less, no ON cond
|
||||
SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
|
||||
|
||||
-- wrong error message: 'id2' - ambiguous column
|
||||
SELECT * FROM
|
||||
(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
|
||||
ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
|
||||
NATURAL JOIN
|
||||
t1;
|
||||
SELECT * FROM
|
||||
(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
|
||||
NATURAL JOIN
|
||||
t1;
|
||||
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6;
|
||||
|
|
|
@ -887,4 +887,47 @@ DROP FUNCTION f1;
|
|||
DROP PROCEDURE p1;
|
||||
DROP USER mysql_bug20230@localhost;
|
||||
|
||||
#
|
||||
# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
|
||||
#
|
||||
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = t.table_schema AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
information_schema.columns c1
|
||||
ON t.table_schema = c1.table_schema AND
|
||||
t.table_name = c1.table_name
|
||||
WHERE t.table_schema = 'information_schema' AND
|
||||
c1.ordinal_position =
|
||||
( SELECT COALESCE(MIN(c2.ordinal_position),1)
|
||||
FROM information_schema.columns c2
|
||||
WHERE c2.table_schema = 'information_schema' AND
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
);
|
||||
|
||||
#
|
||||
# Bug#21231: query with a simple non-correlated subquery over
|
||||
# INFORMARTION_SCHEMA.TABLES
|
||||
#
|
||||
|
||||
SELECT MAX(table_name) FROM information_schema.tables;
|
||||
SELECT table_name from information_schema.tables
|
||||
WHERE table_name=(SELECT MAX(table_name)
|
||||
FROM information_schema.tables);
|
||||
|
||||
# End of 5.0 tests.
|
||||
|
|
|
@ -1079,7 +1079,7 @@ drop table t1,t2,t3;
|
|||
#
|
||||
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
|
||||
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
|
||||
select name2 from t1 union all select name from t1 union all select id from t1;
|
||||
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
|
|
|
@ -2304,6 +2304,51 @@ INSERT INTO t1 VALUES (10);
|
|||
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #21019: First result of SELECT COUNT(*) different than consecutive runs
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
|
||||
|
||||
CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
|
||||
INSERT INTO t2 VALUES (1,NULL), (2,10);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
|
||||
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
|
||||
DROP TABLE IF EXISTS t1,t2;
|
||||
#
|
||||
# Bug #20954 "avg(keyval) retuns 0.38 but max(keyval) returns an empty set"
|
||||
#
|
||||
--disable_ps_protocol
|
||||
CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
|
||||
CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
|
||||
INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
|
||||
INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
|
||||
|
||||
explain select max(key1) from t1 where key1 <= 0.6158;
|
||||
explain select max(key2) from t2 where key2 <= 1.6158;
|
||||
explain select min(key1) from t1 where key1 >= 0.3762;
|
||||
explain select min(key2) from t2 where key2 >= 1.3762;
|
||||
explain select max(key1), min(key2) from t1, t2
|
||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
select max(key2) from t2 where key2 <= 1.6158;
|
||||
select min(key1) from t1 where key1 >= 0.3762;
|
||||
select min(key2) from t2 where key2 >= 1.3762;
|
||||
select max(key1), min(key2) from t1, t2
|
||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
--enable_ps_protocol
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
|
|
|
@ -5963,6 +5963,23 @@ drop table t3|
|
|||
drop procedure bug15217|
|
||||
|
||||
#
|
||||
# BUG#19862: Sort with filesort by function evaluates function twice
|
||||
#
|
||||
--disable_warnings
|
||||
drop procedure if exists bug19862|
|
||||
--enable_warnings
|
||||
CREATE TABLE t11 (a INT)|
|
||||
CREATE TABLE t12 (a INT)|
|
||||
CREATE FUNCTION bug19862(x INT) RETURNS INT
|
||||
BEGIN
|
||||
INSERT INTO t11 VALUES (x);
|
||||
RETURN x+1;
|
||||
END|
|
||||
INSERT INTO t12 VALUES (1), (2)|
|
||||
SELECT bug19862(a) FROM t12 ORDER BY 1|
|
||||
SELECT * FROM t11|
|
||||
DROP TABLE t11, t12|
|
||||
DROP FUNCTION bug19862|
|
||||
# Bug#21002 "Derived table not selecting from a "real" table fails in JOINs"
|
||||
#
|
||||
# A regression caused by the fix for Bug#18444: for derived tables we should
|
||||
|
|
|
@ -1851,6 +1851,24 @@ select 1 from dual where 2 > any (select 1);
|
|||
select 1 from dual where 2 > all (select 1);
|
||||
select 1 from dual where 1 < any (select 2 from dual);
|
||||
select 1 from dual where 1 < all (select 2 from dual where 1!=1);
|
||||
|
||||
# BUG#20975 Wrong query results for subqueries within NOT
|
||||
create table t1 (s1 char);
|
||||
insert into t1 values (1),(2);
|
||||
|
||||
select * from t1 where (s1 < any (select s1 from t1));
|
||||
select * from t1 where not (s1 < any (select s1 from t1));
|
||||
|
||||
select * from t1 where (s1 < ALL (select s1+1 from t1));
|
||||
select * from t1 where not(s1 < ALL (select s1+1 from t1));
|
||||
|
||||
select * from t1 where (s1+1 = ANY (select s1 from t1));
|
||||
select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
|
||||
|
||||
select * from t1 where (s1 = ALL (select s1/s1 from t1));
|
||||
select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
|
||||
drop table t1;
|
||||
# End of 4.1 tests
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
|
|
|
@ -150,3 +150,21 @@ EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JO
|
|||
|
||||
drop table t1, t2, t3, t4;
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
# Bug #20792: Incorrect results from aggregate subquery
|
||||
#
|
||||
CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t2 VALUES (1);
|
||||
|
||||
CREATE TABLE t3 (a int(10), b int(10), c int(10),
|
||||
PRIMARY KEY (a)) Engine=InnoDB;
|
||||
INSERT INTO t3 VALUES (1,2,1);
|
||||
|
||||
SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a
|
||||
and t2.a='1' AND t1.a=t3.b) > 0;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
|
|
@ -109,6 +109,13 @@ SELECT myfunc_double(n) AS f FROM bug19904;
|
|||
SELECT metaphon(v) AS f FROM bug19904;
|
||||
DROP TABLE bug19904;
|
||||
|
||||
#
|
||||
# Bug#19862: Sort with filesort by function evaluates function twice
|
||||
#
|
||||
create table t1(f1 int);
|
||||
insert into t1 values(1),(2);
|
||||
explain select myfunc_int(f1) from t1 order by 1;
|
||||
drop table t1;
|
||||
--echo End of 5.0 tests.
|
||||
|
||||
#
|
||||
|
|
|
@ -390,8 +390,8 @@ create table t1 SELECT da from t2 UNION select dt from t2;
|
|||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 SELECT dt from t2 UNION select sc from t2;
|
||||
select * from t1;
|
||||
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
|
||||
select trim(dt) from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 SELECT dt from t2 UNION select sv from t2;
|
||||
|
@ -794,6 +794,14 @@ drop table t1;
|
|||
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
# Bug#12185: Data type aggregation may produce wrong result
|
||||
#
|
||||
create table t1(f1 char(1), f2 char(5), f3 binary(1), f4 binary(5), f5 timestamp, f6 varchar(1) character set utf8 collate utf8_general_ci, f7 text);
|
||||
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
|
||||
show create table t2;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Bug#18175: Union select over 129 tables with a sum function fails.
|
||||
#
|
||||
|
|
|
@ -2643,3 +2643,46 @@ DESCRIBE t2;
|
|||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug #17526: views with TRIM functions
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (s varchar(10));
|
||||
INSERT INTO t1 VALUES ('yadda'), ('yady');
|
||||
|
||||
SELECT TRIM(BOTH 'y' FROM s) FROM t1;
|
||||
CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
DROP VIEW v1;
|
||||
|
||||
SELECT TRIM(LEADING 'y' FROM s) FROM t1;
|
||||
CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
DROP VIEW v1;
|
||||
|
||||
SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
|
||||
CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
|
||||
SELECT * FROM v1;
|
||||
DROP VIEW v1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE
|
||||
# clause is called
|
||||
#
|
||||
CREATE TABLE t1 (s1 char);
|
||||
INSERT INTO t1 VALUES ('Z');
|
||||
|
||||
CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
|
||||
|
||||
CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
|
||||
|
||||
# either of these statements will cause crash
|
||||
INSERT INTO v1 (col) VALUES ('b');
|
||||
INSERT INTO v2 (col) VALUES ('c');
|
||||
|
||||
SELECT s1 FROM t1;
|
||||
DROP VIEW v1, v2;
|
||||
DROP TABLE t1;
|
||||
|
|
18
sql/field.cc
18
sql/field.cc
|
@ -4387,6 +4387,24 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg,
|
|||
}
|
||||
|
||||
|
||||
Field_timestamp::Field_timestamp(bool maybe_null_arg,
|
||||
const char *field_name_arg,
|
||||
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||
:Field_str((char*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0,
|
||||
NONE, field_name_arg, table_arg, cs)
|
||||
{
|
||||
/* For 4.0 MYD and 4.0 InnoDB compatibility */
|
||||
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
|
||||
if (table && !table->timestamp_field &&
|
||||
unireg_check != NONE)
|
||||
{
|
||||
/* This timestamp has auto-update */
|
||||
table->timestamp_field= this;
|
||||
flags|=TIMESTAMP_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Get auto-set type for TIMESTAMP field.
|
||||
|
||||
|
|
17
sql/field.h
17
sql/field.h
|
@ -780,6 +780,8 @@ public:
|
|||
enum utype unireg_check_arg, const char *field_name_arg,
|
||||
struct st_table *table_arg,
|
||||
CHARSET_INFO *cs);
|
||||
Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
|
||||
struct st_table *table_arg, CHARSET_INFO *cs);
|
||||
enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;}
|
||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
|
||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||
|
@ -1128,6 +1130,21 @@ public:
|
|||
{
|
||||
flags|= BLOB_FLAG;
|
||||
}
|
||||
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
|
||||
struct st_table *table_arg, CHARSET_INFO *cs, bool set_packlength)
|
||||
:Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
|
||||
NONE, field_name_arg, table_arg, cs)
|
||||
{
|
||||
flags|= BLOB_FLAG;
|
||||
packlength= 4;
|
||||
if (set_packlength)
|
||||
{
|
||||
uint32 char_length= len_arg/cs->mbmaxlen;
|
||||
packlength= char_length <= 255 ? 1 :
|
||||
char_length <= 65535 ? 2 :
|
||||
char_length <= 16777215 ? 3 : 4;
|
||||
}
|
||||
}
|
||||
enum_field_types type() const { return FIELD_TYPE_BLOB;}
|
||||
enum ha_base_keytype key_type() const
|
||||
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
|
||||
|
|
13
sql/item.cc
13
sql/item.cc
|
@ -3903,7 +3903,9 @@ Field *Item::make_string_field(TABLE *table)
|
|||
if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
|
||||
return new Field_blob(max_length, maybe_null, name, table,
|
||||
collation.collation);
|
||||
if (max_length > 0)
|
||||
/* Item_type_holder holds the exact type, do not change it */
|
||||
if (max_length > 0 &&
|
||||
(type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING))
|
||||
return new Field_varstring(max_length, maybe_null, name, table,
|
||||
collation.collation);
|
||||
return new Field_string(max_length, maybe_null, name, table,
|
||||
|
@ -3967,6 +3969,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
|
|||
case MYSQL_TYPE_TIME:
|
||||
return new Field_time(maybe_null, name, table, &my_charset_bin);
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
return new Field_timestamp(maybe_null, name, table, &my_charset_bin);
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
return new Field_datetime(maybe_null, name, table, &my_charset_bin);
|
||||
case MYSQL_TYPE_YEAR:
|
||||
|
@ -3990,7 +3993,11 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table)
|
|||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_GEOMETRY:
|
||||
return new Field_blob(max_length, maybe_null, name, table,
|
||||
if (this->type() == Item::TYPE_HOLDER)
|
||||
return new Field_blob(max_length, maybe_null, name, table,
|
||||
collation.collation, 1);
|
||||
else
|
||||
return new Field_blob(max_length, maybe_null, name, table,
|
||||
collation.collation);
|
||||
break; // Blob handled outside of case
|
||||
}
|
||||
|
@ -6151,7 +6158,7 @@ uint32 Item_type_holder::display_length(Item *item)
|
|||
case MYSQL_TYPE_DOUBLE:
|
||||
return 53;
|
||||
case MYSQL_TYPE_NULL:
|
||||
return 4;
|
||||
return 0;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
return 20;
|
||||
case MYSQL_TYPE_INT24:
|
||||
|
|
|
@ -752,6 +752,7 @@ public:
|
|||
virtual bool find_item_in_field_list_processor(byte *arg) { return 0; }
|
||||
virtual bool change_context_processor(byte *context) { return 0; }
|
||||
virtual bool reset_query_id_processor(byte *query_id) { return 0; }
|
||||
virtual bool is_expensive_processor(byte *arg) { return 0; }
|
||||
|
||||
virtual Item *equal_fields_propagator(byte * arg) { return this; }
|
||||
virtual Item *set_no_const_sub(byte *arg) { return this; }
|
||||
|
|
|
@ -3656,6 +3656,28 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
|
|||
}
|
||||
|
||||
|
||||
Item *Item_func_nop_all::neg_transformer(THD *thd)
|
||||
{
|
||||
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
|
||||
Item_func_not_all *new_item= new Item_func_not_all(args[0]);
|
||||
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
|
||||
allany->func= allany->func_creator(FALSE);
|
||||
allany->all= !allany->all;
|
||||
allany->upper_item= new_item;
|
||||
return new_item;
|
||||
}
|
||||
|
||||
Item *Item_func_not_all::neg_transformer(THD *thd)
|
||||
{
|
||||
/* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */
|
||||
Item_func_nop_all *new_item= new Item_func_nop_all(args[0]);
|
||||
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
|
||||
allany->all= !allany->all;
|
||||
allany->func= allany->func_creator(TRUE);
|
||||
allany->upper_item= new_item;
|
||||
return new_item;
|
||||
}
|
||||
|
||||
Item *Item_func_eq::negated_item() /* a = b -> a != b */
|
||||
{
|
||||
return new Item_func_ne(args[0], args[1]);
|
||||
|
|
|
@ -311,6 +311,7 @@ public:
|
|||
void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
|
||||
void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
|
||||
bool empty_underlying_subquery();
|
||||
Item *neg_transformer(THD *thd);
|
||||
};
|
||||
|
||||
|
||||
|
@ -321,6 +322,7 @@ public:
|
|||
Item_func_nop_all(Item *a) :Item_func_not_all(a) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "<nop>"; }
|
||||
Item *neg_transformer(THD *thd);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -398,6 +398,13 @@ Field *Item_func::tmp_table_field(TABLE *t_arg)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool Item_func::is_expensive_processor(byte *arg)
|
||||
{
|
||||
return is_expensive();
|
||||
}
|
||||
|
||||
|
||||
my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed);
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
NOT_FUNC, NOT_ALL_FUNC,
|
||||
NOW_FUNC, TRIG_COND_FUNC,
|
||||
GUSERVAR_FUNC, COLLATE_FUNC,
|
||||
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP };
|
||||
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC };
|
||||
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
|
||||
OPTIMIZE_EQUAL };
|
||||
enum Type type() const { return FUNC_ITEM; }
|
||||
|
@ -189,6 +189,8 @@ public:
|
|||
Item *transform(Item_transformer transformer, byte *arg);
|
||||
void traverse_cond(Cond_traverser traverser,
|
||||
void * arg, traverse_order order);
|
||||
bool is_expensive_processor(byte *arg);
|
||||
virtual bool is_expensive() { return 0; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -933,6 +935,7 @@ public:
|
|||
Item_udf_func(udf_func *udf_arg, List<Item> &list)
|
||||
:Item_func(list), udf(udf_arg) {}
|
||||
const char *func_name() const { return udf.name(); }
|
||||
enum Functype functype() const { return UDF_FUNC; }
|
||||
bool fix_fields(THD *thd, Item **ref)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 0);
|
||||
|
@ -945,6 +948,7 @@ public:
|
|||
void cleanup();
|
||||
Item_result result_type () const { return udf.result_type(); }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool is_expensive() { return 1; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -1473,6 +1477,7 @@ public:
|
|||
virtual enum Functype functype() const { return FUNC_SP; }
|
||||
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
bool is_expensive() { return 1; }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1503,6 +1503,23 @@ void Item_func_trim::fix_length_and_dec()
|
|||
}
|
||||
}
|
||||
|
||||
void Item_func_trim::print(String *str)
|
||||
{
|
||||
if (arg_count == 1)
|
||||
{
|
||||
Item_func::print(str);
|
||||
return;
|
||||
}
|
||||
str->append(Item_func_trim::func_name());
|
||||
str->append('(');
|
||||
str->append(mode_name());
|
||||
str->append(' ');
|
||||
args[1]->print(str);
|
||||
str->append(STRING_WITH_LEN(" from "));
|
||||
args[0]->print(str);
|
||||
str->append(')');
|
||||
}
|
||||
|
||||
|
||||
/* Item_func_password */
|
||||
|
||||
|
|
|
@ -233,6 +233,8 @@ public:
|
|||
String *val_str(String *);
|
||||
void fix_length_and_dec();
|
||||
const char *func_name() const { return "trim"; }
|
||||
void print(String *str);
|
||||
virtual const char *mode_name() const { return "both"; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -243,6 +245,7 @@ public:
|
|||
Item_func_ltrim(Item *a) :Item_func_trim(a) {}
|
||||
String *val_str(String *);
|
||||
const char *func_name() const { return "ltrim"; }
|
||||
const char *mode_name() const { return "leading"; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -253,6 +256,7 @@ public:
|
|||
Item_func_rtrim(Item *a) :Item_func_trim(a) {}
|
||||
String *val_str(String *);
|
||||
const char *func_name() const { return "rtrim"; }
|
||||
const char *mode_name() const { return "trailing"; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -724,7 +728,7 @@ public:
|
|||
void fix_length_and_dec();
|
||||
bool eq(const Item *item, bool binary_cmp) const;
|
||||
const char *func_name() const { return "collate"; }
|
||||
enum Functype func_type() const { return COLLATE_FUNC; }
|
||||
enum Functype functype() const { return COLLATE_FUNC; }
|
||||
void print(String *str);
|
||||
Item_field *filed_for_view_update()
|
||||
{
|
||||
|
|
|
@ -572,14 +572,14 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
|
|||
}
|
||||
|
||||
Item_allany_subselect::Item_allany_subselect(Item * left_exp,
|
||||
Comp_creator *fn,
|
||||
chooser_compare_func_creator fc,
|
||||
st_select_lex *select_lex,
|
||||
bool all_arg)
|
||||
:Item_in_subselect(), all(all_arg)
|
||||
:Item_in_subselect(), func_creator(fc), all(all_arg)
|
||||
{
|
||||
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
|
||||
left_expr= left_exp;
|
||||
func= fn;
|
||||
func= func_creator(all_arg);
|
||||
init(select_lex, new select_exists_subselect(this));
|
||||
max_columns= 1;
|
||||
abort_on_null= 0;
|
||||
|
|
|
@ -269,14 +269,13 @@ public:
|
|||
/* ALL/ANY/SOME subselect */
|
||||
class Item_allany_subselect :public Item_in_subselect
|
||||
{
|
||||
protected:
|
||||
Comp_creator *func;
|
||||
|
||||
public:
|
||||
chooser_compare_func_creator func_creator;
|
||||
Comp_creator *func;
|
||||
bool all;
|
||||
|
||||
Item_allany_subselect(Item * left_expr, Comp_creator *f,
|
||||
st_select_lex *select_lex, bool all);
|
||||
Item_allany_subselect(Item * left_expr, chooser_compare_func_creator fc,
|
||||
st_select_lex *select_lex, bool all);
|
||||
|
||||
// only ALL subquery has upper not
|
||||
subs_type substype() { return all?ALL_SUBS:ANY_SUBS; }
|
||||
|
|
|
@ -377,7 +377,13 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table,
|
|||
case INT_RESULT:
|
||||
return new Field_longlong(max_length,maybe_null,name,table,unsigned_flag);
|
||||
case STRING_RESULT:
|
||||
if (max_length/collation.collation->mbmaxlen > 255 && convert_blob_length)
|
||||
/*
|
||||
Make sure that the blob fits into a Field_varstring which has
|
||||
2-byte lenght.
|
||||
*/
|
||||
if (max_length/collation.collation->mbmaxlen > 255 &&
|
||||
max_length/collation.collation->mbmaxlen < UINT_MAX16 &&
|
||||
convert_blob_length)
|
||||
return new Field_varstring(convert_blob_length, maybe_null,
|
||||
name, table,
|
||||
collation.collation);
|
||||
|
|
|
@ -520,9 +520,11 @@ enum enum_var_type
|
|||
OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
|
||||
};
|
||||
class sys_var;
|
||||
class Comp_creator;
|
||||
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
|
||||
#include "item.h"
|
||||
extern my_decimal decimal_zero;
|
||||
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
|
||||
|
||||
/* sql_parse.cc */
|
||||
void free_items(Item *item);
|
||||
void cleanup_items(Item *item);
|
||||
|
|
|
@ -4041,36 +4041,48 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
|
|||
if (table_ref->nested_join)
|
||||
{
|
||||
List_iterator_fast<TABLE_LIST> nested_it(table_ref->nested_join->join_list);
|
||||
TABLE_LIST *cur_left_neighbor= nested_it++;
|
||||
TABLE_LIST *cur_right_neighbor= NULL;
|
||||
TABLE_LIST *same_level_left_neighbor= nested_it++;
|
||||
TABLE_LIST *same_level_right_neighbor= NULL;
|
||||
/* Left/right-most neighbors, possibly at higher levels in the join tree. */
|
||||
TABLE_LIST *real_left_neighbor, *real_right_neighbor;
|
||||
|
||||
while (cur_left_neighbor)
|
||||
while (same_level_left_neighbor)
|
||||
{
|
||||
TABLE_LIST *cur_table_ref= cur_left_neighbor;
|
||||
cur_left_neighbor= nested_it++;
|
||||
TABLE_LIST *cur_table_ref= same_level_left_neighbor;
|
||||
same_level_left_neighbor= nested_it++;
|
||||
/*
|
||||
The order of RIGHT JOIN operands is reversed in 'join list' to
|
||||
transform it into a LEFT JOIN. However, in this procedure we need
|
||||
the join operands in their lexical order, so below we reverse the
|
||||
join operands. Notice that this happens only in the first loop, and
|
||||
not in the second one, as in the second loop cur_left_neighbor == NULL.
|
||||
This is the correct behavior, because the second loop
|
||||
sets cur_table_ref reference correctly after the join operands are
|
||||
join operands. Notice that this happens only in the first loop,
|
||||
and not in the second one, as in the second loop
|
||||
same_level_left_neighbor == NULL.
|
||||
This is the correct behavior, because the second loop sets
|
||||
cur_table_ref reference correctly after the join operands are
|
||||
swapped in the first loop.
|
||||
*/
|
||||
if (cur_left_neighbor &&
|
||||
if (same_level_left_neighbor &&
|
||||
cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
|
||||
{
|
||||
/* This can happen only for JOIN ... ON. */
|
||||
DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
|
||||
swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
|
||||
swap_variables(TABLE_LIST*, same_level_left_neighbor, cur_table_ref);
|
||||
}
|
||||
|
||||
/*
|
||||
Pick the parent's left and right neighbors if there are no immediate
|
||||
neighbors at the same level.
|
||||
*/
|
||||
real_left_neighbor= (same_level_left_neighbor) ?
|
||||
same_level_left_neighbor : left_neighbor;
|
||||
real_right_neighbor= (same_level_right_neighbor) ?
|
||||
same_level_right_neighbor : right_neighbor;
|
||||
|
||||
if (cur_table_ref->nested_join &&
|
||||
store_top_level_join_columns(thd, cur_table_ref,
|
||||
cur_left_neighbor, cur_right_neighbor))
|
||||
real_left_neighbor, real_right_neighbor))
|
||||
goto err;
|
||||
cur_right_neighbor= cur_table_ref;
|
||||
same_level_right_neighbor= cur_table_ref;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4947,12 +4959,17 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
|
|||
bool ignore_errors)
|
||||
{
|
||||
List_iterator_fast<Item> f(fields),v(values);
|
||||
Item *value;
|
||||
Item *value, *fld;
|
||||
Item_field *field;
|
||||
DBUG_ENTER("fill_record");
|
||||
|
||||
while ((field=(Item_field*) f++))
|
||||
while ((fld= f++))
|
||||
{
|
||||
if (!(field= fld->filed_for_view_update()))
|
||||
{
|
||||
my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
value=v++;
|
||||
Field *rfield= field->field;
|
||||
TABLE *table= rfield->table;
|
||||
|
|
|
@ -7017,7 +7017,7 @@ Item * all_any_subquery_creator(Item *left_expr,
|
|||
return new Item_func_not(new Item_in_subselect(left_expr, select_lex));
|
||||
|
||||
Item_allany_subselect *it=
|
||||
new Item_allany_subselect(left_expr, (*cmp)(all), select_lex, all);
|
||||
new Item_allany_subselect(left_expr, cmp, select_lex, all);
|
||||
if (all)
|
||||
return it->upper_item= new Item_func_not_all(it); /* ALL */
|
||||
|
||||
|
|
|
@ -679,6 +679,25 @@ JOIN::optimize()
|
|||
DBUG_PRINT("info",("Select tables optimized away"));
|
||||
zero_result_cause= "Select tables optimized away";
|
||||
tables_list= 0; // All tables resolved
|
||||
/*
|
||||
Extract all table-independent conditions and replace the WHERE
|
||||
clause with them. All other conditions were computed by opt_sum_query
|
||||
and the MIN/MAX/COUNT function(s) have been replaced by constants,
|
||||
so there is no need to compute the whole WHERE clause again.
|
||||
Notice that make_cond_for_table() will always succeed to remove all
|
||||
computed conditions, because opt_sum_query() is applicable only to
|
||||
conjunctions.
|
||||
Preserve conditions for EXPLAIN.
|
||||
*/
|
||||
if (conds && !(thd->lex->describe & DESCRIBE_EXTENDED))
|
||||
{
|
||||
COND *table_independent_conds=
|
||||
make_cond_for_table(conds, PSEUDO_TABLE_BITS, 0);
|
||||
DBUG_EXECUTE("where",
|
||||
print_where(table_independent_conds,
|
||||
"where after opt_sum_query()"););
|
||||
conds= table_independent_conds;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tables_list)
|
||||
|
@ -1064,6 +1083,23 @@ JOIN::optimize()
|
|||
{
|
||||
need_tmp=1; simple_order=simple_group=0; // Force tmp table without sort
|
||||
}
|
||||
if (order)
|
||||
{
|
||||
/*
|
||||
Force using of tmp table if sorting by a SP or UDF function due to
|
||||
their expensive and probably non-deterministic nature.
|
||||
*/
|
||||
for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
|
||||
{
|
||||
Item *item= *tmp_order->item;
|
||||
if (item->walk(&Item::is_expensive_processor,(byte*)0))
|
||||
{
|
||||
/* Force tmp table without sort */
|
||||
need_tmp=1; simple_order=simple_group=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tmp_having= having;
|
||||
|
@ -2470,8 +2506,11 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
|
|||
/* field = expression OR field IS NULL */
|
||||
old->level= and_level;
|
||||
old->optimize= KEY_OPTIMIZE_REF_OR_NULL;
|
||||
/* Remember the NOT NULL value */
|
||||
if (old->val->is_null())
|
||||
/*
|
||||
Remember the NOT NULL value unless the value does not depend
|
||||
on other tables.
|
||||
*/
|
||||
if (!old->val->used_tables() && old->val->is_null())
|
||||
old->val= new_fields->val;
|
||||
/* The referred expression can be NULL: */
|
||||
old->null_rejecting= 0;
|
||||
|
@ -6174,10 +6213,16 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
used only in JOIN::clear
|
||||
*/
|
||||
static void clear_tables(JOIN *join)
|
||||
{
|
||||
for (uint i=0 ; i < join->tables ; i++)
|
||||
/*
|
||||
must clear only the non-const tables, as const tables
|
||||
are not re-calculated.
|
||||
*/
|
||||
for (uint i=join->const_tables ; i < join->tables ; i++)
|
||||
mark_as_null_row(join->table[i]); // All fields are NULL
|
||||
}
|
||||
|
||||
|
@ -8034,7 +8079,12 @@ Field* create_tmp_field_from_field(THD *thd, Field* org_field,
|
|||
{
|
||||
Field *new_field;
|
||||
|
||||
if (convert_blob_length && (org_field->flags & BLOB_FLAG))
|
||||
/*
|
||||
Make sure that the blob fits into a Field_varstring which has
|
||||
2-byte lenght.
|
||||
*/
|
||||
if (convert_blob_length && convert_blob_length < UINT_MAX16 &&
|
||||
(org_field->flags & BLOB_FLAG))
|
||||
new_field= new Field_varstring(convert_blob_length,
|
||||
org_field->maybe_null(),
|
||||
org_field->field_name, table,
|
||||
|
@ -8116,8 +8166,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
|
|||
if ((type= item->field_type()) == MYSQL_TYPE_DATETIME ||
|
||||
type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE)
|
||||
new_field= item->tmp_table_field_from_field_type(table);
|
||||
/*
|
||||
Make sure that the blob fits into a Field_varstring which has
|
||||
2-byte lenght.
|
||||
*/
|
||||
else if (item->max_length/item->collation.collation->mbmaxlen > 255 &&
|
||||
convert_blob_length)
|
||||
item->max_length/item->collation.collation->mbmaxlen < UINT_MAX16
|
||||
&& convert_blob_length)
|
||||
new_field= new Field_varstring(convert_blob_length, maybe_null,
|
||||
item->name, table,
|
||||
item->collation.collation);
|
||||
|
@ -12810,7 +12865,7 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
|
|||
{
|
||||
if (! field->const_item())
|
||||
{
|
||||
Item_sum *sum_item=(Item_sum*) field;
|
||||
Item_sum *sum_item=(Item_sum*) field->real_item();
|
||||
if (!sum_item->quick_group)
|
||||
param->quick_group=0; // UDF SUM function
|
||||
param->sum_func_count++;
|
||||
|
@ -13070,10 +13125,11 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
|
|||
param->copy_funcs.empty();
|
||||
for (i= 0; (pos= li++); i++)
|
||||
{
|
||||
if (pos->real_item()->type() == Item::FIELD_ITEM)
|
||||
Item *real_pos= pos->real_item();
|
||||
if (real_pos->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
Item_field *item;
|
||||
pos= pos->real_item();
|
||||
pos= real_pos;
|
||||
if (!(item= new Item_field(thd, ((Item_field*) pos))))
|
||||
goto err;
|
||||
pos= item;
|
||||
|
@ -13112,12 +13168,13 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ((pos->type() == Item::FUNC_ITEM ||
|
||||
pos->type() == Item::SUBSELECT_ITEM ||
|
||||
pos->type() == Item::CACHE_ITEM ||
|
||||
pos->type() == Item::COND_ITEM) &&
|
||||
!pos->with_sum_func)
|
||||
else if ((real_pos->type() == Item::FUNC_ITEM ||
|
||||
real_pos->type() == Item::SUBSELECT_ITEM ||
|
||||
real_pos->type() == Item::CACHE_ITEM ||
|
||||
real_pos->type() == Item::COND_ITEM) &&
|
||||
!real_pos->with_sum_func)
|
||||
{ // Save for send fields
|
||||
pos= real_pos;
|
||||
/* TODO:
|
||||
In most cases this result will be sent to the user.
|
||||
This should be changed to use copy_int or copy_real depending
|
||||
|
|
|
@ -2116,12 +2116,6 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
LINT_INIT(end);
|
||||
LINT_INIT(len);
|
||||
|
||||
/*
|
||||
Let us set fake sql_command so views won't try to merge
|
||||
themselves into main statement.
|
||||
*/
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
|
||||
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
|
||||
|
||||
/*
|
||||
|
@ -2144,8 +2138,16 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
I_S tables will be done.
|
||||
*/
|
||||
thd->temporary_tables= open_tables_state_backup.temporary_tables;
|
||||
/*
|
||||
Let us set fake sql_command so views won't try to merge
|
||||
themselves into main statement. If we don't do this,
|
||||
SELECT * from information_schema.xxxx will cause problems.
|
||||
SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'
|
||||
*/
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
res= open_normal_and_derived_tables(thd, show_table_list,
|
||||
MYSQL_LOCK_IGNORE_FLUSH);
|
||||
lex->sql_command= save_sql_command;
|
||||
/*
|
||||
get_all_tables() returns 1 on failure and 0 on success thus
|
||||
return only these and not the result code of ::process_table()
|
||||
|
@ -2267,8 +2269,10 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
|
||||
lex->all_selects_list= &sel;
|
||||
lex->derived_tables= 0;
|
||||
lex->sql_command= SQLCOM_SHOW_FIELDS;
|
||||
res= open_normal_and_derived_tables(thd, show_table_list,
|
||||
MYSQL_LOCK_IGNORE_FLUSH);
|
||||
lex->sql_command= save_sql_command;
|
||||
/*
|
||||
We should use show_table_list->alias instead of
|
||||
show_table_list->table_name because table_name
|
||||
|
@ -3963,6 +3967,7 @@ bool get_schema_tables_result(JOIN *join)
|
|||
table_list->table->file->delete_all_rows();
|
||||
free_io_cache(table_list->table);
|
||||
filesort_free_buffers(table_list->table);
|
||||
table_list->table->null_row= 0;
|
||||
}
|
||||
else
|
||||
table_list->table->file->records= 0;
|
||||
|
|
Loading…
Reference in a new issue