Skip to content
Permalink
Browse files
Merge branch '5.5' into 10.0
  • Loading branch information
vuvova committed Apr 20, 2018
2 parents bcb36ee + 51c415d commit 587568b
Show file tree
Hide file tree
Showing 42 changed files with 421 additions and 58 deletions.
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
Copyright (c) 2010, 2013, Monty Program Ab
Copyright (c) 2010, 2018, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1,7 +1,7 @@
#ifndef SQL_COMMON_INCLUDED
#define SQL_COMMON_INCLUDED
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
Copyright (c) 2010, 2012, Monty Program Ab
Copyright (c) 2010, 2018, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
# -*- cperl -*-

# Copyright (c) 2004, 2014, Oracle and/or its affiliates.
# Copyright (c) 2009, 2017, MariaDB Corporation
# Copyright (c) 2009, 2018, MariaDB Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -4590,6 +4590,37 @@ Field Type Null Key Default Extra
c1 mediumtext YES NULL
DROP TABLE t1;
#
# MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
#
SET NAMES utf8;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
COUNT(DISTINCT c)
3
SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
c
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx
DROP TABLE t1;
#
# End of 5.5 tests
#
#
@@ -2859,6 +2859,29 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
len
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
#
#
@@ -1,8 +1,10 @@
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--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-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
Allows use of UDFs consisting of only one symbol xxx()
@@ -221,6 +221,14 @@ a a
5 10
DROP TABLE temp1, temp2;

# MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB.

CREATE TEMPORARY TABLE temp1 ENGINE=INNODB AS SELECT a FROM t1;
SELECT * FROM temp1;
a
1
DROP TABLE temp1;

# Disconnect and cleanup

SET GLOBAL READ_ONLY = OFF;
@@ -174,3 +174,9 @@ create database mysqltest1;
create procedure mysqltest1.foo() select "foo";
update mysql.proc set name='' where db='mysqltest1';
drop database mysqltest1;
create procedure p1() set @foo = 10;
alter table mysql.proc drop primary key;
drop procedure p1;
ERROR HY000: Cannot load from mysql.proc. The table is probably corrupted
alter table mysql.proc add primary key (db,name,type);
drop procedure p1;
@@ -1043,7 +1043,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
@@ -1134,7 +1134,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No matching min/max row
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT min(f3)+f3, min(f4)+f3+max(f4) FROM t2 WHERE f3 > 10);
f1 f2
set @@optimizer_switch=@save_optimizer_switch;
@@ -2498,3 +2498,23 @@ SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1);
0
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;
#
# mfrv-14515: Wrong results for tableless query with subquery in WHERE
# and implicit aggregation
#
create table t1 (i1 int, i2 int);
insert into t1 values (1314, 1084),(1330, 1084),(1401, 1084),(580, 1084);
create table t2 (cd int);
insert into t2 values
(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330),
(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330);
select max(10) from dual
where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);
max(10)
NULL
insert into t2 select * from t2;
select max(10) from dual
where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);
max(10)
NULL
DROP TABLE t1,t2;
@@ -0,0 +1,24 @@
create table t1 (a int not null, b int not null) engine=innodb;
insert t1 values (1,2),(3,4);
lock table t1 write, t1 tr read;
flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
unlock tables;
alter table t1 drop primary key;
lock table t1 write;
flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
unlock tables;
alter table t1 drop primary key;
flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';
Variable_name Value
Handler_read_rnd_next 0
drop table t1;
@@ -0,0 +1,28 @@
#
# BUG#27216817: INNODB: FAILING ASSERTION:
# PREBUILT->TABLE->N_MYSQL_HANDLES_OPENED == 1
#

source include/have_innodb.inc;
create table t1 (a int not null, b int not null) engine=innodb;
insert t1 values (1,2),(3,4);

lock table t1 write, t1 tr read;
flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';
unlock tables;
alter table t1 drop primary key;

lock table t1 write;
flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';
unlock tables;
alter table t1 drop primary key;

flush status;
alter table t1 add primary key (b);
show status like 'Handler_read_rnd_next';

drop table t1;
@@ -843,6 +843,28 @@ DESCRIBE t1;
DROP TABLE t1;


--echo #
--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
--echo #

SET NAMES utf8;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);

SELECT COUNT(DISTINCT c) FROM (SELECT id, REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT REPLACE(uuid_short(), '0', CAST('o' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;

SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT INSERT(uuid_short(), 1, 1, CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;

SELECT COUNT(DISTINCT c) FROM (SELECT id, CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxxxxxx
SELECT DISTINCT CONCAT(uuid_short(), CAST('0' AS CHAR CHARACTER SET ucs2)) AS c FROM t1;
DROP TABLE t1;


--echo #
--echo # End of 5.5 tests
--echo #
@@ -1841,6 +1841,25 @@ SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;

--echo #
--echo # MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way
--echo #

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;
--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT DISTINCT INSERT(uuid(), 9, 1, "X") AS c FROM t1;

SELECT COUNT(DISTINCT c) FROM (SELECT id, INSERT(UUID(), 9, 1, "X") AS c FROM t1) AS d1;
--replace_column 1 xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
SELECT DISTINCT INSERT(UUID(), 9, 1, "X") AS c FROM t1;

DROP TABLE t1;


--echo #
--echo # End of 5.5 tests
--echo #
@@ -243,6 +243,15 @@ UPDATE temp1,temp2 SET temp1.a = 5, temp2.a = 10;
SELECT * FROM temp1, temp2;
DROP TABLE temp1, temp2;

--echo
--echo # MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB.
--echo

CREATE TEMPORARY TABLE temp1 ENGINE=INNODB AS SELECT a FROM t1;
SELECT * FROM temp1;
DROP TABLE temp1;


--echo
--echo # Disconnect and cleanup
--echo
@@ -286,3 +286,13 @@ create database mysqltest1;
create procedure mysqltest1.foo() select "foo";
update mysql.proc set name='' where db='mysqltest1';
drop database mysqltest1;

#
# BUG#26881798: SERVER EXITS WHEN PRIMARY KEY IN MYSQL.PROC IS DROPPED
#
create procedure p1() set @foo = 10;
alter table mysql.proc drop primary key;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
drop procedure p1;
alter table mysql.proc add primary key (db,name,type);
drop procedure p1;
@@ -2042,3 +2042,26 @@ SELECT 2 IN (SELECT 2 from DUAL WHERE 1 != 1);

SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;

--echo #
--echo # mfrv-14515: Wrong results for tableless query with subquery in WHERE
--echo # and implicit aggregation
--echo #

create table t1 (i1 int, i2 int);
insert into t1 values (1314, 1084),(1330, 1084),(1401, 1084),(580, 1084);

create table t2 (cd int);
insert into t2 values
(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330),
(1330), (1330), (1330), (1330), (1330), (1330), (1330), (1330);

select max(10) from dual
where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);

insert into t2 select * from t2;

select max(10) from dual
where exists (select 1 from t2 join t1 on t1.i1 = t2.cd and t1.i2 = 345);

DROP TABLE t1,t2;
@@ -1,5 +1,5 @@
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates.
Copyright (c) 2009, 2016, MariaDB
/* Copyright (c) 2006, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -84,7 +84,8 @@ static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
do { /* PTR() isn't necessary below, head is a dummy node */
cursor->curr= (LF_SLIST *)(*cursor->prev);
_lf_pin(pins, 1, cursor->curr);
} while (*cursor->prev != (intptr)cursor->curr && LF_BACKOFF);
} while (my_atomic_loadptr((void**)cursor->prev) != cursor->curr &&
LF_BACKOFF);
for (;;)
{
if (unlikely(!cursor->curr))
@@ -98,7 +99,7 @@ static int l_find(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
cur_hashnr= cursor->curr->hashnr;
cur_key= cursor->curr->key;
cur_keylen= cursor->curr->keylen;
if (*cursor->prev != (intptr)cursor->curr)
if (my_atomic_loadptr((void**)cursor->prev) != cursor->curr)
{
(void)LF_BACKOFF;
goto retry;
@@ -1102,10 +1102,12 @@ void print_defaults(const char *conf_file, const char **groups)
}
}
puts("\nThe following options may be given as the first argument:\n\
--print-defaults Print the program argument list and exit.\n\
--no-defaults Don't read default options from any option file.\n\
--defaults-file=# Only read default options from the given file #.\n\
--defaults-extra-file=# Read this file after the global files are read.");
--print-defaults Print the program argument list and exit.\n\
--no-defaults Don't read default options from any option file.\n\
The following specify which files/extra groups are read (specified before remaining options):\n\
--defaults-file=# Only read default options from the given file #.\n\
--defaults-extra-file=# Read this file after the global files are read.\n\
--defaults-group-suffix=# Additionally read default groups with # appended as a suffix.");
}


@@ -1575,7 +1575,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
}
else
{
if (len > (ulong) (end_pos - pos))
if (pos + len > end_pos)
{
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
return -1;

0 comments on commit 587568b

Please sign in to comment.