h2database / h2database/h2database
Suspicious auto-commit logic in BEGIN + (COMMIT | ROLLBACK)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 1.3k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Description
H2 has an undocumented non-standard BEGIN [ WORK | TRANSACTION ] command.
https://github.com/h2database/h2database/blob/6b359b683cd4899f96f42a914cc511b310461c15/h2/src/main/org/h2/command/Parser.java#L1046-L1053
https://github.com/h2database/h2database/blob/6b359b683cd4899f96f42a914cc511b310461c15/h2/src/main/org/h2/command/dml/TransactionCommand.java#L42-L44
Perhaps this command exists for compatibility with some other databases
https://docs.microsoft.com/sql/t-sql/language-elements/begin-transaction-transact-sql?view=sql-server-2017
https://www.ibm.com/support/knowledgecenter/en/SSGU8G_14.1.0/com.ibm.sqls.doc/ids_sqs_0329.htm
The command sets Session.autoCommit to false and Session.autoCommitAtTransactionEnd to true.
https://github.com/h2database/h2database/blob/6b359b683cd4899f96f42a914cc511b310461c15/h2/src/main/org/h2/engine/Session.java#L1462-L1465
COMMIT and ROLLBACK commands set Session.autoCommit to the value of Session.autoCommitAtTransactionEnd (true) and reset Session.autoCommitAtTransactionEnd back to false.
https://github.com/h2database/h2database/blob/6b359b683cd4899f96f42a914cc511b310461c15/h2/src/main/org/h2/engine/Session.java#L700-L703
https://github.com/h2database/h2database/blob/6b359b683cd4899f96f42a914cc511b310461c15/h2/src/main/org/h2/engine/Session.java#L805-L808
It means that combinations of BEGIN WORK + COMMIT WORK or BEGIN TRANSACTION + COMMIT and similar enable the auto-commit in the session uncoditionally. Perhaps they should not enable it if it wasn't enabled before the BEGIN …?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced BEGIN handling in Parser.java and TransactionCommand.java, then trace Session.autoCommit and Session.autoCommitAtTransactionEnd at the referenced Session.java locations. Reproduce BEGIN WORK or BEGIN TRANSACTION followed by COMMIT or ROLLBACK, and verify that the final auto-commit state matches the state before BEGIN rather than being enabled unconditionally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100