1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-30 11:22:14 +03:00
Files
mariadb/mysql-test/suite/innodb/r/lock_insert_into_empty.result
Marko Mäkelä 5dd028f8ee MDEV-24700 Assertion "lock not found"==0 in lock_table_x_unlock()
After an ignored INSERT IGNORE statement into an empty table, we would
wrongly use the MDEV-515 table-level undo logging for a subsequent
REPLACE statement.

ha_innobase::reset_template(): Clear m_prebuilt->ins_node->bulk_insert
on every statement boundary.

ha_innobase::start_stmt(): Invoke end_bulk_insert().

ha_innobase::extra(): Avoid accessing m_prebuilt->trx. Do not call
thd_to_trx(). Invoke end_bulk_insert() and try to reset bulk_insert
when changing the REPLACE or IGNORE settings.

trx_mod_table_time_t::WAS_BULK: Use a distinct value from BULK.

trx_undo_report_row_operation(): Add debug assertions.

Note: Some calls to end_bulk_insert() may be redundant, but statement
boundaries are not always clear in the API (especially in the
presence of LOCK TABLES or stored procedures).
2021-01-27 16:54:38 +02:00

40 lines
1.2 KiB
Plaintext

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(0);
BEGIN;
DELETE FROM t1;
INSERT INTO t2 VALUES(1),(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
connect con1,localhost,root,,;
BEGIN;
SELECT * FROM t2 LOCK IN SHARE MODE;
a
connection default;
SET innodb_lock_wait_timeout=1;
INSERT INTO t2 VALUES(2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
INSERT INTO t2 VALUES(3);
COMMIT;
SELECT * FROM t1;
a
SELECT * FROM t2;
a
3
DROP TABLE t1, t2;
#
# MDEV-24700 Assertion "lock not found"==0 in lock_table_x_unlock()
#
SET FOREIGN_KEY_CHECKS=OFF;
CREATE TABLE t1 (id INT PRIMARY KEY, f INT REFERENCES nonexistent(x))
ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=ON;
BEGIN;
INSERT IGNORE INTO t1 VALUES (1,11);
Warnings:
Warning 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`))
REPLACE INTO t1 VALUES (1,12);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`))
COMMIT;
DROP TABLE t1;