mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Collapse the various "idata" fields into a single field attached to
the QofInstance object. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16042 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cad2164810
commit
9ec864163d
@ -393,16 +393,8 @@ new, otherwise the book version number.
|
||||
*/
|
||||
gint32 qof_book_get_version (const QofBook *book);
|
||||
|
||||
/** get the book tag number
|
||||
|
||||
used for kvp management in sql backends.
|
||||
*/
|
||||
guint32 qof_book_get_idata (const QofBook *book);
|
||||
|
||||
void qof_book_set_version (QofBook *book, gint32 version);
|
||||
|
||||
void qof_book_set_idata(QofBook *book, guint32 idata);
|
||||
|
||||
/* @} */
|
||||
/* @} */
|
||||
/* @} */
|
||||
|
@ -76,7 +76,6 @@ qof_book_init (QofBook *book)
|
||||
|
||||
book->book_open = 'y';
|
||||
book->version = 0;
|
||||
book->idata = 0;
|
||||
}
|
||||
|
||||
QofBook *
|
||||
@ -357,24 +356,12 @@ gint32 qof_book_get_version (const QofBook *book)
|
||||
return book->version;
|
||||
}
|
||||
|
||||
guint32 qof_book_get_idata (const QofBook *book)
|
||||
{
|
||||
if(!book) { return 0; }
|
||||
return book->idata;
|
||||
}
|
||||
|
||||
void qof_book_set_version (QofBook *book, gint32 version)
|
||||
{
|
||||
if(!book && version < 0) { return; }
|
||||
book->version = version;
|
||||
}
|
||||
|
||||
void qof_book_set_idata(QofBook *book, guint32 idata)
|
||||
{
|
||||
if(!book && idata < 0) { return; }
|
||||
book->idata = idata;
|
||||
}
|
||||
|
||||
gint64
|
||||
qof_book_get_counter (QofBook *book, const char *counter_name)
|
||||
{
|
||||
|
@ -114,10 +114,6 @@ struct _QofBook
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
struct _QofBookClass
|
||||
|
@ -56,8 +56,10 @@ enum {
|
||||
PROP_DESTROYING,
|
||||
PROP_DIRTY,
|
||||
PROP_INFANT,
|
||||
|
||||
PROP_VERSION,
|
||||
PROP_VERSION_CHECK,
|
||||
PROP_IDATA,
|
||||
};
|
||||
|
||||
typedef struct QofInstancePrivate
|
||||
@ -101,6 +103,9 @@ typedef struct QofInstancePrivate
|
||||
gint32 version;
|
||||
guint32 version_check; /* data aging timestamp */
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
} QofInstancePrivate;
|
||||
|
||||
#define GET_PRIVATE(o) \
|
||||
@ -183,7 +188,7 @@ static void qof_instance_class_init(QofInstanceClass *klass)
|
||||
g_param_spec_int ("editlevel",
|
||||
"Object Edit Level",
|
||||
"The object edit level.",
|
||||
0, G_MAXINT, 0,
|
||||
0, G_MAXINT32, 0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
@ -240,6 +245,15 @@ static void qof_instance_class_init(QofInstanceClass *klass)
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_EDITLEVEL,
|
||||
g_param_spec_uint ("idata",
|
||||
"Object IData",
|
||||
"Per instance backend private data.",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -378,6 +392,9 @@ qof_instance_get_property (GObject *object,
|
||||
case PROP_VERSION_CHECK:
|
||||
g_value_set_uint(value, priv->version_check);
|
||||
break;
|
||||
case PROP_IDATA:
|
||||
g_value_set_uint(value, priv->idata);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -428,6 +445,9 @@ qof_instance_set_property (GObject *object,
|
||||
case PROP_VERSION_CHECK:
|
||||
qof_instance_set_version_check(inst, g_value_get_uint(value));
|
||||
break;
|
||||
case PROP_IDATA:
|
||||
qof_instance_set_idata(inst, g_value_get_uint(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -780,6 +800,21 @@ qof_instance_copy_version_check (gpointer to, gconstpointer from)
|
||||
GET_PRIVATE(to)->version_check = GET_PRIVATE(from)->version_check;
|
||||
}
|
||||
|
||||
guint32 qof_instance_get_idata (gconstpointer inst)
|
||||
{
|
||||
if(!inst) { return 0; }
|
||||
g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
|
||||
return GET_PRIVATE(inst)->idata;
|
||||
}
|
||||
|
||||
void qof_instance_set_idata(gpointer inst, guint32 idata)
|
||||
{
|
||||
if(!inst) { return; }
|
||||
if(idata < 0) { return; }
|
||||
g_return_if_fail(QOF_IS_INSTANCE(inst));
|
||||
GET_PRIVATE(inst)->idata = idata;
|
||||
}
|
||||
|
||||
/* ========================================================== */
|
||||
|
||||
void
|
||||
|
@ -218,6 +218,11 @@ void qof_instance_set_version_check (gpointer inst, guint32 value);
|
||||
/** copy the instance version_check number */
|
||||
void qof_instance_copy_version_check (gpointer to, gconstpointer from);
|
||||
|
||||
/** get the instance tag number
|
||||
used for kvp management in sql backends. */
|
||||
guint32 qof_instance_get_idata (gconstpointer inst);
|
||||
void qof_instance_set_idata(gpointer inst, guint32 idata);
|
||||
|
||||
/** Pair things up. This routine inserts a kvp value into each instance
|
||||
* containing the guid of the other. In this way, if one has one of the
|
||||
* pair, one can always find the other by looking up it's guid. Typically,
|
||||
|
@ -466,7 +466,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
ts = gnc_iso8601_to_timespec_gmt (DB_GET_VAL("date_entered",j));
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
trans->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(trans, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j),
|
||||
pgendGetBook(be));
|
||||
@ -564,13 +564,15 @@ pgendFillOutToCheckpoint (PGBackend *be, const char *query_string)
|
||||
Transaction *trans = (Transaction *) node->data;
|
||||
GList *engine_splits, *snode;
|
||||
|
||||
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
|
||||
trans->inst.kvp_data = pgendKVPFetch(be, qof_instance_get_idata(trans),
|
||||
trans->inst.kvp_data);
|
||||
|
||||
engine_splits = xaccTransGetSplitList(trans);
|
||||
for (snode = engine_splits; snode; snode=snode->next)
|
||||
{
|
||||
Split *s = snode->data;
|
||||
s->inst.kvp_data = pgendKVPFetch (be, s->idata, s->inst.kvp_data);
|
||||
s->inst.kvp_data = pgendKVPFetch(be, qof_instance_get_idata(s),
|
||||
s->inst.kvp_data);
|
||||
}
|
||||
|
||||
xaccTransCommitEdit (trans);
|
||||
|
@ -79,6 +79,7 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
|
||||
gboolean do_check_version)
|
||||
{
|
||||
const gnc_commodity *com;
|
||||
guint32 a_idata;
|
||||
|
||||
if (!be || !acct) return;
|
||||
if ((FALSE == do_mark) && (!qof_instance_get_dirty_flag(acct)))
|
||||
@ -105,10 +106,12 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
|
||||
/* be sure to update the version !! */
|
||||
qof_instance_increment_version(acct, be->version_check);
|
||||
|
||||
if ((0 == acct->idata) &&
|
||||
a_idata = qof_instance_get_idata(acct);
|
||||
if ((0 == a_idata) &&
|
||||
(FALSE == kvp_frame_is_empty (xaccAccountGetSlots(acct))))
|
||||
{
|
||||
acct->idata = pgendNewGUIDidx(be);
|
||||
a_idata = pgendNewGUIDidx(be);
|
||||
qof_instance_set_idata(acct, a_idata);
|
||||
}
|
||||
|
||||
pgendPutOneAccountOnly (be, acct);
|
||||
@ -126,10 +129,10 @@ pgendStoreAccountNoLock (PGBackend *be, Account *acct,
|
||||
com = xaccAccountGetCommodity (acct);
|
||||
pgendPutOneCommodityOnly (be, (gnc_commodity *) com);
|
||||
|
||||
if (acct->idata)
|
||||
if (a_idata)
|
||||
{
|
||||
pgendKVPDelete (be, acct->idata);
|
||||
pgendKVPStore (be, acct->idata, acct->inst.kvp_data);
|
||||
pgendKVPDelete (be, a_idata);
|
||||
pgendKVPStore (be, a_idata, acct->inst.kvp_data);
|
||||
}
|
||||
LEAVE(" ");
|
||||
}
|
||||
@ -208,8 +211,9 @@ static void
|
||||
restore_cb (Account *acc, void * cb_data)
|
||||
{
|
||||
PGBackend *be = (PGBackend *) cb_data;
|
||||
if (0 == acc->idata) return;
|
||||
acc->inst.kvp_data = pgendKVPFetch (be, acc->idata, acc->inst.kvp_data);
|
||||
guint32 a_idata = qof_instance_get_idata(acc);
|
||||
if (0 == a_idata) return;
|
||||
acc->inst.kvp_data = pgendKVPFetch (be, a_idata, acc->inst.kvp_data);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -301,7 +305,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
if (commodity)
|
||||
xaccAccountSetCommodity(acc, commodity);
|
||||
qof_instance_set_version(acc, atoi(DB_GET_VAL("version",j)));
|
||||
acc->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(acc, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
/* try to find the parent account */
|
||||
PINFO ("parent GUID=%s", DB_GET_VAL("parentGUID",j));
|
||||
@ -475,6 +479,7 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||
char *pbuff;
|
||||
Account *acc = NULL;
|
||||
int engine_data_is_newer = 0;
|
||||
guint32 a_idata;
|
||||
|
||||
ENTER ("be=%p", be);
|
||||
if (!be || !acct_guid) return 0;
|
||||
@ -523,9 +528,10 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||
/* restore any kvp data associated with the transaction and splits */
|
||||
if (acc)
|
||||
{
|
||||
if (acc->idata)
|
||||
a_idata = qof_instance_get_idata(acc);
|
||||
if (a_idata)
|
||||
{
|
||||
acc->inst.kvp_data = pgendKVPFetch (be, acc->idata, acc->inst.kvp_data);
|
||||
acc->inst.kvp_data = pgendKVPFetch (be, a_idata, acc->inst.kvp_data);
|
||||
}
|
||||
|
||||
qof_instance_set_version_check(acc, be->version_check);
|
||||
@ -597,7 +603,7 @@ pgend_account_commit_edit (QofBackend * bend,
|
||||
if (qof_instance_get_destroying(acct))
|
||||
{
|
||||
const GUID *guid = xaccAccountGetGUID(acct);
|
||||
pgendKVPDelete (be, acct->idata);
|
||||
pgendKVPDelete (be, qof_instance_get_idata(acct));
|
||||
|
||||
p = be->buff; *p = 0;
|
||||
p = stpcpy (p, "DELETE FROM gncAccount WHERE accountGuid='");
|
||||
|
@ -69,7 +69,7 @@ void
|
||||
pgendStoreBookNoLock (PGBackend *be, QofBook *book,
|
||||
gboolean do_check_version)
|
||||
{
|
||||
gint32 idata;
|
||||
guint32 idata;
|
||||
if (!be || !book) return;
|
||||
|
||||
ENTER ("book=%p", book);
|
||||
@ -80,14 +80,14 @@ pgendStoreBookNoLock (PGBackend *be, QofBook *book,
|
||||
}
|
||||
qof_book_set_version(book, (qof_book_get_version(book) +1)); /* be sure to update the version !! */
|
||||
|
||||
if ((0 == qof_book_get_idata(book)) &&
|
||||
if ((0 == qof_instance_get_idata(book)) &&
|
||||
(FALSE == kvp_frame_is_empty (qof_book_get_slots(book))))
|
||||
{
|
||||
qof_book_set_idata(book, pgendNewGUIDidx(be));
|
||||
qof_instance_set_idata(book, pgendNewGUIDidx(be));
|
||||
}
|
||||
|
||||
pgendPutOneBookOnly (be, book);
|
||||
idata = qof_book_get_idata(book);
|
||||
idata = qof_instance_get_idata(book);
|
||||
if ( idata > 0)
|
||||
{
|
||||
pgendKVPDelete (be, idata);
|
||||
@ -146,7 +146,7 @@ get_one_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
qof_book_mark_closed(book);
|
||||
}
|
||||
qof_book_set_version(book, atoi(DB_GET_VAL("version",j)));
|
||||
qof_book_set_idata(book, atoi(DB_GET_VAL("iguid",j)));
|
||||
qof_instance_set_idata(book, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
return book;
|
||||
}
|
||||
@ -174,11 +174,11 @@ pgendBookRestore (PGBackend *be, QofBook *book)
|
||||
SEND_QUERY (be, bufp, );
|
||||
pgendGetResults (be, get_one_book_cb, book);
|
||||
|
||||
if (0 != qof_book_get_idata(book))
|
||||
if (0 != qof_instance_get_idata(book))
|
||||
{
|
||||
KvpFrame *pg_frame;
|
||||
|
||||
pg_frame = pgendKVPFetch (be, qof_book_get_idata(book),
|
||||
pg_frame = pgendKVPFetch (be, qof_instance_get_idata(book),
|
||||
qof_instance_get_slots((QofInstance*)book));
|
||||
kvp_frame_for_each_slot(pg_frame, pg_kvp_helper, book);
|
||||
}
|
||||
@ -224,7 +224,7 @@ get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
}
|
||||
// book->book_open = (DB_GET_VAL("book_open",j))[0];
|
||||
qof_book_set_version(book, atoi(DB_GET_VAL("version",j)));
|
||||
qof_book_set_idata(book, atoi(DB_GET_VAL("iguid",j)));
|
||||
qof_instance_set_idata(book, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
return blist;
|
||||
}
|
||||
@ -247,17 +247,18 @@ pgendGetAllBooks (PGBackend *be, QofBookList *blist)
|
||||
for (node=blist; node; node=node->next)
|
||||
{
|
||||
QofBook *book = node->data;
|
||||
if (0 != qof_book_get_idata(book))
|
||||
if (0 != qof_instance_get_idata(book))
|
||||
{
|
||||
KvpFrame *pg_frame;
|
||||
|
||||
pg_frame = pgendKVPFetch (be, qof_book_get_idata(book),
|
||||
pg_frame = pgendKVPFetch (be, qof_instance_get_idata(book),
|
||||
qof_instance_get_slots((QofInstance*)book));
|
||||
kvp_frame_for_each_slot(pg_frame, pg_kvp_helper, book);
|
||||
}
|
||||
/* if (0 != book->idata)
|
||||
/* if (0 != qof_instance_get_idata(book))
|
||||
{
|
||||
book->inst.kvp_data = pgendKVPFetch (be, book->idata, book->inst.kvp_data);
|
||||
book->inst.kvp_data = pgendKVPFetch(be, qof_instance_get_idata(book),
|
||||
book->inst.kvp_data);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ define(`account', `gncAccount, Account, Account, a,
|
||||
type, , char *, xaccAccountTypeEnumAsString(xaccAccountGetType(ptr)),
|
||||
commodity, , char *, gnc_commodity_get_unique_name(xaccAccountGetCommodity(ptr)),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
iguid, , int32, ptr->idata,
|
||||
iguid, , int32, qof_instance_get_idata(ptr),
|
||||
bookGUID, , GUID *, qof_instance_get_guid((QofInstance*)gnc_account_get_book(ptr)),
|
||||
parentGUID, , GUID *, xaccAccountGetGUID(gnc_account_get_parent(ptr)),
|
||||
accountGUID, KEY, GUID *, xaccAccountGetGUID(ptr),
|
||||
@ -21,7 +21,7 @@ define(`account', `gncAccount, Account, Account, a,
|
||||
define(`book', `gncBook, Book, QofBook, b,
|
||||
book_open, , char, qof_book_get_open_marker(ptr),
|
||||
version, , int32, qof_book_get_version(ptr),
|
||||
iguid, , int32, qof_book_get_idata(ptr),
|
||||
iguid, , int32, qof_instance_get_idata(ptr),
|
||||
bookGUID, KEY, GUID *, qof_book_get_guid(ptr),
|
||||
')
|
||||
|
||||
@ -34,7 +34,7 @@ define(`split', `gncSplit, Split, Split, e,
|
||||
date_reconciled, , Timespec, xaccSplitRetDateReconciledTS(ptr),
|
||||
amount, , int64, gnc_numeric_num(xaccSplitGetAmount(ptr)),
|
||||
value, , int64, gnc_numeric_num(xaccSplitGetValue(ptr)),
|
||||
iguid, , int32, ptr->idata,
|
||||
iguid, , int32, qof_instance_get_idata(ptr),
|
||||
splitGuid, KEY, GUID *, xaccSplitGetGUID(ptr),
|
||||
')
|
||||
|
||||
@ -53,7 +53,7 @@ define(`transaction', `gncTransaction, Transaction, Transaction, t,
|
||||
date_entered, , Timespec, xaccTransRetDateEnteredTS(ptr),
|
||||
date_posted, , Timespec, xaccTransRetDatePostedTS(ptr),
|
||||
version, , int32, qof_instance_get_version(ptr),
|
||||
iguid, , int32, ptr->idata,
|
||||
iguid, , int32, qof_instance_get_idata(ptr),
|
||||
transGUID, KEY, GUID *, xaccTransGetGUID(ptr),
|
||||
')
|
||||
|
||||
|
@ -133,6 +133,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
gboolean do_check_version)
|
||||
{
|
||||
GList *start, *deletelist=NULL, *node;
|
||||
guint32 s_idata, t_idata;
|
||||
char * p;
|
||||
|
||||
if (!be || !trans) return;
|
||||
@ -220,23 +221,27 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
for (node=start; node; node=node->next)
|
||||
{
|
||||
Split * s = node->data;
|
||||
if ((0 == s->idata) &&
|
||||
s_idata = qof_instance_get_idata(s);
|
||||
if ((0 == s_idata) &&
|
||||
(FALSE == kvp_frame_is_empty (xaccSplitGetSlots(s))))
|
||||
{
|
||||
s->idata = pgendNewGUIDidx(be);
|
||||
s_idata = pgendNewGUIDidx(be);
|
||||
qof_instance_set_idata(s, s_idata);
|
||||
}
|
||||
pgendPutOneSplitOnly (be, s);
|
||||
if (s->idata)
|
||||
if (s_idata)
|
||||
{
|
||||
pgendKVPDelete (be, s->idata);
|
||||
pgendKVPStore (be, s->idata, s->inst.kvp_data);
|
||||
pgendKVPDelete (be, s_idata);
|
||||
pgendKVPStore (be, s_idata, s->inst.kvp_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ((0 == trans->idata) &&
|
||||
t_idata = qof_instance_get_idata(trans);
|
||||
if ((0 == t_idata) &&
|
||||
(FALSE == kvp_frame_is_empty (xaccTransGetSlots(trans))))
|
||||
{
|
||||
trans->idata = pgendNewGUIDidx(be);
|
||||
t_idata = pgendNewGUIDidx(be);
|
||||
qof_instance_set_idata(trans, t_idata);
|
||||
}
|
||||
|
||||
/* Make sure the commodity is in the table.
|
||||
@ -246,10 +251,10 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
|
||||
pgendPutOneTransactionOnly (be, trans);
|
||||
|
||||
if (trans->idata)
|
||||
if (t_idata)
|
||||
{
|
||||
pgendKVPDelete (be, trans->idata);
|
||||
pgendKVPStore (be, trans->idata, trans->inst.kvp_data);
|
||||
pgendKVPDelete (be, t_idata);
|
||||
pgendKVPStore (be, t_idata, trans->inst.kvp_data);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -282,9 +287,11 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
|
||||
for (node=start; node; node=node->next)
|
||||
{
|
||||
Split * s = node->data;
|
||||
if (0 != s->idata) pgendKVPDelete (be, s->idata);
|
||||
s_idata = qof_instance_get_idata(s);
|
||||
if (0 != s_idata) pgendKVPDelete (be, s_idata);
|
||||
}
|
||||
if (0 != trans->idata) pgendKVPDelete (be, trans->idata);
|
||||
t_idata = qof_instance_get_idata(trans);
|
||||
if (0 != t_idata) pgendKVPDelete (be, t_idata);
|
||||
}
|
||||
|
||||
LEAVE(" ");
|
||||
@ -479,7 +486,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
|
||||
xaccSplitSetDateReconciledTS (s, &ts);
|
||||
|
||||
xaccSplitSetReconcile (s, (DB_GET_VAL("reconciled", j))[0]);
|
||||
s->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(s, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
/* --------------------------------------------- */
|
||||
/* next, find the account that this split goes into */
|
||||
@ -632,6 +639,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
int engine_data_is_newer = 0;
|
||||
int j;
|
||||
GList *node, *engine_splits;
|
||||
guint32 s_idata, t_idata;
|
||||
|
||||
ENTER ("be=%p", be);
|
||||
if (!be || !trans_guid) return 0;
|
||||
@ -755,7 +763,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
trans->idata = atoi(DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(trans, atoi(DB_GET_VAL("iguid",j)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +790,8 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
/* ------------------------------------------------- */
|
||||
/* restore any kvp data associated with the transaction and splits */
|
||||
|
||||
if (0 != trans->idata)
|
||||
t_idata = qof_instance_get_idata(trans);
|
||||
if (0 != t_idata)
|
||||
{
|
||||
if (!kvp_frame_is_empty (trans->inst.kvp_data))
|
||||
{
|
||||
@ -790,14 +799,15 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
trans->inst.kvp_data = kvp_frame_new ();
|
||||
}
|
||||
|
||||
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
|
||||
trans->inst.kvp_data = pgendKVPFetch (be, t_idata, trans->inst.kvp_data);
|
||||
}
|
||||
|
||||
engine_splits = xaccTransGetSplitList(trans);
|
||||
for (node = engine_splits; node; node=node->next)
|
||||
{
|
||||
Split *s = node->data;
|
||||
if (0 != s->idata)
|
||||
s_idata = qof_instance_get_idata(s);
|
||||
if (0 != s_idata)
|
||||
{
|
||||
if (!kvp_frame_is_empty (s->inst.kvp_data))
|
||||
{
|
||||
@ -805,7 +815,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
||||
s->inst.kvp_data = kvp_frame_new ();
|
||||
}
|
||||
|
||||
s->inst.kvp_data = pgendKVPFetch (be, s->idata, s->inst.kvp_data);
|
||||
s->inst.kvp_data = pgendKVPFetch (be, s_idata, s->inst.kvp_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
ts = gnc_iso8601_to_timespec_gmt (DB_GET_VAL("date_entered",j));
|
||||
xaccTransSetDateEnteredTS (trans, &ts);
|
||||
qof_instance_set_version (trans, atoi(DB_GET_VAL("version",j)));
|
||||
trans->idata = atoi (DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(trans, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
currency = gnc_string_to_commodity (DB_GET_VAL("currency",j), book);
|
||||
|
||||
@ -147,7 +147,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
xaccSplitSetDateReconciledTS (s, &ts);
|
||||
|
||||
xaccSplitSetReconcile (s, (DB_GET_VAL("reconciled", j))[0]);
|
||||
s->idata = atoi (DB_GET_VAL("iguid",j));
|
||||
qof_instance_set_idata(s, atoi(DB_GET_VAL("iguid",j)));
|
||||
|
||||
guid = nullguid; /* just in case the read fails ... */
|
||||
string_to_guid (DB_GET_VAL("transGUID",j), &guid);
|
||||
@ -214,6 +214,7 @@ pgendGetMassTransactions (PGBackend *be, QofBook *book)
|
||||
char *p, buff[900];
|
||||
GList *node, *xaction_list = NULL;
|
||||
Account *root;
|
||||
guint32 t_idata, s_idata;
|
||||
|
||||
qof_event_suspend();
|
||||
pgendDisable(be);
|
||||
@ -258,18 +259,20 @@ pgendGetMassTransactions (PGBackend *be, QofBook *book)
|
||||
* We won't do this en-mass, as there currently seems to be no
|
||||
* performance advantage to doing so */
|
||||
|
||||
if (trans->idata)
|
||||
t_idata = qof_instance_get_idata(trans);
|
||||
if (t_idata)
|
||||
{
|
||||
trans->inst.kvp_data = pgendKVPFetch (be, trans->idata, trans->inst.kvp_data);
|
||||
trans->inst.kvp_data = pgendKVPFetch (be, t_idata, trans->inst.kvp_data);
|
||||
}
|
||||
|
||||
splits = xaccTransGetSplitList(trans);
|
||||
for (snode = splits; snode; snode=snode->next)
|
||||
{
|
||||
Split *s = snode->data;
|
||||
if (s->idata)
|
||||
s_idata = qof_instance_get_idata(s);
|
||||
if (s_idata)
|
||||
{
|
||||
s->inst.kvp_data = pgendKVPFetch (be, s->idata, s->inst.kvp_data);
|
||||
s->inst.kvp_data = pgendKVPFetch (be, s_idata, s->inst.kvp_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -726,8 +726,6 @@ xaccInitAccount (Account * acc, QofBook *book)
|
||||
ENTER ("book=%p\n", book);
|
||||
qof_instance_init_data (&acc->inst, GNC_ID_ACCOUNT, book);
|
||||
|
||||
acc->idata = 0;
|
||||
|
||||
LEAVE ("account=%p\n", acc);
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,6 @@
|
||||
struct account_s
|
||||
{
|
||||
QofInstance inst;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
/* Set the account's GUID. This should only be done when reading
|
||||
|
@ -101,8 +101,6 @@ xaccInitSplit(Split * split, QofBook *book)
|
||||
split->cleared_balance = gnc_numeric_zero();
|
||||
split->reconciled_balance = gnc_numeric_zero();
|
||||
|
||||
split->idata = 0;
|
||||
|
||||
split->gains = GAINS_STATUS_UNKNOWN;
|
||||
split->gains_split = NULL;
|
||||
|
||||
@ -134,7 +132,7 @@ xaccSplitReinit(Split * split)
|
||||
if (split->inst.kvp_data)
|
||||
kvp_frame_delete(split->inst.kvp_data);
|
||||
split->inst.kvp_data = kvp_frame_new();
|
||||
split->idata = 0;
|
||||
qof_instance_set_idata(split, 0);
|
||||
|
||||
split->gains = GAINS_STATUS_UNKNOWN;
|
||||
split->gains_split = NULL;
|
||||
@ -217,7 +215,6 @@ xaccSplitClone (const Split *s)
|
||||
split->balance = s->balance;
|
||||
split->cleared_balance = s->cleared_balance;
|
||||
split->reconciled_balance = s->reconciled_balance;
|
||||
split->idata = 0;
|
||||
|
||||
split->gains = GAINS_STATUS_UNKNOWN;
|
||||
split->gains_split = NULL;
|
||||
@ -255,7 +252,7 @@ xaccSplitDump (const Split *split, const char *tag)
|
||||
printf(" CBalance: %s\n", gnc_numeric_to_string(split->cleared_balance));
|
||||
printf(" RBalance: %s\n",
|
||||
gnc_numeric_to_string(split->reconciled_balance));
|
||||
printf(" idata: %x\n", split->idata);
|
||||
printf(" idata: %x\n", qof_instance_get_idata(split));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -125,10 +125,6 @@ struct split_s
|
||||
gnc_numeric balance;
|
||||
gnc_numeric cleared_balance;
|
||||
gnc_numeric reconciled_balance;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
struct _SplitClass
|
||||
|
@ -274,7 +274,6 @@ xaccInitTransaction (Transaction * trans, QofBook *book)
|
||||
trans->marker = 0;
|
||||
trans->orig = NULL;
|
||||
|
||||
trans->idata = 0;
|
||||
qof_instance_init_data (&trans->inst, GNC_ID_TRANS, book);
|
||||
LEAVE (" ");
|
||||
}
|
||||
@ -314,7 +313,7 @@ xaccTransDump (const Transaction *trans, const char *tag)
|
||||
printf(" version_chk: %x\n", qof_instance_get_version_check(trans));
|
||||
printf(" editlevel: %x\n", qof_instance_get_editlevel(trans));
|
||||
printf(" orig: %p\n", trans->orig);
|
||||
printf(" idata: %x\n", trans->idata);
|
||||
printf(" idata: %x\n", qof_instance_get_idata(trans));
|
||||
printf(" splits: ");
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
{
|
||||
@ -424,7 +423,6 @@ xaccTransClone (const Transaction *t)
|
||||
qof_instance_copy_version_check(trans, t);
|
||||
|
||||
trans->orig = NULL;
|
||||
trans->idata = 0;
|
||||
|
||||
qof_instance_init_data (&trans->inst, GNC_ID_TRANS, qof_instance_get_book(t));
|
||||
kvp_frame_delete (trans->inst.kvp_data);
|
||||
|
@ -110,10 +110,6 @@ struct transaction_s
|
||||
* any changes made if/when the edit is abandoned.
|
||||
*/
|
||||
Transaction *orig;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
struct _TransactionClass
|
||||
|
Loading…
Reference in New Issue
Block a user