Misc fixes to allow the postgres backend to compile w/ the entity makeover

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9554 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas
2003-10-18 14:44:39 +00:00
parent aee3597d53
commit 8c8871f65d
9 changed files with 71 additions and 51 deletions
+2 -2
View File
@@ -102,10 +102,10 @@ AM_CFLAGS = \
$(M4_SRC): table.m4
%-autogen.c: %-objects.m4
%-autogen.c: %-objects.m4 table.m4
m4 -I ${srcdir} $< > $@
%-autogen.h: %-objects-header.m4
%-autogen.h: %-objects-header.m4 table.m4
m4 -I ${srcdir} $< > $@
.sql.c:
+25 -5
View File
@@ -197,18 +197,38 @@ pgendSplitLookup (PGBackend *be, const GUID *split_guid)
return NULL;
}
struct _iter {
const GUID *guid;
QofEntity *ent;
};
static void
cforeach (QofCollection *col, gpointer data)
{
struct _iter *iter = data;
if (iter->ent) return;
iter->ent = qof_collection_lookup_entity (col, iter->guid);
}
QofIdType
pgendGUIDType (PGBackend *be, const GUID *guid)
{
GList *node;
QofIdType tip = GNC_ID_NONE;
struct _iter iter;
iter.guid = guid;
iter.ent = NULL;
ENTER("guid = %s", guid_to_string(guid));
for (node=be->blist; node; node=node->next)
{
QofBook *book = node->data;
tip = qof_entity_type (qof_book_get_entity_table(book), guid);
if (GNC_ID_NONE != tip) { LEAVE("tip = %s", tip); return tip; }
qof_book_foreach_collection (book, cforeach, &iter);
if (iter.ent)
{
LEAVE("tip = %s", iter.ent->e_type);
return iter.ent->e_type;
}
}
LEAVE("tip = NULL");
@@ -559,7 +579,7 @@ pgendFillOutToCheckpoint (PGBackend *be, const char *query_string)
Transaction *trans = (Transaction *) node->data;
GList *engine_splits, *snode;
trans->kvp_data = pgendKVPFetch (be, trans->idata, trans->kvp_data);
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
engine_splits = xaccTransGetSplitList(trans);
for (snode = engine_splits; snode; snode=snode->next)
@@ -911,7 +931,7 @@ pgendSync (QofBackend *bend, QofBook *book)
/* hack alert -- In some deranged theory, we should be
* syncing prices here, as well as syncing any/all other
* engine structures that need to be stored. But instead,
* price syn is handled as a separate routine ...
* price sync is handled as a separate routine ...
*/
/* re-enable events */
+7 -7
View File
@@ -92,7 +92,7 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
const gnc_commodity *com;
if (!be || !acct) return;
if ((FALSE == do_mark) && (FALSE == acct->core_dirty)) return;
if ((FALSE == do_mark) && (FALSE == acct->inst.dirty)) return;
ENTER ("acct=%p, mark=%d", acct, do_mark);
@@ -139,7 +139,7 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
if (acct->idata)
{
pgendKVPDelete (be, acct->idata);
pgendKVPStore (be, acct->idata, acct->kvp_data);
pgendKVPStore (be, acct->idata, acct->inst.kvp_data);
}
LEAVE(" ");
}
@@ -227,7 +227,7 @@ restore_cb (Account *acc, void * cb_data)
{
PGBackend *be = (PGBackend *) cb_data;
if (0 == acc->idata) return NULL;
acc->kvp_data = pgendKVPFetch (be, acc->idata, acc->kvp_data);
acc->inst.kvp_data = pgendKVPFetch (be, acc->idata, acc->inst.kvp_data);
return NULL;
}
@@ -552,7 +552,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
{
if (acc->idata)
{
acc->kvp_data = pgendKVPFetch (be, acc->idata, acc->kvp_data);
acc->inst.kvp_data = pgendKVPFetch (be, acc->idata, acc->inst.kvp_data);
}
acc->version_check = be->version_check;
@@ -585,7 +585,7 @@ pgend_account_commit_edit (QofBackend * bend,
ENTER ("be=%p, acct=%p", be, acct);
if (!be || !acct) return;
if (FALSE == acct->core_dirty)
if (FALSE == acct->inst.dirty)
{
parent = xaccAccountGetParent(acct);
if (parent) parent->saved = 1;
@@ -607,7 +607,7 @@ pgend_account_commit_edit (QofBackend * bend,
* made changes, and we must roll back. */
if (0 < pgendAccountCompareVersion (be, acct))
{
acct->do_free = FALSE;
acct->inst.do_free = FALSE;
p = "ROLLBACK;";
SEND_QUERY (be,p,);
FINISH_QUERY(be->connection);
@@ -624,7 +624,7 @@ pgend_account_commit_edit (QofBackend * bend,
acct->version ++; /* be sure to update the version !! */
acct->version_check = be->version_check;
if (acct->do_free)
if (acct->inst.do_free)
{
const GUID *guid = xaccAccountGetGUID(acct);
pgendKVPDelete (be, acct->idata);
+3 -3
View File
@@ -145,7 +145,7 @@ get_one_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("bookGuid",j), &guid);
qof_book_set_guid (book, guid);
qof_book_set_guid (book, &guid);
book->book_open = (DB_GET_VAL("book_open",j))[0];
book->version = atoi(DB_GET_VAL("version",j));
@@ -200,14 +200,14 @@ get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
for (node=blist; node; node=node->next)
{
book = node->data;
if (guid_equal (&book->guid, &guid)) break;
if (guid_equal (&book->entity.guid, &guid)) break;
book = NULL;
}
if (!book)
{
book = qof_book_new();
qof_book_set_guid (book, guid);
qof_book_set_guid (book, &guid);
}
book->book_open = (DB_GET_VAL("book_open",j))[0];
+2 -2
View File
@@ -489,7 +489,7 @@ pgend_price_commit_edit (QofBackend * bend, GNCPrice *pr)
* made changes, and we must roll back. */
if (0 < pgendPriceCompareVersion (be, pr))
{
pr->do_free = FALSE;
pr->inst.do_free = FALSE;
bufp = "ROLLBACK;";
SEND_QUERY (be,bufp,);
FINISH_QUERY(be->connection);
@@ -506,7 +506,7 @@ pgend_price_commit_edit (QofBackend * bend, GNCPrice *pr)
pr->version ++; /* be sure to update the version !! */
pr->version_check = be->version_check;
if (pr->do_free)
if (pr->inst.do_free)
{
pgendStoreAuditPrice (be, pr, SQL_DELETE);
bufp = be->buff; *bufp = 0;
+19 -19
View File
@@ -348,25 +348,25 @@ int finishQuery(PGBackend *be);
/* --------------------------------------------------------------- */
#define FIND_BOOK(book) { \
if (NULL == book) \
{ \
GList *node; \
GUID book_guid; \
\
/* Find the book that holds this item */ \
book_guid = nullguid; /* just in case the read fails */ \
string_to_guid (DB_GET_VAL("bookGUID",j), &book_guid); \
\
book = NULL; \
for (node=be->blist; node; node=node->next) \
{ \
book = node->data; \
if (guid_equal (&book->guid, &book_guid)) break; \
book = NULL; \
} \
if (!book) return data; \
} \
#define FIND_BOOK(book) { \
if (NULL == book) \
{ \
GList *node; \
GUID book_guid; \
\
/* Find the book that holds this item */ \
book_guid = nullguid; /* just in case the read fails */ \
string_to_guid (DB_GET_VAL("bookGUID",j), &book_guid); \
\
book = NULL; \
for (node=be->blist; node; node=node->next) \
{ \
book = node->data; \
if (guid_equal (&book->entity.guid, &book_guid)) break; \
book = NULL; \
} \
if (!book) return data; \
} \
}
+2 -2
View File
@@ -362,7 +362,7 @@ define(`compare_version',
p = be->buff; *p = 0;
p = stpcpy (p, "SELECT version FROM tablename($@) WHERE key_fieldname($@) = ''`");
p = guid_to_string_buff (&(ptr->guid), p);
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
p = stpcpy (p, "''`;");
SEND_QUERY (be,be->buff, -1);
sql_version = (int) pgendGetResults (be, get_version_cb, (gpointer) -1);
@@ -392,7 +392,7 @@ define(`is_deleted',
p = be->buff; *p = 0;
p = stpcpy (p, "SELECT version FROM tablename($@)" "Trail WHERE key_fieldname($@) = ''`");
p = guid_to_string_buff (&(ptr->guid), p);
p = guid_to_string_buff (qof_entity_get_guid(QOF_ENTITY(ptr)), p);
p = stpcpy (p, "''` AND change = ''`d''`;");
SEND_QUERY (be,be->buff, -1);
sql_version = (int) pgendGetResults (be, get_version_cb, (gpointer) -1);
+10 -10
View File
@@ -178,7 +178,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
{
Split *s = split_node->data;
if (s && guid_equal (&s->guid, &dti->guid))
if (s && guid_equal (&s->entity.guid, &dti->guid))
{
pgendStoreAuditSplit (be, s, SQL_DELETE);
break;
@@ -218,8 +218,8 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
/* Update the rest */
start = xaccTransGetSplitList(trans);
PINFO ("split-list=%p, do_free=%d", start, trans->do_free);
if ((start) && !(trans->do_free))
PINFO ("split-list=%p, do_free=%d", start, trans->inst.do_free);
if ((start) && !(trans->inst.do_free))
{
gnc_commodity *com;
@@ -255,7 +255,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
if (trans->idata)
{
pgendKVPDelete (be, trans->idata);
pgendKVPStore (be, trans->idata, trans->kvp_data);
pgendKVPStore (be, trans->idata, trans->inst.kvp_data);
}
}
else
@@ -473,7 +473,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
s = pgendSplitLookup (be, &guid);
if (!s)
{
s = xaccMallocSplit(trans->book);
s = xaccMallocSplit(trans->inst.book);
xaccSplitSetGUID(s, &guid);
}
@@ -809,13 +809,13 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
if (0 != trans->idata)
{
if (!kvp_frame_is_empty (trans->kvp_data))
if (!kvp_frame_is_empty (trans->inst.kvp_data))
{
kvp_frame_delete (trans->kvp_data);
trans->kvp_data = kvp_frame_new ();
kvp_frame_delete (trans->inst.kvp_data);
trans->inst.kvp_data = kvp_frame_new ();
}
trans->kvp_data = pgendKVPFetch (be, trans->idata, trans->kvp_data);
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
}
engine_splits = xaccTransGetSplitList(trans);
@@ -1003,7 +1003,7 @@ pgend_trans_commit_edit (QofBackend * bend,
"\ttransaction is '%s' %s\n",
xaccTransGetDescription (trans), buf);
rollback = 0;
trans->do_free = TRUE;
trans->inst.do_free = TRUE;
}
else
{
+1 -1
View File
@@ -269,7 +269,7 @@ pgendGetMassTransactions (PGBackend *be, QofBook *book)
if (trans->idata)
{
trans->kvp_data = pgendKVPFetch (be, trans->idata, trans->kvp_data);
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
}
splits = xaccTransGetSplitList(trans);