START TRANSACTION(或者begin); SAVEPOINT point1; if ???? then ROLLBACK TO SAVEPOINT point1;
#(回滚到SAVEPOINT处) else ....... end if;
COMMIT;(必须,否则会引起Lock wait timeout exceeded; try restarting transaction的错误,并导致所操作的表被死锁)