MDEV-29975 InnoDB fails to release savepoint during bulk insert

- InnoDB does rollback the whole transaction and discards the
savepoint when there is a failure happens during bulk
insert operation. When server request to release the savepoint,
InnoDB should return DB_SUCCESS when it deals with bulk
insert operation
parent a55b951e
......@@ -214,4 +214,19 @@ WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
DROP TABLE t1;
#
# MDEV-29975 InnoDB fails to release savepoint during bulk insert
#
CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
begin;
INSERT INTO t VALUES (0,0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT a;
INSERT INTO t VALUES (0),(0);
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
SAVEPOINT a;
commit;
SELECT * FROM t;
c
DROP TABLE t;
# End of 10.6 tests
......@@ -233,4 +233,18 @@ SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
DROP TABLE t1;
--echo #
--echo # MDEV-29975 InnoDB fails to release savepoint during bulk insert
--echo #
CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
begin;
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES (0,0);
SAVEPOINT a;
--error ER_DUP_ENTRY
INSERT INTO t VALUES (0),(0);
SAVEPOINT a;
commit;
SELECT * FROM t;
DROP TABLE t;
--echo # End of 10.6 tests
......@@ -558,9 +558,13 @@ trx_release_savepoint_for_mysql(
if (savep != NULL) {
trx_roll_savepoint_free(trx, savep);
return DB_SUCCESS;
} else if (trx->last_sql_stat_start.least_undo_no == 0) {
/* Bulk insert could have discarded savepoints */
return DB_SUCCESS;
}
return(savep != NULL ? DB_SUCCESS : DB_NO_SAVEPOINT);
return DB_NO_SAVEPOINT;
}
/*******************************************************************//**
......
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