static int dbd_sqlite3_end_transaction(apr_dbd_transaction_t *trans) { int ret = -1; /* ending transaction that was never started is an error */ int nrows = 0; if (trans) { 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; } return ret; }
static int dbd_sqlite3_end_transaction(apr_dbd_transaction_t *trans) { int ret = -1; /* ending transaction that was never started is an error */ int nrows = 0; if (trans) { /* rollback on error or explicit rollback request */ if (trans->errnum || TXN_DO_ROLLBACK(trans)) { trans->errnum = 0; ret = dbd_sqlite3_query(trans->handle, &nrows, "ROLLBACK"); } else { ret = dbd_sqlite3_query(trans->handle, &nrows, "COMMIT"); } trans->handle->trans = NULL; } return ret; }
static int dbd_sqlite3_start_transaction(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_transaction_t **trans) { int ret = 0; int nrows = 0; ret = dbd_sqlite3_query(handle, &nrows, "BEGIN IMMEDIATE"); if (!*trans) { *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t)); (*trans)->handle = handle; handle->trans = *trans; } return ret; }