Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clientside transactions #3

Open
SevDan opened this issue Jan 9, 2021 · 1 comment
Open

Clientside transactions #3

SevDan opened this issue Jan 9, 2021 · 1 comment

Comments

@SevDan
Copy link

SevDan commented Jan 9, 2021

There is good way to implement user transactions

Example API:

userdata pg_begin_tx(userdata connection)
Execute query CREATE TRANSACTION, set it status 'open' and save into local transactions storage.

userdata pg_rollback_tx(userdata transaction)
Get transaction from storage. If transaction is open and valid, rollback it with ROLLBACK and set 'rollbacked' status.
Abort transaction when has no instances in storage

userdata pg_commit_tx(userdata transaction)
Get transaction from storage and commit it with COMMIT if opened and set 'commited' status.
Abort transaction when has no instances in storage

Client database transactions control implementation may prevent problems with concurrent execution and add more performance features (for instance, execute whole transaction in one query)

@SevDan SevDan changed the title High level transactions Clientside transactions Jan 9, 2021
@SevDan
Copy link
Author

SevDan commented Jan 10, 2021

Maybe should implement easier API (adopted for single thread applications)
bool pg_tx_begin(userdata connection)
Creates new transaction only if has no opened other yet

bool pg_tx_commit(userdata connection)
Commit current transaction

bool pg_tx_rollback(userdata connection)
Rollback current transaction

So, API supports operations only one transaction per connection (without subtransactions)

SevDan added a commit to SevDan/ml_pgsql that referenced this issue Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant