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

Imported Upstream version 5.5.39

parent 16eb3898
......@@ -1876,6 +1876,40 @@ SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev;
dev
1
#
# Bug #17059925 : UNIONS COMPUTES ROWS_EXAMINED INCORRECTLY
#
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
CREATE TABLE t17059925 (a INT);
CREATE TABLE t2 (b INT);
CREATE TABLE t3 (c INT);
INSERT INTO t17059925 VALUES (1), (2), (3);
INSERT INTO t2 VALUES (4), (5), (6);
INSERT INTO t3 VALUES (7), (8), (9);
TRUNCATE table mysql.slow_log;
SELECT * FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3;
a
1
2
3
4
5
6
7
8
9
SELECT sql_text, rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%t17059925%';
sql_text rows_examined
SELECT * FROM t17059925 UNION SELECT * FROM t2 UNION SELECT * FROM t3 18
DROP TABLE t17059925, t2, t3;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
#
# lp:1010729: Unexpected syntax error from UNION
# (bug #54382) with single-table join nest
#
......
......@@ -189,6 +189,8 @@ select @@concurrent_insert;
@@concurrent_insert
AUTO
set global timed_mutexes=ON;
Warnings:
Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
show variables like 'timed_mutexes';
Variable_name Value
timed_mutexes ON
......@@ -196,6 +198,8 @@ select * from information_schema.session_variables where variable_name like 'tim
VARIABLE_NAME VARIABLE_VALUE
TIMED_MUTEXES ON
set global timed_mutexes=0;
Warnings:
Warning 1287 '@@timed_mutexes' is deprecated and will be removed in a future release.
show variables like 'timed_mutexes';
Variable_name Value
timed_mutexes OFF
......
......@@ -4791,6 +4791,45 @@ DROP DATABASE IF EXISTS nodb;
CREATE VIEW nodb.a AS SELECT 1;
ERROR 42000: Unknown database 'nodb'
#
# BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION
# BUG#18405221 - SHOW CREATE VIEW OUTPUT INCORRECT
#
CREATE VIEW v1 AS (SELECT '' FROM DUAL);
CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
(SELECT '' FROM DUAL);
CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
(SELECT '' FROM DUAL) UNION ALL
(SELECT '' FROM DUAL);
CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL
(SELECT '' AS col2 FROM DUAL) UNION ALL
(SELECT '' FROM DUAL);
CREATE VIEW v5 AS (SELECT 'buggy' AS col1, 'fix' as col2 FROM DUAL) UNION ALL
(SELECT 'buggy' as a, 'fix' as a FROM DUAL);
# Name for the column in select1 is set properly with or
# without this fix.
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
# Name for the column in select2 is set with this fix.
# Without this fix, name would not have set for the
# columns in select2.
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
# Name for the field item in select2 & select3 is set with this fix.
# Without this fix, name would not have set for the
# columns in select2 & select3.
SHOW CREATE VIEW v3;
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `Name_exp_1`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
# Name for the field item in select3 is set with this fix.
# Without this fix, name would not have set for the
# columns in select3.
SHOW CREATE VIEW v4;
View Create View character_set_client collation_connection
v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `col2`) union all (select '' AS `Name_exp_1`) latin1 latin1_swedish_ci
DROP VIEW v1, v2, v3, v4, v5;
#
# lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin)
#
CREATE TABLE t1 ( a int, b int );
......@@ -5302,6 +5341,61 @@ NULL 8
drop view v1;
drop table t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch_MDEV_3874;
CREATE TABLE `t1` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`f0` int(11) unsigned NOT NULL DEFAULT '0',
`f1` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
);
CREATE TABLE `t2` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`f02` bigint(20) unsigned NOT NULL DEFAULT '0',
`f03` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
);
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v1` AS
SELECT
`t1`.`f0` AS `f0`,
`t1`.`f1` AS `f1`,
`t2`.`f02` AS `f02`,
`t2`.`f03` AS `f03`
FROM
(`t1` LEFT JOIN `t2` ON((`t1`.`id` = `t2`.`f02`)));
CREATE FUNCTION `f1`(
p0 BIGINT(20) UNSIGNED
)
RETURNS bigint(20) unsigned
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE k0 INTEGER UNSIGNED DEFAULT 0;
DECLARE lResult INTEGER UNSIGNED DEFAULT 0;
SET k0 = 0;
WHILE k0 < 1 DO
SELECT COUNT(*) as `f00` INTO lResult FROM `v1` WHERE `v1`.`f0` = p0; -- BUG
SET k0 = k0 + 1;
END WHILE;
RETURN(k0);
END|
SELECT `f1`(1);
`f1`(1)
1
SELECT `f1`(1);
`f1`(1)
1
SELECT `f1`(1);
`f1`(1)
1
SELECT `f1`(1);
`f1`(1)
1
DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1, t2;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------
......
File mode changed from 100644 to 100755
......@@ -126,3 +126,29 @@ select count(*) from t1;
count(*)
100
drop table t1;
#
#BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
# CORRUPTS FRM
CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= MYISAM PARTITION BY HASH(fld1)
PARTITIONS 5;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`fld1` int(11) NOT NULL,
PRIMARY KEY (`fld1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (fld1)
PARTITIONS 5 */
ALTER TABLE t1 ENGINE= ARCHIVE;
ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 1)
#After the patch, the ENGINE is correctly displayed as MyISAM
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`fld1` int(11) NOT NULL,
PRIMARY KEY (`fld1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (fld1)
PARTITIONS 5 */
#Cleanup.
DROP TABLE t1;
......@@ -128,3 +128,21 @@ show create table t1;
select count(*) from t1;
drop table t1;
--echo #
--echo #BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
--echo # CORRUPTS FRM
CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= MYISAM PARTITION BY HASH(fld1)
PARTITIONS 5;
SHOW CREATE TABLE t1;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
--error ER_CANT_CREATE_TABLE
ALTER TABLE t1 ENGINE= ARCHIVE;
--echo #After the patch, the ENGINE is correctly displayed as MyISAM
SHOW CREATE TABLE t1;
--echo #Cleanup.
DROP TABLE t1;
......@@ -353,6 +353,10 @@ drop function bug27563;
# common cleanup
#
connection default;
disconnect con1;
disconnect con2;
drop table t1,t2,t3;
--echo end of the tests
......@@ -5035,9 +5035,9 @@ CAST(0.2359591234567e6 AS TIME)
23:59:59
SELECT CAST(0.2359591234567e+30 AS TIME);
CAST(0.2359591234567e+30 AS TIME)
NULL
838:59:59
Warnings:
Warning 1292 Incorrect datetime value: '2.359591234567e29'
Warning 1292 Truncated incorrect time value: '2.359591234567e29'
select cast('100:55:50' as time) < cast('24:00:00' as time);
cast('100:55:50' as time) < cast('24:00:00' as time)
0
......
--echo #
--echo # Testing robustness against random compression failures
--echo #
--source include/not_embedded.inc
--source include/have_innodb.inc
--disable_query_log
# record the file format in order to restore in the end.
--let $file_format_save = `SELECT @@innodb_file_format`
--let $file_format_max_save = `SELECT @@innodb_file_format_max`
--let $simulate_comp_failures_save = `SELECT @@innodb_simulate_comp_failures`
--disable_warnings
DROP TABLE IF EXISTS t1;
SET GLOBAL INNODB_FILE_FORMAT='Barracuda';
--enable_warnings
# since this test generates lot of errors in log, suppress checking errors
call mtr.add_suppression(".*");
--enable_query_log
# create the table with compressed pages of size 8K.
CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
# percentage of compressions that will be forced to fail
SET GLOBAL innodb_simulate_comp_failures = 25;
--disable_query_log
--disable_result_log
let $num_inserts_ind = $num_inserts;
while ($num_inserts_ind)
{
let $repeat = `select floor(rand() * 10)`;
eval
INSERT INTO t1(id, msg)
VALUES ($num_inserts_ind, REPEAT('abcdefghijklmnopqrstuvwxyz', $repeat));
dec $num_inserts_ind;
}
--enable_query_log
--enable_result_log
SELECT COUNT(*) FROM t1;
--disable_query_log
--disable_result_log
# do random ops, making sure that some pages will get fragmented and reorganized.
let $num_ops_ind = $num_ops;
while($num_ops_ind)
{
let $idx = `select floor(rand()*$num_inserts)`;
let $insert_or_update = `select floor(rand()*3)`;
let $repeat = `select floor(rand() * 9) + 1`;
let $msg = query_get_value(`select repeat('abcdefghijklmnopqrstuvwxyz', $repeat) as x`, x, 1);
let $single_or_multi = `select floor(rand()*10)`;
if ($insert_or_update)
{
let $cnt = query_get_value(SELECT COUNT(*) cnt FROM t1 WHERE id=$idx, cnt, 1);
if ($cnt)
{
let $update = `select floor(rand()*2)`;
if ($update)
{
if ($single_or_multi)
{
eval UPDATE t1 SET msg=\"$msg\" WHERE id=$idx;
}
if (!$single_or_multi)
{
eval UPDATE t1 SET msg=\"$msg\" WHERE id >= $idx - 100 AND id <= $idx + 100;
}
}
if (!$update)
{
if ($single_or_multi)
{
eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id = VALUES(id);
}
if (!$single_or_multi)
{
let $diff = 200;
while ($diff)
{
eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx + 100 - $diff) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id=VALUES(id);
dec $diff;
}
}
}
}
if (!$cnt)
{
let $null_msg = `select floor(rand()*2)`;
if ($null_msg)
{
eval INSERT INTO t1(id,msg) VALUES ($idx, NULL);
}
if (!$null_msg)
{
eval INSERT INTO t1(id, msg) VALUES ($idx, \"$msg\");
}
}
}
if (!$insert_or_update)
{
if ($single_or_multi)
{
eval DELETE from t1 WHERE id=$idx;
}
if (!$single_or_multi)
{
eval DELETE from t1 WHERE id >= $idx - 100 AND id <= $idx + 100;
}
}
dec $num_ops_ind;
}
# final cleanup
DROP TABLE t1;
# restore innodb_file_format and innodb_file_format_max
eval SET GLOBAL innodb_file_format = \"$file_format_save\";
eval SET GLOBAL innodb_file_format_max = \"$file_format_max_save\";
eval SET GLOBAL innodb_simulate_comp_failures = $simulate_comp_failures_save;
--enable_query_log
create table t1 (f1 tinyblob not null) engine=innodb;
alter table t1 add unique index (f1(255));
drop table t1;
create table t1 (f1 tinyblob not null) engine=innodb;
alter table t1 add unique index (f1(356));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` tinyblob NOT NULL,
UNIQUE KEY `f1` (`f1`(255))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (f1 point not null) engine=innodb;
alter table t1 add unique index (f1);
drop table t1;
#
# Bug #18806829 OPENING INNODB TABLES WITH MANY FOREIGN KEY
# REFERENCES IS SLOW/CRASHES SEMAPHORE
#
create table t1 (f1 int primary key) engine=innodb;
insert into t1 values (5);
insert into t1 values (2882);
insert into t1 values (10);
update t1 set f1 = 28 where f1 = 2882;
select * from fk_120;
f1
5
10
28
select * from fk_1;
f1
5
10
28
select * from fk_50;
f1
5
10
28
drop table t1;
#
# Check if restrict is working fine.
#
create table t1 (f1 int primary key) engine=innodb;
delete from t1 where f1 = 29;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`fk_29`, CONSTRAINT `pc29` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`))
select * from fk_29;
f1
29
drop table t1;
#
# Testing robustness against random compression failures
#
CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SET GLOBAL innodb_simulate_comp_failures = 25;
SELECT COUNT(*) FROM t1;
COUNT(*)
100000
#
# Testing robustness against random compression failures
#
CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SET GLOBAL innodb_simulate_comp_failures = 25;
SELECT COUNT(*) FROM t1;
COUNT(*)
10000
--source include/have_innodb.inc
#
# Bug#16368875 INNODB: FAILING ASSERTION: PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0
#
create table t1 (f1 tinyblob not null) engine=innodb;
alter table t1 add unique index (f1(255));
drop table t1;
create table t1 (f1 tinyblob not null) engine=innodb;
alter table t1 add unique index (f1(356));
show create table t1;
drop table t1;
create table t1 (f1 point not null) engine=innodb;
alter table t1 add unique index (f1);
drop table t1;
--source include/have_innodb.inc
--source include/not_embedded.inc
--echo #
--echo # Bug #18806829 OPENING INNODB TABLES WITH MANY FOREIGN KEY
--echo # REFERENCES IS SLOW/CRASHES SEMAPHORE
--echo #
create table t1 (f1 int primary key) engine=innodb;
insert into t1 values (5);
insert into t1 values (2882);
insert into t1 values (10);
let $fk_tables = 120;
--disable_query_log
let $i = $fk_tables;
while ($i)
{
eval create table fk_$i (f1 int primary key,
constraint pc$i foreign key (f1) references t1(f1)
on delete cascade on update cascade) engine=innodb;
eval insert into fk_$i values (5);
eval insert into fk_$i values (2882);
eval insert into fk_$i values (10);
dec $i;
}
--enable_query_log
--source include/restart_mysqld.inc
update t1 set f1 = 28 where f1 = 2882;
select * from fk_120;
select * from fk_1;
select * from fk_50;
--disable_query_log
let $i = $fk_tables;
while ($i)
{
eval drop table fk_$i;
dec $i;
}
--enable_query_log
drop table t1;
--echo #
--echo # Check if restrict is working fine.
--echo #
create table t1 (f1 int primary key) engine=innodb;
let $fk_tables = 30;
--disable_query_log
let $i = $fk_tables;
while ($i)
{
eval create table fk_$i (f1 int primary key,
constraint pc$i foreign key (f1) references t1(f1)
on delete restrict on update restrict) engine=innodb;
eval insert into t1 values ($i);
eval insert into fk_$i values ($i);
dec $i;
}
--enable_query_log
--source include/restart_mysqld.inc
--error ER_ROW_IS_REFERENCED_2
delete from t1 where f1 = 29;
select * from fk_29;
--disable_query_log
let $i = $fk_tables;
while ($i)
{
eval drop table fk_$i;
dec $i;
}
--enable_query_log
drop table t1;
--lower-case-table-names=2
--lower-case-table-names=2
--source include/big_test.inc
# test takes too long with valgrind
--source include/not_valgrind.inc
--let $num_inserts = 100000
--let $num_ops = 30000
--source suite/innodb/include/innodb_simulate_comp_failures.inc
# clean exit
--exit
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