mariadb/mysql-test/suite/binlog_in_engine/not_implemented_yet.test
Kristian Nielsen 68042221e6 MDEV-38465: Savepoint in trigger causes transactional inconsistency
SAVEPOINT inside a trigger doesn't work correctly. Setting a savepoint
inside a trigger somehow loses the implicit savepoint set at transaction
start, so that the partial changes are left if the statement later fails.
Referencing an existing savepoint claims the savepoint does not exist (and
it is in any case very unclear what exactly it should mean to rollback to a
savepoint from the middle of a statement, or set in the middle of a prior
statement).

These problems are independent of binlog-in-engine, but in the new binlog
implementation we are trying to make things work more correctly and
robustly, so let's disallow use of savepoints inside triggers. The new
binlog is off by default, so backwards compatibility is less of a concern,
though arguably disallowing savepoints in triggers would be better done
unconditionally.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-01-23 03:23:20 +01:00

34 lines
1.1 KiB
Text

--source include/have_binlog_format_mixed.inc
--source include/have_innodb_binlog.inc
--error ER_NOT_YET_SUPPORTED_ENGINE_BINLOG
SET GLOBAL rpl_semi_sync_master_enabled= 1;
# The BINLOG_GTID_POS() function is not available and will not be, we
# want to get away from old problematic filename/offset coordinates.
--error ER_NOT_AVAILABLE_WITH_ENGINE_BINLOG
SELECT BINLOG_GTID_POS("binlog-000000.ibb", 4096);
# MDEV-38465: Savepoint in trigger causes transactional inconsistency.
CREATE TABLE t (a INT) ENGINE=InnoDB;
--delimiter $
CREATE TRIGGER tr AFTER INSERT ON t FOR EACH ROW BEGIN SAVEPOINT A; DELETE FROM non_existing; END $
--delimiter ;
START TRANSACTION;
--error ER_NOT_AVAILABLE_WITH_ENGINE_BINLOG
INSERT INTO t VALUES (1), (3);
COMMIT;
SELECT * FROM t ORDER BY a;
DROP TRIGGER tr;
--delimiter $
CREATE TRIGGER tr AFTER INSERT ON t FOR EACH ROW BEGIN ROLLBACK TO SAVEPOINT B; DELETE FROM non_existing; END $
--delimiter ;
START TRANSACTION;
SAVEPOINT B;
--error ER_NOT_AVAILABLE_WITH_ENGINE_BINLOG
INSERT INTO t VALUES (11), (13);
COMMIT;
SELECT * FROM t ORDER BY a;
DROP TRIGGER tr;
DROP TABLE t;