Commit a3908e32 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Update upstream source from tag 'upstream/5.5.61'

Update to upstream version '5.5.61'
with Debian dir 20b939dcfbc305feda76bc5cca6748b5c526a79c
parents 908ae0c2 1627a8b1
...@@ -2656,6 +2656,29 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; ...@@ -2656,6 +2656,29 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
len len
196608 196608
# #
# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
#
SET NAMES utf8mb4;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(UUID(), "-", "") AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1;
c
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1;
c
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
DROP TABLE t1;
#
# End of 5.5 tests # End of 5.5 tests
# #
# #
......
...@@ -1011,4 +1011,78 @@ id id data ...@@ -1011,4 +1011,78 @@ id id data
2 2 yes 2 2 yes
1 NULL NULL 1 NULL NULL
drop table t1; drop table t1;
#
# MDEV-14241: Server crash in key_copy / get_matching_chain_by_join_key
# or valgrind warnings
#
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES ('foo'),('bar');
CREATE TABLE t2 (b integer auto_increment primary key) ENGINE=MyISAM;
INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
1 PRIMARY <derived3> hash_ALL NULL #hash#$hj 3075 func 2 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 v3.d 1 Using index
3 DERIVED t3 ALL NULL NULL NULL NULL 2
2 DERIVED t1 ALL NULL NULL NULL NULL 2
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
a b c d
DROP VIEW v1, v3;
DROP TABLE t1, t2, t3;
#
# MDEV-14786: Server crashes in Item_cond::transform on 2nd
# execution of SP querying from a view
#
create table t1 (i int, row_start timestamp(6) not null default now(),
row_end timestamp(6) not null default '2030-01-01 0:0:0');
create view v1 as select i from t1 where i < 5 and (row_end =
TIMESTAMP'2030-01-01 0:0:0' or row_end is null);
create procedure pr(x int) select i from v1;
call pr(1);
i
call pr(2);
i
drop procedure pr;
drop view v1;
drop table t1;
set @@join_cache_level= @save_join_cache_level;
#
# MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
#
CREATE TABLE t1 (c1 text, c2 int);
INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
CREATE TABLE t2 (c1 text, c2 int);
INSERT INTO t2 VALUES ('b',2), ('c',3);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
set @save_join_cache_level= @@join_cache_level;
set @@join_cache_level=4;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY <derived2> hash_ALL NULL #hash#$hj 3 test.t2.c1 5 Using where; Using join buffer (flat, BNLH join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
drop table t1,t2;
drop view v1;
set @@join_cache_level= @save_join_cache_level;
# end of 5.5 # end of 5.5
...@@ -572,6 +572,17 @@ N AVG ...@@ -572,6 +572,17 @@ N AVG
0 NULL 0 NULL
drop table t1; drop table t1;
# #
# MDEV-15630 uuid() function evaluates at wrong time in query
#
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(1), UUID() as uid FROM t1 GROUP BY uid;
COUNT(1) uid
1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
DROP TABLE t1;
#
# End of 5.5 tests # End of 5.5 tests
# #
SELECT NAME_CONST('a', -(1 OR 2)) OR 1; SELECT NAME_CONST('a', -(1 OR 2)) OR 1;
......
...@@ -1647,11 +1647,6 @@ drop user mysqluser11@localhost; ...@@ -1647,11 +1647,6 @@ drop user mysqluser11@localhost;
drop database mysqltest1; drop database mysqltest1;
End of 5.0 tests End of 5.0 tests
set names utf8; set names utf8;
grant select on test.* to юзер_юзер@localhost;
user()
юзер_юзер@localhost
revoke all on test.* from юзер_юзер@localhost;
drop user юзер_юзер@localhost;
grant select on test.* to очень_длинный_юзер@localhost; grant select on test.* to очень_длинный_юзер@localhost;
ERROR HY000: String 'очень_длинный_юзер' is too long for user name (should be no longer than 16) ERROR HY000: String 'очень_длинный_юзер' is too long for user name (should be no longer than 16)
set names default; set names default;
...@@ -1693,6 +1688,7 @@ revoke create, insert on mysqltest.t6 from mysqltest@localhost; ...@@ -1693,6 +1688,7 @@ revoke create, insert on mysqltest.t6 from mysqltest@localhost;
drop user mysqltest@localhost; drop user mysqltest@localhost;
drop database mysqltest; drop database mysqltest;
use test; use test;
call mtr.add_suppression("Can't open and lock privilege tables");
FLUSH PRIVILEGES without procs_priv table. FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone; RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
...@@ -1782,8 +1778,6 @@ BEGIN ...@@ -1782,8 +1778,6 @@ BEGIN
SET @x = 0; SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;|| END ;||
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
SHOW GRANTS FOR 'user1'@'localhost'; SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost Grants for user1@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost' GRANT USAGE ON *.* TO 'user1'@'localhost'
...@@ -1793,6 +1787,7 @@ SHOW GRANTS FOR 'user2'; ...@@ -1793,6 +1787,7 @@ SHOW GRANTS FOR 'user2';
Grants for user2@% Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%' GRANT USAGE ON *.* TO 'user2'@'%'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%' GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc2` TO 'user2'@'%'
DROP PROCEDURE db1.proc1; DROP PROCEDURE db1.proc1;
DROP PROCEDURE db1.proc2; DROP PROCEDURE db1.proc2;
REVOKE ALL ON db1.* FROM 'user1'@'localhost'; REVOKE ALL ON db1.* FROM 'user1'@'localhost';
......
set names utf8;
grant select on test.* to юзер_юзер@localhost;
user()
юзер_юзер@localhost
revoke all on test.* from юзер_юзер@localhost;
drop user юзер_юзер@localhost;
set names default;
...@@ -712,3 +712,14 @@ a ct ...@@ -712,3 +712,14 @@ a ct
4 2 4 2
set sql_mode=@save_sql_mode; set sql_mode=@save_sql_mode;
drop table t1; drop table t1;
#
# mdev-16235: impossible HAVING in query without aggregation
#
explain extended
select * from mysql.help_topic where example = 'foo' having description is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
Warnings:
Note 1003 select `mysql`.`help_topic`.`help_topic_id` AS `help_topic_id`,`mysql`.`help_topic`.`name` AS `name`,`mysql`.`help_topic`.`help_category_id` AS `help_category_id`,`mysql`.`help_topic`.`description` AS `description`,`mysql`.`help_topic`.`example` AS `example`,`mysql`.`help_topic`.`url` AS `url` from `mysql`.`help_topic` where (`mysql`.`help_topic`.`example` = 'foo') having 0
select * from mysql.help_topic where example = 'foo' having description is null;
help_topic_id name help_category_id description example url
...@@ -1387,7 +1387,7 @@ USE test; ...@@ -1387,7 +1387,7 @@ USE test;
End of 5.0 tests. End of 5.0 tests.
select * from information_schema.engines WHERE ENGINE="MyISAM"; select * from information_schema.engines WHERE ENGINE="MyISAM";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
MyISAM DEFAULT MyISAM storage engine NO NO NO MyISAM DEFAULT Non-transactional engine with good performance and small data footprint NO NO NO
grant select on *.* to user3148@localhost; grant select on *.* to user3148@localhost;
select user,db from information_schema.processlist; select user,db from information_schema.processlist;
user db user db
......
...@@ -853,3 +853,12 @@ INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7; ...@@ -853,3 +853,12 @@ INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7;
SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size; SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size;
DROP TABLE t1; DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
create table t1 (i int);
create table t2 as select values(i) as a from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` binary(0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2;
End of 5.5 tests
...@@ -1497,3 +1497,43 @@ Note 1003 select NULL AS `i1`,`v2`.`i2` AS `i2`,`v2`.`a` AS `a`,`v2`.`b` AS `b` ...@@ -1497,3 +1497,43 @@ Note 1003 select NULL AS `i1`,`v2`.`i2` AS `i2`,`v2`.`a` AS `a`,`v2`.`b` AS `b`
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-16512
# Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
# non-existing field
#
CREATE TABLE t (i INT);
CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
FLUSH TABLES;
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (f INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (i INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT, c INT);
CREATE TABLE t4 (a INT, c INT);
CREATE TABLE t5 (a INT, c INT);
CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
LEFT JOIN t5 USING (a)) USING (a);
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
#
# End of MariaDB 5.5 tests
#
...@@ -5813,4 +5813,95 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -5813,4 +5813,95 @@ id select_type table type possible_keys key key_len ref rows Extra
set join_buffer_size=default; set join_buffer_size=default;
set join_cache_level = default; set join_cache_level = default;
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# MDEV-14960: BNLH used for materialized semi-join
#
CREATE TABLE t1 (i1 int);
CREATE TABLE t2 (e1 int);
CREATE TABLE t4 (e1 int);
CREATE TABLE t5 (e1 int);
INSERT INTO t1 VALUES
(1),(2),(3),(4),(5),(6),(7),(8);
INSERT INTO t1 SELECT i1+8 FROM t1;
INSERT INTO t1 SELECT i1+16 FROM t1;
INSERT INTO t1 SELECT i1+32 FROM t1;
INSERT INTO t1 SELECT i1+64 FROM t1;
INSERT INTO t2 SELECT * FROM t1;
INSERT INTO t4 SELECT * FROM t1;
INSERT INTO t5 SELECT * FROM t1;
set @save_optimizer_switch= @@optimizer_switch;
SET join_cache_level = 6;
SET join_buffer_size=4096;
SET join_buffer_space_limit=4096;
SET optimizer_switch = 'join_cache_hashed=on,optimize_join_buffer_size=on';
EXPLAIN SELECT * FROM t1
WHERE
i1 < 10 AND
i1 IN
(SELECT i1 FROM
(SELECT (t4.e1) i1 FROM t4
LEFT JOIN t5 ON t4.e1 = t5.e1
LEFT JOIN (SELECT e1 FROM t2 ) AS d ON t4.e1 = d.e1) a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 128 Using where
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 128
2 MATERIALIZED t5 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t2 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; Using join buffer (incremental, BNLH join)
SELECT * FROM t1
WHERE
i1 < 10 AND
i1 IN
(SELECT i1 FROM
(SELECT (t4.e1) i1 FROM t4
LEFT JOIN t5 ON t4.e1 = t5.e1
LEFT JOIN (SELECT e1 FROM t2 ) AS d ON t4.e1 = d.e1) a);
i1
1
2
3
4
5
6
7
8
9
SET join_cache_level = default;
SET join_buffer_size = default;
SET join_buffer_space_limit= default;
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
#
# MDEV-16603: BNLH for query with materialized semi-join
#
set join_cache_level=4;
CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
(228,'x'),(3,'y'),(1,'z'),(9,'z');
CREATE TABLE temp
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
f1 f2
7 x
7 x
7 x
7 x
7 x
7 x
7 x
EXPLAIN EXTENDED SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 100.00
1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 100.00 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using join buffer (flat, BNLH join)
Warnings:
Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`temp`.`f1` = `test`.`t1`.`i1`) and (`test`.`t2`.`v1` = `test`.`t1`.`v1`) and (`test`.`temp`.`f2` = `test`.`t1`.`v1`))
DROP TABLE t1,t2,temp;
SET join_cache_level = default;
set @@optimizer_switch=@save_optimizer_switch; set @@optimizer_switch=@save_optimizer_switch;
...@@ -2346,11 +2346,77 @@ CREATE TABLE t1 (b1 BIT NOT NULL); ...@@ -2346,11 +2346,77 @@ CREATE TABLE t1 (b1 BIT NOT NULL);
INSERT INTO t1 VALUES (0),(1); INSERT INTO t1 VALUES (0),(1);
CREATE TABLE t2 (b2 BIT NOT NULL); CREATE TABLE t2 (b2 BIT NOT NULL);
INSERT INTO t2 VALUES (0),(1); INSERT INTO t2 VALUES (0),(1);
SET SESSION JOIN_CACHE_LEVEL = 3; set @save_join_cache_level= @@join_cache_level;
SET @@join_cache_level = 3;
SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2;
t1.b1+'0' t2.b2 + '0' t1.b1+'0' t2.b2 + '0'
0 0 0 0
1 1 1 1
DROP TABLE t1, t2; DROP TABLE t1, t2;
set @join_cache_level= @save_join_cache_level;
#
# MDEV-14779: using left join causes incorrect results with materialization and derived tables
#
create table t1(id int);
insert into t1 values (1),(2);
create table t2(sid int, id int);
insert into t2 values (1,1),(2,2);
select * from t1 t
left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r
on t.id=r.id ;
id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests # end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
...@@ -2357,12 +2357,78 @@ CREATE TABLE t1 (b1 BIT NOT NULL); ...@@ -2357,12 +2357,78 @@ CREATE TABLE t1 (b1 BIT NOT NULL);
INSERT INTO t1 VALUES (0),(1); INSERT INTO t1 VALUES (0),(1);
CREATE TABLE t2 (b2 BIT NOT NULL); CREATE TABLE t2 (b2 BIT NOT NULL);
INSERT INTO t2 VALUES (0),(1); INSERT INTO t2 VALUES (0),(1);
SET SESSION JOIN_CACHE_LEVEL = 3; set @save_join_cache_level= @@join_cache_level;
SET @@join_cache_level = 3;
SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2;
t1.b1+'0' t2.b2 + '0' t1.b1+'0' t2.b2 + '0'
0 0 0 0
1 1 1 1
DROP TABLE t1, t2; DROP TABLE t1, t2;
set @join_cache_level= @save_join_cache_level;
#
# MDEV-14779: using left join causes incorrect results with materialization and derived tables
#
create table t1(id int);
insert into t1 values (1),(2);
create table t2(sid int, id int);
insert into t2 values (1,1),(2,2);
select * from t1 t
left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r
on t.id=r.id ;
id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests # end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default; set join_cache_level=default;
......
...@@ -146,3 +146,19 @@ a ...@@ -146,3 +146,19 @@ a
16 16
DROP TABLE t1; DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
#
# mdev-16235: SELECT over a table with LIMIT 0
#
EXPLAIN
SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
SELECT * FROM mysql.slow_log WHERE sql_text != 'foo' LIMIT 0;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
EXPLAIN
SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
SELECT * FROM mysql.help_topic WHERE help_category_id != example LIMIT 0;
help_topic_id name help_category_id description example url
End of 5.5 tests
...@@ -407,7 +407,7 @@ LOCK TABLE t1 WRITE; ...@@ -407,7 +407,7 @@ LOCK TABLE t1 WRITE;
HANDLER t1 OPEN; HANDLER t1 OPEN;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
HANDLER t1 READ FIRST; HANDLER t1 READ FIRST;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction Got one of the listed errors
HANDLER t1 CLOSE; HANDLER t1 CLOSE;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES; UNLOCK TABLES;
......
create table t1(a bit(1), b int auto_increment ,id int, index(a,b));
insert into t1 values(1,null,1);
insert into t1 values(1,null,2);
insert into t1 values(0,null,3);
insert into t1 values(0,null,4);
select a+0, b as auto_increment , id from t1 order by id;
a+0 auto_increment id
1 1 1
1 2 2
0 1 3
0 2 4
drop table t1;
create table t1(a int auto_increment, b bit(5) ,id int, index (b,a));
insert into t1 values(null,b'1',1);
insert into t1 values(null,b'1',2);
insert into t1 values(null,b'11',3);
insert into t1 values(null,b'11',4);
select a as auto_increment, b+0, id from t1 order by id;
auto_increment b+0 id
1 1 1
2 1 2
1 3 3
2 3 4
drop table t1;
create table t1(a bit(1), b int auto_increment , c bit(1) , d bit(1), id int,index(a,c,b,d));
insert into t1 values(1,null,1,1,1);
insert into t1 values(1,null,1,1,2);
insert into t1 values(0,null,1,1,3);
insert into t1 values(1,null,0,1,4);
select a+0, b as auto_increment, c+0, d+0, id from t1 order by id;
a+0 auto_increment c+0 d+0 id
1 1 1 1 1
1 2 1 1 2
0 1 1 1 3
1 1 0 1 4
drop table t1;
CREATE TABLE t1 (b BIT(1), pk INTEGER AUTO_INCREMENT PRIMARY KEY);
ALTER TABLE t1 ADD INDEX(b,pk);
INSERT INTO t1 VALUES (1,b'1');
ALTER TABLE t1 DROP PRIMARY KEY;
select b+0, pk as auto_increment from t1;
b+0 auto_increment
1 1
DROP TABLE t1;
The following options may be given as the first argument: The following options may be given as the first argument:
--print-defaults Print the program argument list and exit. --print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file. --no-defaults Don't read default options from any option file.
The following specify which files/extra groups are read (specified before remaining options):
--defaults-file=# Only read default options from the given file #. --defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read. --defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=# Additionally read default groups with # appended as a suffix.
--allow-suspicious-udfs --allow-suspicious-udfs
Allows use of UDFs consisting of only one symbol xxx() Allows use of UDFs consisting of only one symbol xxx()
......
...@@ -124,3 +124,46 @@ v1 ...@@ -124,3 +124,46 @@ v1
1v 1v
drop database `mysqltest1 drop database `mysqltest1
1tsetlqsym`; 1tsetlqsym`;
create database `test```;
create database `test\``
\! ls
#`;
show databases like 'test%';
Database (test%)
test
test\`
\! ls
#
test`
--
-- Current Database: `test```
--
/*!40000 DROP DATABASE IF EXISTS `test```*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test``` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test```;
--
-- Current Database: `test\``
-- \! ls
-- #`
--
/*!40000 DROP DATABASE IF EXISTS `test\``
\! ls
#`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test\``
\! ls
#` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test\``
\! ls
#`;
drop database `test```;
drop database `test\``
\! ls
#`;
...@@ -5401,3 +5401,18 @@ DELIMITER ; ...@@ -5401,3 +5401,18 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET collation_connection = @saved_col_connection */ ;
ALTER DATABASE `a\"'``b` CHARACTER SET utf8 COLLATE utf8_general_ci ; ALTER DATABASE `a\"'``b` CHARACTER SET utf8 COLLATE utf8_general_ci ;
DROP DATABASE `a\"'``b`; DROP DATABASE `a\"'``b`;
#
# MDEV-15021: Fix the order in which routines are called
#
use test;
CREATE FUNCTION f() RETURNS INT RETURN 1;
CREATE VIEW v1 AS SELECT f();
# Running mysqldump -uroot test --routines --tables v1 > **vardir**/test.dmp
DROP VIEW v1;
DROP FUNCTION f;
# Running mysql -uroot test < **vardir**/test.dmp
#
# Cleanup after succesful import.
#
DROP VIEW v1;
DROP FUNCTION f;
...@@ -255,3 +255,6 @@ Benchmark ...@@ -255,3 +255,6 @@ Benchmark
# MDEV-4684 - Enhancement request: --init-command support for mysqlslap # MDEV-4684 - Enhancement request: --init-command support for mysqlslap
# #
DROP TABLE t1; DROP TABLE t1;
#
# Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK
#
...@@ -672,3 +672,10 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -672,3 +672,10 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\'; PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\' at line 1
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger
#
CREATE TABLE t1 (a INT);
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @@NEW.a=0;
ERROR HY000: Unknown system variable 'NEW'
DROP TABLE t1;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment