remove the old, bogus error reporting semantics

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4817 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2001-06-27 05:28:02 +00:00
parent fe79df9323
commit 2237faa4b5
11 changed files with 150 additions and 98 deletions

View File

@ -286,7 +286,6 @@ void
xaccAccountCommitEdit (Account *acc) xaccAccountCommitEdit (Account *acc)
{ {
Backend * be; Backend * be;
int rc;
if (!acc) return; if (!acc) return;
@ -342,16 +341,23 @@ xaccAccountCommitEdit (Account *acc)
be = xaccAccountGetBackend (acc); be = xaccAccountGetBackend (acc);
if (be && be->account_commit_edit) if (be && be->account_commit_edit)
{ {
rc = (be->account_commit_edit) (be, acc); GNCBackendError errcode;
/* hack alert -- we really really should be checking
* for errors returned by the back end ... */ /* clear errors */
if (rc) do {
errcode = xaccBackendGetError (be);
} while (ERR_BACKEND_NO_ERR != errcode);
(be->account_commit_edit) (be, acc);
errcode = xaccBackendGetError (be);
if (ERR_BACKEND_NO_ERR != errcode)
{ {
/* destroys must be rolled back as well ... ??? */ /* destroys must be rolled back as well ... ??? */
acc->do_free = FALSE; acc->do_free = FALSE;
/* XXX hack alert FIXME implement account rollback */ /* XXX hack alert FIXME implement account rollback */
PERR (" backend asked engine to rollback, but this isn't" PERR (" backend asked engine to rollback, but this isn't"
" handled yet. Return code=%d", rc); " handled yet. Return code=%d", errcode);
} }
} }
acc->core_dirty = FALSE; acc->core_dirty = FALSE;

View File

@ -50,8 +50,6 @@
#include "gnc-book.h" #include "gnc-book.h"
#include "gnc-pricedb.h" #include "gnc-pricedb.h"
#define BACKEND_ROLLBACK_DESTROY 999
/* /*
* The book_begin() routine gives the backend a second initialization * The book_begin() routine gives the backend a second initialization
* opportunity. It is suggested that the backend check that * opportunity. It is suggested that the backend check that
@ -106,8 +104,8 @@
* gives the backend a chance to clean up failed commits. * gives the backend a chance to clean up failed commits.
* *
* If the second user tries to modify a transaction that * If the second user tries to modify a transaction that
* the first user deleted, then the backend should return * the first user deleted, then the backend should set the error
* BACKEND_ROLLBACK_DESTROY from this routine, so that the * to ERR_BACKEND_MOD_DESTROY from this routine, so that the
* engine can properly clean up. * engine can properly clean up.
* *
* The run_query() callback takes a GnuCash query object. * The run_query() callback takes a GnuCash query object.
@ -168,14 +166,14 @@ struct _backend
GNCPriceDB * (*price_load) (Backend *); GNCPriceDB * (*price_load) (Backend *);
void (*book_end) (Backend *); void (*book_end) (Backend *);
int (*account_begin_edit) (Backend *, Account *); void (*account_begin_edit) (Backend *, Account *);
int (*account_commit_edit) (Backend *, Account *); void (*account_commit_edit) (Backend *, Account *);
int (*trans_begin_edit) (Backend *, Transaction *); void (*trans_begin_edit) (Backend *, Transaction *);
int (*trans_commit_edit) (Backend *, Transaction *new, Transaction *orig); void (*trans_commit_edit) (Backend *, Transaction *new, Transaction *orig);
int (*trans_rollback_edit) (Backend *, Transaction *); void (*trans_rollback_edit) (Backend *, Transaction *);
int (*price_begin_edit) (Backend *, GNCPrice *); void (*price_begin_edit) (Backend *, GNCPrice *);
int (*price_commit_edit) (Backend *, GNCPrice *); void (*price_commit_edit) (Backend *, GNCPrice *);
void (*run_query) (Backend *, Query *); void (*run_query) (Backend *, Query *);
void (*price_lookup) (Backend *, GNCPriceLookup *); void (*price_lookup) (Backend *, GNCPriceLookup *);

View File

@ -1449,24 +1449,30 @@ xaccTransCommitEdit (Transaction *trans)
be = xaccTransactionGetBackend (trans); be = xaccTransactionGetBackend (trans);
if (be && be->trans_commit_edit) if (be && be->trans_commit_edit)
{ {
int rc = 0; GNCBackendError errcode;
rc = (be->trans_commit_edit) (be, trans, trans->orig);
if (rc) { /* clear errors */
do {
errcode = xaccBackendGetError (be);
} while (ERR_BACKEND_NO_ERR != errcode);
(be->trans_commit_edit) (be, trans, trans->orig);
errcode = xaccBackendGetError (be);
if (ERR_BACKEND_NO_ERR != errcode)
{
/* if the backend puked, then we must roll-back /* if the backend puked, then we must roll-back
* at this point, and let the user know that we failed. * at this point, and let the user know that we failed.
*/ */
/* XXX hack alert -- turn this into a gui dialog */ /* XXX hack alert -- turn this into a gui dialog */
PWARN("Another user has modified this transaction\n" if (ERR_BACKEND_MODIFIED == errcode)
"\tjust a moment ago. Please look at thier changes,\n" {
"\t and try again, if needed.\n" PWARN("Another user has modified this transaction\n"
"\t(This dialog should be a gui dialog and \n" "\tjust a moment ago. Please look at thier changes,\n"
"\tshould check for errors)\n" "\t and try again, if needed.\n"
"\t rc=%d\n", rc); "\t(This dialog should be a gui dialog and \n"
/* hack alert -- we should check for i/o errors from "\tshould check for errors)\n");
* the backend too ... since an i/o error is not a true }
* rollback. what to do ...
*/
trans->editlevel++; trans->editlevel++;
xaccTransRollbackEdit (trans); xaccTransRollbackEdit (trans);
return; return;
@ -1670,10 +1676,17 @@ xaccTransRollbackEdit (Transaction *trans)
be = xaccTransactionGetBackend (trans); be = xaccTransactionGetBackend (trans);
if (be && be->trans_rollback_edit) if (be && be->trans_rollback_edit)
{ {
int rc = 0; GNCBackendError errcode;
rc = (be->trans_rollback_edit) (be, trans);
if (BACKEND_ROLLBACK_DESTROY == rc) /* clear errors */
do {
errcode = xaccBackendGetError (be);
} while (ERR_BACKEND_NO_ERR != errcode);
(be->trans_rollback_edit) (be, trans);
errcode = xaccBackendGetError (be);
if (ERR_BACKEND_MOD_DESTROY == errcode)
{ {
/* The backend is asking us to delete this transaction. /* The backend is asking us to delete this transaction.
* This typically happens because another (remote) user * This typically happens because another (remote) user
@ -1686,7 +1699,8 @@ xaccTransRollbackEdit (Transaction *trans)
LEAVE ("deleted trans addr=%p\n", trans); LEAVE ("deleted trans addr=%p\n", trans);
return; return;
} }
if (rc) { if (ERR_BACKEND_NO_ERR != errcode)
{
PERR ("Rollback Failed. Ouch!"); PERR ("Rollback Failed. Ouch!");
} }
} }

View File

@ -187,7 +187,12 @@ gnc_price_commit_edit (GNCPrice *p)
Backend *be; Backend *be;
be = xaccPriceDBGetBackend (p->db); be = xaccPriceDBGetBackend (p->db);
if (be && be->price_commit_edit) { if (be && be->price_commit_edit) {
int rc; GNCBackendError errcode;
/* clear errors */
do {
errcode = xaccBackendGetError (be);
} while (ERR_BACKEND_NO_ERR != errcode);
/* if we haven't been able to call begin edit before, call it now */ /* if we haven't been able to call begin edit before, call it now */
if (TRUE == p->not_saved) { if (TRUE == p->not_saved) {
@ -196,11 +201,13 @@ gnc_price_commit_edit (GNCPrice *p)
} }
} }
rc = (be->price_commit_edit) (be, p); (be->price_commit_edit) (be, p);
if (rc) { errcode = xaccBackendGetError (be);
if (ERR_BACKEND_NO_ERR != errcode)
{
/* XXX hack alert FIXME implement price rollback */ /* XXX hack alert FIXME implement price rollback */
PERR (" backend asked engine to rollback, but this isn't" PERR (" backend asked engine to rollback, but this isn't"
" handled yet. Return code=%d", rc); " handled yet. Return code=%d", errcode);
} }
} }
p->not_saved = FALSE; p->not_saved = FALSE;

View File

@ -418,12 +418,12 @@ static void rpcend_book_end (Backend *bend)
LEAVE ("be=%p", be); LEAVE ("be=%p", be);
} }
static int rpcend_account_begin_edit (Backend *bend, Account *acct) static void rpcend_account_begin_edit (Backend *bend, Account *acct)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_backend_guid args; gncrpc_backend_guid args;
int ret = 0; int ret = 0;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, acc=%p", be, acct); ENTER ("be=%p, acc=%p", be, acct);
@ -432,21 +432,27 @@ static int rpcend_account_begin_edit (Backend *bend, Account *acct)
memcpy (args.guid, acct->guid.data, sizeof (args.guid)); memcpy (args.guid, acct->guid.data, sizeof (args.guid));
gncrpc_account_begin_edit_1 (&args, &ret, be->client); gncrpc_account_begin_edit_1 (&args, &ret, be->client);
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : ""); LEAVE ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : "");
return ret;
} }
static int rpcend_account_rollback_edit (Backend *bend, Account *acct) static void rpcend_account_rollback_edit (Backend *bend, Account *acct)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_backend_guid args; gncrpc_backend_guid args;
int ret = 0; int ret = 0;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : ""); ENTER ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : "");
if (acct == NULL) if (acct == NULL) {
return ERR_BACKEND_MISC; xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
return;
}
memset (&args, 0, sizeof (args)); memset (&args, 0, sizeof (args));
memcpy (args.backend, (char *)&be, sizeof(be)); memcpy (args.backend, (char *)&be, sizeof(be));
@ -454,22 +460,28 @@ static int rpcend_account_rollback_edit (Backend *bend, Account *acct)
gncrpc_account_rollback_edit_1 (&args, &ret, be->client); gncrpc_account_rollback_edit_1 (&args, &ret, be->client);
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, acc=%p, ret=%d", be, acct, ret); LEAVE ("be=%p, acc=%p, ret=%d", be, acct, ret);
return ret;
} }
static int rpcend_account_commit_edit (Backend *bend, Account *acct) static void rpcend_account_commit_edit (Backend *bend, Account *acct)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_commit_acct_args args; gncrpc_commit_acct_args args;
int ret = 0; int ret = 0;
AccountGroup *parent; AccountGroup *parent;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : ""); ENTER ("be=%p, acc=%p (%s)", be, acct, acct ? acct->accountName : "");
if (acct == NULL) if (acct == NULL) {
return ERR_BACKEND_MISC; xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
return;
}
parent = xaccAccountGetParent(acct); parent = xaccAccountGetParent(acct);
@ -507,16 +519,20 @@ static int rpcend_account_commit_edit (Backend *bend, Account *acct)
acct->version--; acct->version--;
} }
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, acc=%p, ret=%d", be, acct, ret); LEAVE ("be=%p, acc=%p, ret=%d", be, acct, ret);
return ret;
} }
static int rpcend_trans_begin_edit (Backend *bend, Transaction *txn) static void rpcend_trans_begin_edit (Backend *bend, Transaction *txn)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_backend_guid args; gncrpc_backend_guid args;
int ret = 0; int ret = 0;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, txn=%p", be, txn); ENTER ("be=%p, txn=%p", be, txn);
@ -525,17 +541,21 @@ static int rpcend_trans_begin_edit (Backend *bend, Transaction *txn)
memcpy (args.guid, txn->guid.data, sizeof (args.guid)); memcpy (args.guid, txn->guid.data, sizeof (args.guid));
gncrpc_txn_begin_edit_1 (&args, &ret, be->client); gncrpc_txn_begin_edit_1 (&args, &ret, be->client);
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, txn=%p", be, txn); LEAVE ("be=%p, txn=%p", be, txn);
return ret;
} }
static int rpcend_trans_commit_edit (Backend *bend, Transaction *new, static void rpcend_trans_commit_edit (Backend *bend, Transaction *new,
Transaction *orig) Transaction *orig)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_commit_txn_args args; gncrpc_commit_txn_args args;
int ret = 0; int ret = 0;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, new=%p, vers=%d", be, new, new->version); ENTER ("be=%p, new=%p, vers=%d", be, new, new->version);
new->version++; new->version++;
@ -553,16 +573,20 @@ static int rpcend_trans_commit_edit (Backend *bend, Transaction *new,
new->version--; new->version--;
} }
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, new=%p, ret=%d, txn_vers=%d", be, new, ret, new->version); LEAVE ("be=%p, new=%p, ret=%d, txn_vers=%d", be, new, ret, new->version);
return ret;
} }
static int rpcend_trans_rollback_edit (Backend *bend, Transaction *txn) static void rpcend_trans_rollback_edit (Backend *bend, Transaction *txn)
{ {
RPCBackend *be = (RPCBackend *)bend; RPCBackend *be = (RPCBackend *)bend;
gncrpc_backend_guid args; gncrpc_backend_guid args;
int ret = 0; int ret = 0;
VERIFY_BE (be, -1); VERIFY_BEV (be);
ENTER ("be=%p, txn=%p", be, txn); ENTER ("be=%p, txn=%p", be, txn);
memset (&args, 0, sizeof (args)); memset (&args, 0, sizeof (args));
memcpy (args.backend, (char *)&be, sizeof(be)); memcpy (args.backend, (char *)&be, sizeof(be));
@ -570,20 +594,22 @@ static int rpcend_trans_rollback_edit (Backend *bend, Transaction *txn)
gncrpc_txn_rollback_edit_1 (&args, &ret, be->client); gncrpc_txn_rollback_edit_1 (&args, &ret, be->client);
if (ret)
{
/* ah this is certainly wrong ... */
xaccBackendSetError (&be->be, ERR_BACKEND_MISC);
}
LEAVE ("be=%p, txn=%p, ret=%d", be, txn, ret); LEAVE ("be=%p, txn=%p, ret=%d", be, txn, ret);
return ret;
} }
static int rpcend_price_begin_edit (Backend *bend, GNCPrice *pr) static void rpcend_price_begin_edit (Backend *bend, GNCPrice *pr)
{ {
PERR ("not implemented"); PERR ("not implemented");
return 0;
} }
static int rpcend_price_commit_edit (Backend *bend, GNCPrice *pr) static void rpcend_price_commit_edit (Backend *bend, GNCPrice *pr)
{ {
PERR ("not implemented"); PERR ("not implemented");
return 0;
} }
static void rpcend_price_lookup (Backend *bend, GNCPriceLookup *q) static void rpcend_price_lookup (Backend *bend, GNCPriceLookup *q)

View File

@ -444,7 +444,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
/* ============================================================= */ /* ============================================================= */
/* ============================================================= */ /* ============================================================= */
int void
pgend_account_commit_edit (Backend * bend, pgend_account_commit_edit (Backend * bend,
Account * acct) Account * acct)
{ {
@ -453,7 +453,7 @@ pgend_account_commit_edit (Backend * bend,
PGBackend *be = (PGBackend *)bend; PGBackend *be = (PGBackend *)bend;
ENTER ("be=%p, acct=%p", be, acct); ENTER ("be=%p, acct=%p", be, acct);
if (!be || !acct) return 1; /* hack alert hardcode literal */ if (!be || !acct) return;
if (FALSE == acct->core_dirty) if (FALSE == acct->core_dirty)
{ {
@ -468,7 +468,7 @@ pgend_account_commit_edit (Backend * bend,
"LOCK TABLE gncAccount IN EXCLUSIVE MODE;\n" "LOCK TABLE gncAccount IN EXCLUSIVE MODE;\n"
"LOCK TABLE gncCommodity IN EXCLUSIVE MODE;\n"; "LOCK TABLE gncCommodity IN EXCLUSIVE MODE;\n";
SEND_QUERY (be,p, 555); SEND_QUERY (be,p,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* check to see that the engine version is equal or newer than /* check to see that the engine version is equal or newer than
@ -478,7 +478,7 @@ pgend_account_commit_edit (Backend * bend,
{ {
acct->do_free = FALSE; acct->do_free = FALSE;
p = "ROLLBACK;"; p = "ROLLBACK;";
SEND_QUERY (be,p,444); SEND_QUERY (be,p,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* hack alert -- we should restore the account data from the /* hack alert -- we should restore the account data from the
@ -488,7 +488,7 @@ pgend_account_commit_edit (Backend * bend,
" is not completely implemented !! \n"); " is not completely implemented !! \n");
xaccBackendSetError (&be->be, ERR_BACKEND_MODIFIED); xaccBackendSetError (&be->be, ERR_BACKEND_MODIFIED);
LEAVE ("rolled back"); LEAVE ("rolled back");
return 445; return;
} }
acct->version ++; /* be sure to update the version !! */ acct->version ++; /* be sure to update the version !! */
acct->version_check = be->version_check; acct->version_check = be->version_check;
@ -503,7 +503,7 @@ pgend_account_commit_edit (Backend * bend,
p = stpcpy (p, "DELETE FROM gncAccount WHERE accountGuid='"); p = stpcpy (p, "DELETE FROM gncAccount WHERE accountGuid='");
p = guid_to_string_buff (guid, p); p = guid_to_string_buff (guid, p);
p = stpcpy (p, "';"); p = stpcpy (p, "';");
SEND_QUERY (be,be->buff, 444); SEND_QUERY (be,be->buff,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
} }
else else
@ -513,7 +513,7 @@ pgend_account_commit_edit (Backend * bend,
p = "COMMIT;\n" p = "COMMIT;\n"
"NOTIFY gncAccount;"; "NOTIFY gncAccount;";
SEND_QUERY (be,p,336); SEND_QUERY (be,p,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* Mark this up so that we don't get that annoying gui dialog /* Mark this up so that we don't get that annoying gui dialog
@ -524,7 +524,7 @@ pgend_account_commit_edit (Backend * bend,
parent = xaccAccountGetParent(acct); parent = xaccAccountGetParent(acct);
if (parent) parent->saved = 1; if (parent) parent->saved = 1;
LEAVE ("commited"); LEAVE ("commited");
return 0; return;
} }
/* ======================== END OF FILE ======================== */ /* ======================== END OF FILE ======================== */

View File

@ -35,6 +35,6 @@ void pgendStoreGroupNoLock (PGBackend *be, AccountGroup *grp,
gboolean do_mark, gboolean do_check_version); gboolean do_mark, gboolean do_check_version);
int pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid); int pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid);
int pgend_account_commit_edit (Backend * bend, Account * acct); void pgend_account_commit_edit (Backend * bend, Account * acct);
#endif /* __POSTGRES_ACCOUNT_H__ */ #endif /* __POSTGRES_ACCOUNT_H__ */

View File

@ -400,29 +400,29 @@ pgendPriceLookup (Backend *bend, GNCPriceLookup *look)
/* ============================================================= */ /* ============================================================= */
/* ============================================================= */ /* ============================================================= */
int void
pgend_price_begin_edit (Backend * bend, GNCPrice *pr) pgend_price_begin_edit (Backend * bend, GNCPrice *pr)
{ {
if (pr && pr->db && pr->db->dirty) if (pr && pr->db && pr->db->dirty)
{ {
PERR ("price db is unexpectedly dirty"); PERR ("price db is unexpectedly dirty");
} }
return 0; return;
} }
int void
pgend_price_commit_edit (Backend * bend, GNCPrice *pr) pgend_price_commit_edit (Backend * bend, GNCPrice *pr)
{ {
char * bufp; char * bufp;
PGBackend *be = (PGBackend *)bend; PGBackend *be = (PGBackend *)bend;
ENTER ("be=%p, price=%p", be, pr); ENTER ("be=%p, price=%p", be, pr);
if (!be || !pr) return 1; /* hack alert hardcode literal */ if (!be || !pr) return;
/* lock it up so that we query and store atomically */ /* lock it up so that we query and store atomically */
bufp = "BEGIN;\n" bufp = "BEGIN;\n"
"LOCK TABLE gncPrice IN EXCLUSIVE MODE;\n"; "LOCK TABLE gncPrice IN EXCLUSIVE MODE;\n";
SEND_QUERY (be,bufp, 555); SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* check to see that the engine version is equal or newer than /* check to see that the engine version is equal or newer than
@ -432,7 +432,7 @@ pgend_price_commit_edit (Backend * bend, GNCPrice *pr)
{ {
pr->do_free = FALSE; pr->do_free = FALSE;
bufp = "ROLLBACK;"; bufp = "ROLLBACK;";
SEND_QUERY (be,bufp,444); SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* hack alert -- we should restore the price data from the /* hack alert -- we should restore the price data from the
@ -441,7 +441,8 @@ pgend_price_commit_edit (Backend * bend, GNCPrice *pr)
" price must be rolled back. This function\n" " price must be rolled back. This function\n"
" is not completely implemented !! \n"); " is not completely implemented !! \n");
LEAVE ("rolled back"); LEAVE ("rolled back");
return 445; xaccBackendSetError (&be->be, ERR_BACKEND_MODIFIED);
return;
} }
pr->version ++; /* be sure to update the version !! */ pr->version ++; /* be sure to update the version !! */
pr->version_check = be->version_check; pr->version_check = be->version_check;
@ -454,7 +455,7 @@ pgend_price_commit_edit (Backend * bend, GNCPrice *pr)
bufp = guid_to_string_buff (gnc_price_get_guid(pr), bufp); bufp = guid_to_string_buff (gnc_price_get_guid(pr), bufp);
bufp = stpcpy (bufp, "';"); bufp = stpcpy (bufp, "';");
PINFO ("%s\n", be->buff ? be->buff : "(null)"); PINFO ("%s\n", be->buff ? be->buff : "(null)");
SEND_QUERY (be,be->buff, 444); SEND_QUERY (be,be->buff, );
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
} }
else else
@ -464,13 +465,13 @@ pgend_price_commit_edit (Backend * bend, GNCPrice *pr)
bufp = "COMMIT;\n" bufp = "COMMIT;\n"
"NOTIFY gncPrice;"; "NOTIFY gncPrice;";
SEND_QUERY (be,bufp,335); SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
if (pr->db) pr->db->dirty = FALSE; if (pr->db) pr->db->dirty = FALSE;
LEAVE ("commited"); LEAVE ("commited");
return 0; return;
} }
/* ======================== END OF FILE ======================== */ /* ======================== END OF FILE ======================== */

View File

@ -33,7 +33,7 @@ GNCPriceDB * pgendGetAllPrices (PGBackend *be, GNCPriceDB *prdb);
void pgendPriceLookup (Backend *bend, GNCPriceLookup *look); void pgendPriceLookup (Backend *bend, GNCPriceLookup *look);
int pgend_price_begin_edit (Backend * bend, GNCPrice *pr); void pgend_price_begin_edit (Backend * bend, GNCPrice *pr);
int pgend_price_commit_edit (Backend * bend, GNCPrice *pr); void pgend_price_commit_edit (Backend * bend, GNCPrice *pr);
#endif /* __POSTGRES_PRICE_H__ */ #endif /* __POSTGRES_PRICE_H__ */

View File

@ -732,7 +732,7 @@ pgendSyncTransaction (PGBackend *be, GUID *trans_guid)
/* ============================================================= */ /* ============================================================= */
int void
pgend_trans_commit_edit (Backend * bend, pgend_trans_commit_edit (Backend * bend,
Transaction * trans, Transaction * trans,
Transaction * oldtrans) Transaction * oldtrans)
@ -742,13 +742,13 @@ pgend_trans_commit_edit (Backend * bend,
PGBackend *be = (PGBackend *)bend; PGBackend *be = (PGBackend *)bend;
ENTER ("be=%p, trans=%p", be, trans); ENTER ("be=%p, trans=%p", be, trans);
if (!be || !trans) return 1; /* hack alert hardcode literal */ if (!be || !trans) return;
/* lock it up so that we query and store atomically */ /* lock it up so that we query and store atomically */
bufp = "BEGIN;\n" bufp = "BEGIN;\n"
"LOCK TABLE gncTransaction IN EXCLUSIVE MODE;\n" "LOCK TABLE gncTransaction IN EXCLUSIVE MODE;\n"
"LOCK TABLE gncEntry IN EXCLUSIVE MODE;\n"; "LOCK TABLE gncEntry IN EXCLUSIVE MODE;\n";
SEND_QUERY (be,bufp, 555); SEND_QUERY (be,bufp, );
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* Check to see if this is a 'new' transaction, or not. /* Check to see if this is a 'new' transaction, or not.
@ -822,7 +822,7 @@ pgend_trans_commit_edit (Backend * bend,
if (rollback) { if (rollback) {
bufp = "ROLLBACK;"; bufp = "ROLLBACK;";
SEND_QUERY (be,bufp,444); /* hack alert hard coded literal */ SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
PINFO ("old tranasction didn't match DB, edit rolled back)\n"); PINFO ("old tranasction didn't match DB, edit rolled back)\n");
@ -834,7 +834,7 @@ pgend_trans_commit_edit (Backend * bend,
* the sql database, and voila! we are good to go. * the sql database, and voila! we are good to go.
*/ */
xaccBackendSetError (&be->be, ERR_BACKEND_MODIFIED); xaccBackendSetError (&be->be, ERR_BACKEND_MODIFIED);
return 666; /* hack alert- hard coded literal */ return;
} }
} }
@ -843,7 +843,7 @@ pgend_trans_commit_edit (Backend * bend,
bufp = "COMMIT;\n" bufp = "COMMIT;\n"
"NOTIFY gncTransaction;"; "NOTIFY gncTransaction;";
SEND_QUERY (be,bufp,334); SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection); FINISH_QUERY(be->connection);
/* If this is the multi-user mode, we need to update the /* If this is the multi-user mode, we need to update the
@ -879,7 +879,7 @@ pgend_trans_commit_edit (Backend * bend,
} }
LEAVE ("commited"); LEAVE ("commited");
return 0; return;
} }
/* ============================================================= */ /* ============================================================= */
@ -894,13 +894,13 @@ pgend_trans_commit_edit (Backend * bend,
* to sync from the changes that other users had made. * to sync from the changes that other users had made.
*/ */
int void
pgend_trans_rollback_edit (Backend * bend, Transaction * trans) pgend_trans_rollback_edit (Backend * bend, Transaction * trans)
{ {
PGBackend *be = (PGBackend *)bend; PGBackend *be = (PGBackend *)bend;
const GUID * trans_guid; const GUID * trans_guid;
if (!be || !trans) return 0; if (!be || !trans) return;
ENTER ("be=%p, trans=%p", be, trans); ENTER ("be=%p, trans=%p", be, trans);
/* First, lets see if the other user had deleted this transaction. /* First, lets see if the other user had deleted this transaction.
@ -910,14 +910,14 @@ pgend_trans_rollback_edit (Backend * bend, Transaction * trans)
{ {
LEAVE ("destroyed"); LEAVE ("destroyed");
xaccBackendSetError (&be->be, ERR_BACKEND_MOD_DESTROY); xaccBackendSetError (&be->be, ERR_BACKEND_MOD_DESTROY);
return BACKEND_ROLLBACK_DESTROY; return;
} }
trans_guid = xaccTransGetGUID (trans); trans_guid = xaccTransGetGUID (trans);
pgendCopyTransactionToEngine (be, trans_guid); pgendCopyTransactionToEngine (be, trans_guid);
LEAVE ("rolled back"); LEAVE ("rolled back");
return 0; return;
} }
/* ======================== END OF FILE ======================== */ /* ======================== END OF FILE ======================== */

View File

@ -46,8 +46,8 @@ int pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid);
void pgendStoreAllTransactions (PGBackend *be, AccountGroup *grp); void pgendStoreAllTransactions (PGBackend *be, AccountGroup *grp);
void pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans, gboolean do_check_version); void pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans, gboolean do_check_version);
int pgend_trans_commit_edit (Backend * bend, Transaction * trans, Transaction * oldtrans); void pgend_trans_commit_edit (Backend * bend, Transaction * trans, Transaction * oldtrans);
int pgend_trans_rollback_edit (Backend * bend, Transaction * trans); void pgend_trans_rollback_edit (Backend * bend, Transaction * trans);