MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned

- Trigger statement initiate update statement after bulk insert
operation and leads to disable of bulk operation. During commit,
InnoDB expects transaction to be in bulk insert mode before
applying the bulk insert operation. InnoDB transaction should
apply all bulk insert operation before disabling bulk insert
operation.
parent e858fc89
......@@ -268,3 +268,16 @@ INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(0),(0);
ERROR HY000: Got error 1 "Operation not permitted" during COMMIT
DELETE FROM t1;
DROP TABLE t1;
#
# MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned
#
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW UPDATE t2 SET c=1;
INSERT INTO t1 VALUES (0);
SELECT * FROM t1;
c
0
SELECT * FROM t2;
c
DROP TABLE t2, t1;
......@@ -281,3 +281,14 @@ CREATE TABLE t1 (c0 YEAR UNIQUE) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(0),(0);
DELETE FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-28037 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned
--echo #
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW UPDATE t2 SET c=1;
INSERT INTO t1 VALUES (0);
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t2, t1;
......@@ -15836,6 +15836,12 @@ ha_innobase::start_stmt(
if (!trx->bulk_insert) {
break;
}
/* Trigger could've initiated another stmt.
So apply all bulk operation and mark as
end bulk insert for all tables */
trx->bulk_insert_apply();
trx->end_bulk_insert();
trx->bulk_insert = false;
trx->last_sql_stat_start.least_undo_no = trx->undo_no;
}
......
Markdown is supported
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