Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.11' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abarkov committed Aug 18, 2023
2 parents 5f6e987 + 725bd56 commit baf00fc
Show file tree
Hide file tree
Showing 41 changed files with 1,072 additions and 297 deletions.
4 changes: 0 additions & 4 deletions mysql-test/main/having_cond_pushdown.result
Expand Up @@ -5986,12 +5986,8 @@ SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL);
i
SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL AND 'x' = 0);
i
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: 'x'
SELECT * FROM t1 GROUP BY i HAVING i='1' IN ( i IS NULL AND 'x' = 0);
i
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: 'x'
DROP TABLE t1;
#
# MDEV-28080: HAVING with NOT EXIST predicate in an equality
Expand Down
35 changes: 35 additions & 0 deletions mysql-test/main/prepare.result
Expand Up @@ -80,3 +80,38 @@ drop table t1, t2, t3;
#
# End of 10.4 tests
#
#
# MDEV-9938 Prepared statement return wrong result (missing row)
#
CREATE TABLE t1 (a_id INT AUTO_INCREMENT PRIMARY KEY, a_text VARCHAR(20));
CREATE TABLE t2 (b_id INT AUTO_INCREMENT PRIMARY KEY, b_a_id INT);
INSERT INTO t1 VALUES (NULL, 'word1');
INSERT INTO t2 VALUES (NULL, 1), (NULL, NULL);
PREPARE q FROM 'SELECT * FROM t2
LEFT JOIN t1 ON (t1.a_id = t2.b_a_id)
WHERE ((? IS NULL) OR (t1.a_text = ?))';
SET @var = 'word1';
expect row count 1
EXECUTE q USING @var, @var;
b_id b_a_id a_id a_text
1 1 1 word1
expect row count = 2
EXECUTE q USING @nul, @nul;
b_id b_a_id a_id a_text
1 1 1 word1
2 NULL NULL NULL
PREPARE q2 FROM 'SELECT * FROM t2
LEFT JOIN t1 ON (t1.a_id = t2.b_a_id)
WHERE ((? IS NULL) OR (t1.a_text = ?))';
expect row count 2
SET @var = 'word1';
EXECUTE q2 USING @nul, @nul;
b_id b_a_id a_id a_text
1 1 1 word1
2 NULL NULL NULL
deallocate prepare q;
deallocate prepare q2;
drop table t1,t2;
#
# End of 10.6 tests
#
36 changes: 36 additions & 0 deletions mysql-test/main/prepare.test
Expand Up @@ -69,3 +69,39 @@ drop table t1, t2, t3;
--echo #
--echo # End of 10.4 tests
--echo #

--echo #
--echo # MDEV-9938 Prepared statement return wrong result (missing row)
--echo #

CREATE TABLE t1 (a_id INT AUTO_INCREMENT PRIMARY KEY, a_text VARCHAR(20));
CREATE TABLE t2 (b_id INT AUTO_INCREMENT PRIMARY KEY, b_a_id INT);

INSERT INTO t1 VALUES (NULL, 'word1');
INSERT INTO t2 VALUES (NULL, 1), (NULL, NULL);

PREPARE q FROM 'SELECT * FROM t2
LEFT JOIN t1 ON (t1.a_id = t2.b_a_id)
WHERE ((? IS NULL) OR (t1.a_text = ?))';

SET @var = 'word1';
--echo expect row count 1
EXECUTE q USING @var, @var;
--echo expect row count = 2
EXECUTE q USING @nul, @nul;

PREPARE q2 FROM 'SELECT * FROM t2
LEFT JOIN t1 ON (t1.a_id = t2.b_a_id)
WHERE ((? IS NULL) OR (t1.a_text = ?))';

--echo expect row count 2
SET @var = 'word1';
EXECUTE q2 USING @nul, @nul;

deallocate prepare q;
deallocate prepare q2;
drop table t1,t2;

--echo #
--echo # End of 10.6 tests
--echo #
7 changes: 7 additions & 0 deletions mysql-test/main/ps.result
Expand Up @@ -4092,9 +4092,16 @@ DROP TABLE t1, t2;
#
CREATE TABLE t1 (a INT);
PREPARE stmt FROM "SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1";
execute stmt;
1
SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1;
1
insert into t1 values(1),(2);
execute stmt;
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 + 1'
SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1;
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 + 1'
deallocate prepare stmt;
drop table t1;
# End of 5.3 tests
#
Expand Down
8 changes: 6 additions & 2 deletions mysql-test/main/ps.test
Expand Up @@ -3632,12 +3632,16 @@ DROP TABLE t1, t2;
--echo # with out of range in GROUP BY
--echo #
CREATE TABLE t1 (a INT);

--error ER_DATA_OUT_OF_RANGE
PREPARE stmt FROM "SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1";
execute stmt;
SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1;
insert into t1 values(1),(2);
--error ER_DATA_OUT_OF_RANGE
execute stmt;
--error ER_DATA_OUT_OF_RANGE
SELECT 1 FROM t1 GROUP BY 0 OR 18446744073709551615+1;

deallocate prepare stmt;
drop table t1;

--echo # End of 5.3 tests
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/main/range.result
Expand Up @@ -1637,8 +1637,6 @@ NULL
Warnings:
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
1
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/main/range_mrr_icp.result
Expand Up @@ -1640,8 +1640,6 @@ NULL
Warnings:
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
1
Expand Down
39 changes: 39 additions & 0 deletions mysql-test/main/show_analyze.result
Expand Up @@ -440,3 +440,42 @@ ANALYZE
}
}
DROP TABLE t1;
#
# MDEV-31432 tmp_table field accessed after free
# testing for the above (MDEV-28201) caused use after free error
#
create table t1 (x int) engine=myisam;
insert into t1 values(1);
set @tmp=@@optimizer_trace;
set @@optimizer_trace=1;
SELECT
1 IN
((
SELECT
1 IN (SELECT 1 AS x0
FROM
(
SELECT *
FROM (SELECT 1 AS x) AS x5
GROUP BY x,x
HAVING
x IN (
SELECT *
FROM t1 AS x1
WHERE
x IN (SELECT 1 AS x
FROM t1 AS x3
GROUP BY x
HAVING
x IN (SELECT 0 FROM t1 AS x4)
)
)
) AS x6
)
FROM
t1
)) as VAL;
VAL
0
set optimizer_trace=@tmp;
drop table t1;
41 changes: 41 additions & 0 deletions mysql-test/main/show_analyze.test
Expand Up @@ -364,3 +364,44 @@ ANALYZE format=json
SELECT 1 FROM t1 GROUP BY convert_tz('1969-12-31 22:00:00',a,'+10:00');
DROP TABLE t1;

--echo #
--echo # MDEV-31432 tmp_table field accessed after free
--echo # testing for the above (MDEV-28201) caused use after free error
--echo #
create table t1 (x int) engine=myisam;
insert into t1 values(1);
set @tmp=@@optimizer_trace;
set @@optimizer_trace=1;
# Different warning text is produced in regular and --ps-protocol runs:
--disable_warnings
SELECT
1 IN
((
SELECT
1 IN (SELECT 1 AS x0
FROM
(
SELECT *
FROM (SELECT 1 AS x) AS x5
GROUP BY x,x
HAVING
x IN (
SELECT *
FROM t1 AS x1
WHERE
x IN (SELECT 1 AS x
FROM t1 AS x3
GROUP BY x
HAVING
x IN (SELECT 0 FROM t1 AS x4)
)
)
) AS x6
)
FROM
t1
)) as VAL;
--enable_warnings
set optimizer_trace=@tmp;
drop table t1;

4 changes: 2 additions & 2 deletions mysql-test/main/subselect_exists2in.result
Expand Up @@ -338,7 +338,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in ( <materialize> (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` is not null ), <primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
Expand All @@ -352,7 +352,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !(1 is not null and <in_optimizer>(1,1 in ( <materialize> (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` is not null ), <primary_index_lookup>(1 in <temporary table> on distinct_key where 1 = `<subquery3>`.`c`))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/view.result
Expand Up @@ -4638,7 +4638,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or 1) having trigcond(NULL is null))))
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or <cache>(NULL is null)) having trigcond(NULL is null))))
SELECT * FROM t1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= t1.a);
Expand All @@ -4654,7 +4654,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or 1) having trigcond(NULL is null))))
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where !<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(/* select#2 */ select NULL from `test`.`t4` where `test`.`t4`.`a` >= `test`.`t1`.`a` and trigcond(<cache>(10) = NULL or <cache>(NULL is null)) having trigcond(NULL is null))))
SELECT * FROM v1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= v1.a);
Expand Down
95 changes: 95 additions & 0 deletions mysql-test/suite/rpl/r/rpl_parallel_autoinc.result
@@ -0,0 +1,95 @@
include/master-slave.inc
[connection master]
MDEV-31482: Lock wait timeout with INSERT-SELECT, autoinc, and statement-based replication
include/rpl_connect.inc [creating slave2]
include/rpl_connect.inc [creating slave3]
connection master;
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b INT, c INT, INDEX (c)) ENGINE=InnoDB;
INSERT INTO t1 (b,c) VALUES (0, 1), (0, 1), (0, 2), (0,3), (0, 5), (0, 7), (0, 8);
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (10,1), (20,2), (30,3), (40,4), (50,5);
CREATE TABLE t3 (a VARCHAR(20) PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t3 VALUES ('row for T1', 0), ('row for T2', 0), ('row for T3', 0);
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
set @@global.slave_parallel_threads= 3;
set @@global.slave_parallel_mode= OPTIMISTIC;
set @@global.innodb_lock_wait_timeout= 20;
connection master;
BEGIN;
UPDATE t3 SET b=b+1 where a="row for T1";
INSERT INTO t1(b, c) SELECT 1, t2.b FROM t2 WHERE a=10;
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
COMMIT;
DELETE FROM t1 WHERE c >= 4 and c < 6;
BEGIN;
UPDATE t3 SET b=b+1 where a="row for T3";
INSERT INTO t1(b, c) SELECT 3, t2.b FROM t2 WHERE a >= 20 AND a <= 40;
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
COMMIT;
include/save_master_gtid.inc
connection slave1;
BEGIN;
SELECT * FROM t3 WHERE a="row for T1" FOR UPDATE;
a b
row for T1 0
connection slave2;
BEGIN;
SELECT * FROM t3 WHERE a="row for T3" FOR UPDATE;
a b
row for T3 0
connection slave3;
BEGIN;
DELETE FROM t2 WHERE a=30;
connection slave;
include/start_slave.inc
connection slave2;
ROLLBACK;
connection slave1;
ROLLBACK;
connection slave3;
ROLLBACK;
connection slave;
include/sync_with_master_gtid.inc
SELECT * FROM t1 ORDER BY a;
a b c
1 0 1
2 0 1
3 0 2
4 0 3
6 0 7
7 0 8
8 1 1
9 3 2
10 3 3
11 3 4
SELECT * FROM t2 ORDER BY a;
a b
10 1
20 2
30 3
40 4
50 5
SELECT * FROM t3 ORDER BY a;
a b
row for T1 1
row for T2 0
row for T3 1
connection master;
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
DROP TABLE t1, t2, t3;
connection slave;
include/stop_slave.inc
SET @@global.slave_parallel_threads= 0;
SET @@global.slave_parallel_mode= optimistic;
SET @@global.innodb_lock_wait_timeout= 50;
include/start_slave.inc
SELECT @@GLOBAL.innodb_autoinc_lock_mode;
@@GLOBAL.innodb_autoinc_lock_mode
1
include/rpl_end.inc

0 comments on commit baf00fc

Please sign in to comment.