Here's the backport. I got it compiled, seems to work OK, for saving the file to a database. There seems to be another crash uncovered by this fix specific to the 1.8.x branch, that occurs after entering/updating a transaction and closing the register window. Seeing what I can find out about that...
-- Matthew Vanecek perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);' ******************************************************************************** For 93 million miles, there is nothing between the sun and my shadow except me. I'm always getting in the way of something...
? autom4te.cache
? gnucash-1.8.4
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1461.2.223
diff -u -r1.1461.2.223 ChangeLog
--- ChangeLog 27 Jul 2003 23:26:32 -0000 1.1461.2.223
+++ ChangeLog 28 Jul 2003 02:23:28 -0000
@@ -1,3 +1,22 @@
+2003-07-27 Matt Vanecek <[EMAIL PROTECTED]>
+
+ * src/backend/postgres/PostgresBackend.c: Added pgendGetBook(),
+ to retrieve the GNCBook from the session, instead of storing the
+ book in the backend object.
+ - Where be->book was used, use pgendGetBook() instead.
+ - Enhanced debug messages.
+ * src/backend/postgres/PostgresBackend.h: Added the gncbook.h
+ include, and the pgendGetBook() prototype
+ * src/backend/postgres/book.c: Changed pgendGetBook to
+ pgendBookRestore() to reflect its functionality of restoring
+ the book's data to the engine.
+ * src/backend/postgres/price.c: In pgendPriceFind(), couched the
+ currenct portion of the SQL statement in an "if" statement,
+ because gnc_pricedb_lookup_latest_any_currency() can pass in
+ a NULL currency, and stpcpy() doesn't like NULLs.
+ * src/backend/postgres/escape.c: enhanced debug messages.
+ Fixes bug #116546
+
2003-07-27 Derek Atkins <[EMAIL PROTECTED]>
* src/import-export/Makefile.am: add log-replay (make sure its built)
Index: src/backend/postgres/PostgresBackend.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/PostgresBackend.c,v
retrieving revision 1.43
diff -u -r1.43 PostgresBackend.c
--- src/backend/postgres/PostgresBackend.c 1 Feb 2003 21:26:27 -0000 1.43
+++ src/backend/postgres/PostgresBackend.c 28 Jul 2003 02:23:36 -0000
@@ -233,6 +233,17 @@
/* ============================================================= */
+GNCBook *
+pgendGetBook(PGBackend *pbe) {
+ GNCBook *book;
+
+ ENTER(" ");
+ book = gnc_session_get_book(pbe->session);
+
+ LEAVE("book = %p", book);
+ return book;
+}
+
static void
pgend_set_book (PGBackend *be, GNCBook *book)
{
@@ -454,7 +465,7 @@
}
else
{
- trans = xaccMallocTransaction(be->book);
+ trans = xaccMallocTransaction(pgendGetBook(be));
xaccTransBeginEdit (trans);
xaccTransSetGUID (trans, &trans_guid);
}
@@ -468,7 +479,8 @@
xaccTransSetVersion (trans, atoi(DB_GET_VAL("version",j)));
trans->idata = atoi(DB_GET_VAL("iguid",j));
- currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), be->book);
+ currency = gnc_string_to_commodity (DB_GET_VAL("currency",j),
+ pgendGetBook(be));
if (currency)
xaccTransSetCurrency (trans, currency);
else
@@ -528,7 +540,8 @@
gnc_commodity * commodity;
pgendGetCommodity (be, ri->commodity_string);
- commodity = gnc_string_to_commodity (ri->commodity_string, be->book);
+ commodity = gnc_string_to_commodity (ri->commodity_string,
+ pgendGetBook(be));
if (commodity)
{
@@ -713,7 +726,7 @@
sqlQuery *sq;
ENTER ("be=%p, qry=%p", be, q);
- if (!be || !q) return;
+ if (!be || !q) { LEAVE("(null) args"); return; }
be->version_check = (guint32) time(0);
gnc_engine_suspend_events();
@@ -724,7 +737,7 @@
sq = sqlQuery_new();
sql_query_string = sqlQuery_build (sq, q);
- topgroup = gnc_book_get_group (be->book);
+ topgroup = gnc_book_get_group (pgendGetBook(be));
/* stage transactions, save some postgres overhead */
xaccGroupBeginStagedTransactionTraversals (topgroup);
@@ -1480,7 +1493,9 @@
AccountGroup *grp;
PGBackend *be = (PGBackend *)bend;
- if (!be) return;
+ ENTER("be = %p", bend);
+
+ if (!be || !book) { LEAVE("(null) args"); return; }
/* don't send events to GUI, don't accept callbacks to backend */
gnc_engine_suspend_events();
@@ -1500,9 +1515,8 @@
g_list_free (be->blist);
be->blist = NULL;
}
+ pgendBookRestore (be, book);
pgend_set_book (be, book);
- pgendGetBook (be, book);
- gnc_session_set_book(be->session, book);
PINFO("Book GUID = %s\n",
guid_to_string(gnc_book_get_guid(book)));
@@ -1517,6 +1531,7 @@
/* re-enable events */
pgendEnable(be);
gnc_engine_resume_events();
+ LEAVE(" ");
}
/* ============================================================= */
@@ -1532,16 +1547,15 @@
{
PGBackend *be = (PGBackend *)bend;
- if (!be) return;
-
+ ENTER("be = %p", bend);
+
+ if (!be || !book) { LEAVE("(null) args"); return; }
/* don't send events to GUI, don't accept callbacks to backend */
gnc_engine_suspend_events();
pgendDisable(be);
be->version_check = (guint32) time(0);
- pgend_set_book (be, book);
-
pgendKVPInit(be);
if (be->blist)
@@ -1550,9 +1564,8 @@
PWARN ("old book list not empty ");
g_list_free (be->blist);
}
- pgendGetBook (be, book);
-
- be->blist = g_list_append (NULL, book);
+ pgendBookRestore (be, book);
+ pgend_set_book (be, book);
pgendGetAllAccountsInBook (be, book);
@@ -1561,6 +1574,7 @@
/* re-enable events */
pgendEnable(be);
gnc_engine_resume_events();
+ LEAVE(" ");
}
/* ============================================================= */
@@ -1784,7 +1798,6 @@
g_list_free (be->blist);
be->blist = NULL;
}
- pgend_set_book (be, gnc_session_get_book(session));
/* Parse the sessionid for the hostname, port number and db name.
* The expected URL format is
@@ -2360,13 +2373,17 @@
void
pgendDisable (PGBackend *be)
{
+ ENTER("be = %p", be);
if (0 > be->nest_count)
{
PERR ("too many nested enables");
}
be->nest_count ++;
PINFO("nest count=%d", be->nest_count);
- if (1 < be->nest_count) return;
+ if (1 < be->nest_count) {
+ LEAVE("be->nest_count > 1: %d", be->nest_count);
+ return;
+ }
/* save hooks */
be->snr.load = be->be.load;
@@ -2398,6 +2415,8 @@
be->be.percentage = NULL;
be->be.events_pending = NULL;
be->be.process_events = NULL;
+
+ LEAVE(" ");
}
/* ============================================================= */
Index: src/backend/postgres/PostgresBackend.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/PostgresBackend.h,v
retrieving revision 1.8
diff -u -r1.8 PostgresBackend.h
--- src/backend/postgres/PostgresBackend.h 5 Jan 2002 18:32:07 -0000 1.8
+++ src/backend/postgres/PostgresBackend.h 28 Jul 2003 02:23:36 -0000
@@ -39,6 +39,7 @@
#include "Group.h"
#include "guid.h"
#include "Transaction.h"
+#include "gnc-book.h"
#include "builder.h"
#include "BackendP.h"
@@ -126,6 +127,7 @@
Split * pgendSplitLookup (PGBackend *be, const GUID *split_guid);
GNCPrice * pgendPriceLookup (PGBackend *be, const GUID *price_guid);
GNCIdType pgendGUIDType (PGBackend *be, const GUID *guid);
+GNCBook * pgendGetBook(PGBackend *pbe);
void pgendDisable (PGBackend *be);
void pgendEnable (PGBackend *be);
Index: src/backend/postgres/book.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/book.c,v
retrieving revision 1.6
diff -u -r1.6 book.c
--- src/backend/postgres/book.c 4 Jan 2002 21:28:31 -0000 1.6
+++ src/backend/postgres/book.c 28 Jul 2003 02:23:37 -0000
@@ -128,7 +128,7 @@
/* ============================================================= */
/* ============================================================= */
-/* The pgendGetBook() routine restores the all book data,
+/* The pgendBookRestore() routine restores the all book data,
* including the account heirarchy, the price db, commodities, etc.
*/
@@ -153,7 +153,7 @@
}
void
-pgendGetBook (PGBackend *be, GNCBook *book)
+pgendBookRestore (PGBackend *be, GNCBook *book)
{
char * bufp;
Index: src/backend/postgres/book.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/book.h,v
retrieving revision 1.4
diff -u -r1.4 book.h
--- src/backend/postgres/book.h 4 Jan 2002 21:28:31 -0000 1.4
+++ src/backend/postgres/book.h 28 Jul 2003 02:23:37 -0000
@@ -32,7 +32,7 @@
BookList * pgendGetAllBooks (PGBackend *be, BookList *);
-void pgendGetBook (PGBackend *be, GNCBook *book);
+void pgendBookRestore (PGBackend *be, GNCBook *book);
void pgendStoreBookNoLock (PGBackend *be, GNCBook *book, int do_check_version);
void pgendStoreBook (PGBackend *be, GNCBook *book);
Index: src/backend/postgres/escape.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/escape.c,v
retrieving revision 1.3
diff -u -r1.3 escape.c
--- src/backend/postgres/escape.c 1 Feb 2003 21:26:28 -0000 1.3
+++ src/backend/postgres/escape.c 28 Jul 2003 02:23:37 -0000
@@ -57,16 +57,23 @@
char *dst_tail;
size_t len, slen;
- if (!b || !str) return NULL;
+ ENTER("str = %s", str);
+
+ if (!b || !str) { LEAVE("(null) args"); return NULL; }
/* if a string is escaped twice, just return the first */
- if (b->escape == str)
- return str;
+ if (b->escape == str) {
+ LEAVE("%s: already escaped", str);
+ return str;
+ }
/* if nothing to escape, just return */
len = strlen (str);
slen = strcspn (str, "\\\'");
- if (len == slen) return str;
+ if (len == slen) {
+ LEAVE("nothing to escape");
+ return str;
+ }
/* count to see how much space we'll need */
p = str + slen + 1;
@@ -110,6 +117,7 @@
}
*dst_tail = 0;
+ LEAVE("b->escape = %s", b->escape);
return b->escape;
}
Index: src/backend/postgres/price.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/price.c,v
retrieving revision 1.17
diff -u -r1.17 price.c
--- src/backend/postgres/price.c 5 Jan 2002 18:32:07 -0000 1.17
+++ src/backend/postgres/price.c 28 Jul 2003 02:23:38 -0000
@@ -362,8 +362,8 @@
char * p;
ENTER ("be=%p, lookup=%p", be, look);
- if (!be || !look) return;
-
+ if (!be || !look) { LEAVE("(null) args"); return; }
+
/* special case the two-way search in terms of more basic primitives */
if (LOOKUP_NEAREST_IN_TIME == look->type)
{
@@ -371,6 +371,7 @@
pgendPriceFind (bend, look);
look->type = LOOKUP_EARLIEST_AFTER;
pgendPriceFind (bend, look);
+ LEAVE(" ");
return;
}
@@ -388,9 +389,14 @@
p = stpcpy (p, "SELECT * FROM gncPrice"
" WHERE commodity='");
p = stpcpy (p, sqlEscapeString (escape, commodity_str));
- p = stpcpy (p, "' AND currency='");
- p = stpcpy (p, sqlEscapeString (escape, currency_str));
p = stpcpy (p, "' ");
+ if (currency_str) {
+ p = stpcpy (p, "AND currency='");
+ p = stpcpy (p, sqlEscapeString (escape, currency_str));
+ p = stpcpy (p, "' ");
+ }
+
+ PINFO("query = %s", be->buff);
sqlEscape_destroy (escape);
escape = NULL;
@@ -428,6 +434,7 @@
/* re-enable events */
pgendEnable(be);
gnc_engine_resume_events();
+ LEAVE(" ");
return;
}
@@ -441,6 +448,7 @@
/* re-enable events */
pgendEnable(be);
gnc_engine_resume_events();
+ LEAVE(" ");
}
/* ============================================================= */
signature.asc
Description: This is a digitally signed message part
_______________________________________________ gnucash-devel mailing list [EMAIL PROTECTED] http://www.gnucash.org/cgi-bin/mailman/listinfo/gnucash-devel
