* src/backend/postgres/test/test-db.c: expand testing

* src/engine/Transaction.c: fix bugs. keep positive editlevel
while committing and rolling back transaction.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6414 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-12-27 09:03:32 +00:00
parent a02f6e3f4d
commit cdf8dd0fa1
3 changed files with 25 additions and 16 deletions

View File

@ -1,3 +1,10 @@
2001-12-27 Dave Peticolas <dave@krondo.com>
* src/backend/postgres/test/test-db.c: expand testing
* src/engine/Transaction.c: fix bugs. keep positive editlevel
while committing and rolling back transaction.
2001-12-25 Dave Peticolas <dave@krondo.com>
* src/backend/postgres/test/test-db.c: test rollback

View File

@ -716,13 +716,9 @@ test_trans_update (Transaction *trans, gpointer data)
guid = *xaccTransGetGUID (trans);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransRollbackEdit (trans);
/*
make_random_changes_to_transaction_and_splits (book_1, trans,
td->accounts_1);
*/
xaccTransCommitEdit (trans);
io_err = gnc_session_get_error (td->session_1);
if (!do_test_args (io_err == ERR_BACKEND_NO_ERR,
@ -738,11 +734,9 @@ test_trans_update (Transaction *trans, gpointer data)
if (trans_2)
{
xaccTransBeginEdit (trans_2);
/*
make_random_changes_to_transaction_and_splits (book_2, trans_2,
td->accounts_2);
*/
xaccTransRollbackEdit (trans_2);
xaccTransCommitEdit (trans_2);
}
trans_2 = xaccTransLookup (&guid, book_2);

View File

@ -1528,6 +1528,11 @@ xaccTransCommitEdit (Transaction *trans)
trans->editlevel = 0;
}
/* We increment this for the duration of the call
* so other functions don't result in a recursive
* call to xaccTransCommitEdit. */
trans->editlevel++;
/* At this point, we check to see if we have a valid transaction.
* There are two possiblities:
* 1) Its more or less OK, and needs a little cleanup
@ -1612,7 +1617,6 @@ xaccTransCommitEdit (Transaction *trans)
/* push error back onto the stack */
xaccBackendSetError (be, errcode);
trans->editlevel++;
xaccTransRollbackEdit (trans);
return;
}
@ -1642,6 +1646,9 @@ xaccTransCommitEdit (Transaction *trans)
xaccFreeTransaction (trans->orig);
trans->orig = NULL;
/* Put back to zero. */
trans->editlevel--;
LEAVE ("trans addr=%p\n", trans);
}
@ -1664,6 +1671,11 @@ xaccTransRollbackEdit (Transaction *trans)
trans->editlevel = 0;
}
/* We increment this for the duration of the call
* so other functions don't result in a recursive
* call to xaccTransCommitEdit. */
trans->editlevel++;
/* copy the original values back in. */
orig = trans->orig;
@ -1770,10 +1782,6 @@ xaccTransRollbackEdit (Transaction *trans)
{
GList *node;
/* prevent the transaction from being messed with
* while we make the changes. */
trans->editlevel++;
/* In this loop, we tuck the fixed-up splits back into
* orig array, for temp safekeeping. */
for (i = 0, node = trans->splits ;
@ -1823,8 +1831,6 @@ xaccTransRollbackEdit (Transaction *trans)
xaccAccountRecomputeBalance (account);
gen_event (s);
}
trans->editlevel--;
}
/* Now that the engine copy is back to its original version,
@ -1849,7 +1855,6 @@ xaccTransRollbackEdit (Transaction *trans)
* has deleted this transaction, and we haven't found
* out about it until this user tried to edit it.
*/
trans->editlevel++;
xaccTransDestroy (trans);
xaccFreeTransaction (trans);
@ -1873,6 +1878,9 @@ xaccTransRollbackEdit (Transaction *trans)
trans->orig = NULL;
trans->do_free = FALSE;
/* Put back to zero. */
trans->editlevel--;
LEAVE ("trans addr=%p\n", trans);
}