SAVEPOINTidentifier
ROLLBACK [WORK] TO [SAVEPOINT]identifier
RELEASE SAVEPOINTidentifier
InnoDB
supports the SQL statements SAVEPOINT
, ROLLBACK TO SAVEPOINT
, RELEASE SAVEPOINT
and the optional WORK
keyword for ROLLBACK
.InnoDB
支持SQL语句SAVEPOINT
、ROLLBACK TO SAVEPOINT
、RELEASE SAVEPOINT
和ROLLBACK
的可选WORK
关键字。
The SAVEPOINT
statement sets a named transaction savepoint with a name of identifier
. SAVEPOINT
语句设置一个名为identifier
的命名事务保存点。If the current transaction has a savepoint with the same name, the old savepoint is deleted and a new one is set.如果当前事务具有同名的保存点,则会删除旧的保存点并设置新的保存点。
The ROLLBACK TO SAVEPOINT
statement rolls back a transaction to the named savepoint without terminating the transaction. ROLLBACK TO SAVEPOINT
语句将事务回滚到指定的保存点,而不终止该事务。Modifications that the current transaction made to rows after the savepoint was set are undone in the rollback, but 设置保存点后,当前事务对行所做的修改将在回滚中撤消,但InnoDB
does not release the row locks that were stored in memory after the savepoint. InnoDB
不会释放保存点后存储在内存中的行锁。(For a new inserted row, the lock information is carried by the transaction ID stored in the row; the lock is not separately stored in memory. (对于新插入的行,锁信息由存储在该行中的事务ID携带;锁不单独存储在内存中。In this case, the row lock is released in the undo.) 在这种情况下,行锁定将在“撤消”中释放。)Savepoints that were set at a later time than the named savepoint are deleted.在指定保存点之后设置的保存点将被删除。
If the 如果ROLLBACK TO SAVEPOINT
statement returns the following error, it means that no savepoint with the specified name exists:ROLLBACK TO SAVEPOINT
语句返回以下错误,则表示不存在具有指定名称的保存点:
ERROR 1305 (42000): SAVEPOINT identifier
does not exist
The RELEASE SAVEPOINT
statement removes the named savepoint from the set of savepoints of the current transaction. RELEASE SAVEPOINT
语句从当前事务的保存点集中删除命名的保存点。No commit or rollback occurs. 不会发生提交或回滚。It is an error if the savepoint does not exist.如果保存点不存在,则为错误。
All savepoints of the current transaction are deleted if you execute a 如果执行未命名保存点的COMMIT
, or a ROLLBACK
that does not name a savepoint.COMMIT
或ROLLBACK
,则将删除当前事务的所有保存点。
A new savepoint level is created when a stored function is invoked or a trigger is activated. 调用存储函数或激活触发器时,将创建新的保存点级别。The savepoints on previous levels become unavailable and thus do not conflict with savepoints on the new level. 以前级别上的保存点不可用,因此不会与新级别上的保存点冲突。When the function or trigger terminates, any savepoints it created are released and the previous savepoint level is restored.当函数或触发器终止时,将释放它创建的所有保存点,并恢复以前的保存点级别。