Close a Mysql connection without committing or rollback to c# Asp.net

Asked

Viewed 512 times

2

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

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

What would happen with the transaction?

1 answer

5


If the connection is disconnected before reaching the COMMIT, happens a ROLLBACK automatic.

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 flag autocommit is unchecked. While remaining unchecked, changes are not persisted until a COMMIT. If the link falls, the changes have never been persisted - and therefore have no effect.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.