Set autocommit=0 refers to a transaction that is not automatically committed, since the execution of this sentence, each SQL statement or statement block the transaction needs to display "commit" to commit the transaction.
1, whether autocommit is 1 or 0
After START TRANSACTION, only if the commit data will take effect, the rollback will be rolled back.
2, when autocommit is 0 o'clock
Whether or not there is a start TRANSACTION.
Only if the commit data will take effect will it be rolled back after rollback.
3, if the autocommit is 1, and there is no start TRANSACTION.
It is useless to call rollback. Even if the savepoint is set.
Roll back success
Set autocommit =1;delimiter $ $DROP PROCEDURE IF EXISTS mmmm $$ CREATE definer= ' tms_admin ' @ '% ' PROCEDURE ' mmmm ' () BEGIN DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER for sqlexception,sqlwarning,not FOUND SET t_error=1; START TRANSACTION; SavePoint P1; Update T_user Set instance_seq_id = ' tt00006 '; Update T_user Set instance_seq_id000 = ' tt00007 '; IF t_error = 1 then ROLLBACK to P1; ELSE COMMIT; END IF; end$ $DELIMITER; Call ' tms_inst_tt00003 '. ' Mmmm ' ();
Set autocommit =0;delimiter $ $DROP PROCEDURE IF EXISTS mmmm $$ CREATE definer= ' tms_admin ' @ '% ' PROCEDURE ' mmmm ' () BEGIN DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER for sqlexception,sqlwarning,not FOUND SET t_error=1; START TRANSACTION; SavePoint P1; Update T_user Set instance_seq_id = ' tt00006 '; Update T_user Set instance_seq_id000 = ' tt00007 '; IF t_error = 1 then ROLLBACK to P1; ELSE COMMIT; END IF; end$ $DELIMITER; Call ' tms_inst_tt00003 '. ' Mmmm ' ();
Roll back success
Set autocommit =0;delimiter $ $DROP PROCEDURE IF EXISTS mmmm $$ CREATE definer= ' tms_admin ' @ '% ' PROCEDURE ' mmmm ' () BEGIN DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER for sqlexception,sqlwarning,not FOUND SET t_error=1; SavePoint P1; Update T_user Set instance_seq_id = ' tt00006 '; Update T_user Set instance_seq_id000 = ' tt00007 '; IF t_error = 1 then ROLLBACK to P1; ELSE COMMIT; END IF; end$ $DELIMITER;
Roll back success
The difference between set autocommit=0 and start transaction in MySQL