Back to index
This class wraps a transaction inside a given C++ scope, guaranteeing that the transaction will be completed even if you have an exception or return early. More...
|mozStorageTransaction (mozIStorageConnection *aConnection, PRBool aCommitOnComplete, PRInt32 aType=mozIStorageConnection::TRANSACTION_DEFERRED)|
|Commits the transaction if one is in progress. |
|Rolls back the transaction in progress. |
|Returns whether this object wraps a real transaction. |
|void||SetDefaultAction (PRBool aCommitOnComplete)|
|This sets the default action (commit or rollback) when this object goes out of scope. |
|nsCOMPtr< mozIStorageConnection >||mConnection|
This class wraps a transaction inside a given C++ scope, guaranteeing that the transaction will be completed even if you have an exception or return early.
aCommitOnComplete controls whether the transaction is committed or rolled back when it goes out of scope. A common use is to create an instance with commitOnComplete = FALSE (rollback), then call Commit on this object manually when your function completes successfully.
Note that nested transactions are not supported by sqlite, so if a transaction is already in progress, this object does nothing. Note that in this case, you may not get the transaction type you ask for, and you won't be able to rollback.
Commits the transaction if one is in progress.
If one is not in progress, this is a NOP since the actual owner of the transaction outside of our scope is in charge of finally comitting or rolling back the transaction.
Rolls back the transaction in progress.
You should only call this function if this object has a real transaction (HasTransaction() = true) because otherwise, there is no transaction to roll back.