Functions | |
| struct evsql_trans * | evsql_trans (struct evsql *evsql, enum evsql_trans_type type, evsql_trans_error_cb error_fn, evsql_trans_ready_cb ready_fn, evsql_trans_done_cb done_fn, void *cb_arg) |
| Create a new transaction. | |
| int | evsql_trans_commit (struct evsql_trans *trans) |
| Commit a transaction using "COMMIT TRANSACTION". | |
| void | evsql_trans_abort (struct evsql_trans *trans) |
| Abort a transaction, using "ROLLBACK TRANSACTION". | |
| const char * | evsql_trans_error (struct evsql_trans *trans) |
| Retrieve the transaction-specific error message from the underlying engine. | |
| struct evsql_trans* evsql_trans | ( | struct evsql * | evsql, | |
| enum evsql_trans_type | type, | |||
| evsql_trans_error_cb | error_fn, | |||
| evsql_trans_ready_cb | ready_fn, | |||
| evsql_trans_done_cb | done_fn, | |||
| void * | cb_arg | |||
| ) | [read] |
Create a new transaction.
A transaction will be allocated its own connection, and the "BEGIN TRANSACTION ..." query will be sent (use the type argument to specify this).
Once the transaction has been opened, the given ready_fn will be triggered, and the transaction can then be used (see Query interface).
If, at any point, the transaction-connection fails, any pending query will be forgotten (i.e. the query callback will NOT be called), and the given error_fn will be called. Note that this includes some, but not all, cases where Query interface returns an error.
Once you are done with the transaction, call either evsql_trans_commit() or evsql_trans_abort().
| evsql | the context handle from Session creation interface | |
| type | the type of transaction to create | |
| error_fn | the evsql_trans_error_cb() to call if this transaction fails | |
| ready_fn | the evsql_trans_ready_cb() to call once this transaction is ready for use | |
| done_fn | the evsql_trans_done_cb() to call once this transaction has been commmited | |
| cb_arg | the void* to pass to the above |
| void evsql_trans_abort | ( | struct evsql_trans * | trans | ) |
Abort a transaction, using "ROLLBACK TRANSACTION".
No more transaction callbacks will be called. If there was a query running, it will be aborted, and the transaction then rollback'd.
You cannot abort a COMMIT, calling trans_abort on trans after a call to trans_commit is an error.
Do not call evsql_trans_abort from within evsql_trans_error_cb()!
| trans | the transaction from evsql_trans to abort |
| int evsql_trans_commit | ( | struct evsql_trans * | trans | ) |
Commit a transaction using "COMMIT TRANSACTION".
The transaction must be idle, just like for evsql_query. Once the transaction has been commited, the transaction's done_fn will be called, after which the transaction must not be used anymore.
You cannot abort a COMMIT, calling trans_abort() on trans after a succesful trans_commit is an error.
Note that done_fn will never be called directly, always indirectly via the event loop.
| trans | the transaction handle from evsql_trans to commit |
| const char* evsql_trans_error | ( | struct evsql_trans * | trans | ) |
Retrieve the transaction-specific error message from the underlying engine.
Intended to be called from evsql_trans_error_cb()
1.5.6