1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-31 22:22:30 +03:00
Files
mariadb/mysql-test/suite/innodb/t/lock_insert_into_empty.test
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

42 lines
894 B
Plaintext

--source include/have_innodb.inc
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;
--error ER_DUP_ENTRY
INSERT INTO t2 VALUES(1),(1);
connect (con1,localhost,root,,);
BEGIN;
SELECT * FROM t2 LOCK IN SHARE MODE;
connection default;
SET innodb_lock_wait_timeout=1;
--error ER_LOCK_WAIT_TIMEOUT
INSERT INTO t2 VALUES(2);
disconnect con1;
INSERT INTO t2 VALUES(3);
COMMIT;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-24700 Assertion "lock not found"==0 in lock_table_x_unlock()
--echo #
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);
--error ER_NO_REFERENCED_ROW_2
REPLACE INTO t1 VALUES (1,12);
COMMIT;
DROP TABLE t1;