Here is a quick patch that should get rid of the "commit twice" code.
I also removed explicit rollback, as it is not required (SQLite3 rolls
back by itself when things aren't good).
Note also that the default return code was changed to -1 in this
patch. It is normally an error to end a transaction that that was
never started, so this change is trying to emulate that behaviour.
I'll test this and wait for the feedback before I commit.
--
Bojan
Index: apr_dbd_sqlite3.c
===================================================================
--- apr_dbd_sqlite3.c (revision 397754)
+++ apr_dbd_sqlite3.c (working copy)
@@ -351,17 +351,11 @@
static int dbd_sqlite3_end_transaction(apr_dbd_transaction_t *trans)
{
- int ret = 0;
+ int ret = -1; /* ending transaction that was never started is an error */
int nrows = 0;
if (trans) {
ret = dbd_sqlite3_query(trans->handle, &nrows, "END TRANSACTION;");
- if (trans->errnum) {
- trans->errnum = 0;
- ret = dbd_sqlite3_query(trans->handle, &nrows, "ROLLBACK;");
- } else {
- ret = dbd_sqlite3_query(trans->handle, &nrows, "COMMIT;");
- }
trans->handle->trans = NULL;
}