Close a MySql connection without commit or rollback in C # asp.net

2

I would like to know what happens in the following scenario:

In a program with was opened MySqlConnection , then started a MySqlTransaction , was done insert in the open transaction, however, instead of giving a commit or rollback in the transaction, the connection is closed.

What would happen to the transaction?

    
asked by anonymous 25.02.2014 / 17:51

1 answer

5

If the connection is disconnected before reaching COMMIT , an automatic ROLLBACK occurs.

Documentation :

  

With START TRANSACTION, autocommit remains disabled until you end the transaction with COMMIT or ROLLBACK. The autocommit mode then reverts to its previous state.

  

After disabling autocommit mode by setting the autocommit variable to zero, changes to transaction-safe tables (such as those for InnoDB or NDB) are not made permanent immediately. You must use COMMIT to store your changes to disk or ROLLBACK to ignore the changes.

Basically, when you start a transaction the autocommit flag is turned off. While it remains off, the changes are not persisted until a COMMIT is executed. If the link goes down, the changes have never been persisted - and therefore have no effect.

    
25.02.2014 / 17:54