From what I read and understood in https://mysqlserverteam.com/mysql-connection-handling-and-scaling/
Each connection have a THD object and what ever we update or insert using that is stored in THD and gets committed to the DB.
In case of transaction, especially programmatic transactions, My understanding is, we hold on the connection till we are done with our operations and then commit. meanwhile we can do both DB related updates OR inserts and other calculations that may result in some exception/errors. example :
Begin;
IN-Transaction :
UPDATE Table-1
c = A/B
Insert Table-2 with c
... so on
Commit;
in this programmatic transactions, we have to pass a reference of transaction for doing multiple DB operations, and that reference is not a transaction object, rather a connection and there is one-to-one mapping between connection and a transaction context. If we encounter an exception, we do a rollback and DB understand that it needs to discard THD related changes.
My questions are :
Is my understanding correct, If somethings missing, please help me with that!!.
If this is correct, is it the same strategy used in any other DB like postgres Or maria Or voltDB ??
If it is incorrect, how is it implemented in mysql, postgres, voltDB etc..? Can you point me to relevant links where I can get better idea!!.
thanks.
However there are rare exceptions like distributed transactions using two-phase commit protocol where a single transaction runs on different sessions on different databases.
You must also take into account that some client tools (for example psql for PostgreSQL) or JDBC API for Java have defaults settings that change a little bit this behaviour: both implement auto-commit mode after each statement (this means that each SQL statement runs in its own transaction) but you can change this behaviour in each tool.