mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
fdcf0aff02
Bug#46539 Various crashes on INSERT IGNORE SELECT + SELECT FOR UPDATE. If a transaction was rolled back inside InnoDB due to a deadlock or lock wait timeout, and the statement had IGNORE clause, the server could crash at the end of the statement or on shutdown. This was caused by the error handling infrastructure's attempt to ignore a non-ignorable error. When a transaction rollback request is raised, switch off current_select->no_error flag, so that the following error won't be ignored. Instead, we could add !thd->is_fatal_sub_stmt_error to my_message_sql(), but since in write_record() we switch off no_error, the same approach is used in thd_mark_transaction_to_rollback(). @todo: call thd_mark_transaction_to_rollback() from handler::print_error(), then we can easily make sure that the error reported by print_error is not ignored.
75 lines
1.6 KiB
Text
75 lines
1.6 KiB
Text
--source include/have_innodb.inc
|
|
|
|
--echo #
|
|
--echo # Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout
|
|
--echo # without error
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 (a,b) VALUES (1070109,99);
|
|
|
|
CREATE TABLE t2 (b int, a int, PRIMARY KEY (b)) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t2 (b,a) VALUES (7,1070109);
|
|
|
|
SELECT * FROM t1;
|
|
|
|
BEGIN;
|
|
|
|
SELECT b FROM t2 WHERE b=7 FOR UPDATE;
|
|
|
|
CONNECT (addconroot, localhost, root,,);
|
|
CONNECTION addconroot;
|
|
|
|
BEGIN;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
SELECT b FROM t2 WHERE b=7 FOR UPDATE;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 (a) VALUES ((SELECT a FROM t2 WHERE b=7));
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
UPDATE t1 SET a='7000000' WHERE a=(SELECT a FROM t2 WHERE b=7);
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
DELETE FROM t1 WHERE a=(SELECT a FROM t2 WHERE b=7);
|
|
|
|
SELECT * FROM t1;
|
|
|
|
CONNECTION default;
|
|
DISCONNECT addconroot;
|
|
|
|
DROP TABLE t2, t1;
|
|
|
|
--echo # End of 5.0 tests
|
|
|
|
--echo #
|
|
--echo # Bug#46539 Various crashes on INSERT IGNORE SELECT + SELECT
|
|
--echo # FOR UPDATE
|
|
--echo #
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
create table t1 (a int primary key auto_increment,
|
|
b int, index(b)) engine=innodb;
|
|
insert into t1 (b) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
|
set autocommit=0;
|
|
begin;
|
|
select * from t1 where b=5 for update;
|
|
connect (con1, localhost, root,,);
|
|
connection con1;
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
insert ignore into t1 (b) select a as b from t1;
|
|
connection default;
|
|
--echo # Cleanup
|
|
--echo #
|
|
disconnect con1;
|
|
commit;
|
|
set autocommit=default;
|
|
drop table t1;
|
|
|
|
--echo #
|
|
--echo # End of 5.1 tests
|
|
--echo #
|