mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
mass restore design runs nearly as native xml file speed (only 16% slower)
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5009 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -15,7 +15,8 @@ libgnc_postgres_la_SOURCES = \
|
||||
gncquery.c \
|
||||
kvp-sql.c \
|
||||
price.c \
|
||||
txn.c
|
||||
txn.c \
|
||||
txnmass.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
PostgresBackend.h \
|
||||
@@ -28,7 +29,8 @@ noinst_HEADERS = \
|
||||
kvp-sql.h \
|
||||
price.h \
|
||||
putil.h \
|
||||
txn.h
|
||||
txn.h \
|
||||
txnmass.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
.cvsignore \
|
||||
|
||||
@@ -46,17 +46,19 @@
|
||||
#include "checkpoint.h"
|
||||
#include "kvp-sql.h"
|
||||
#include "PostgresBackend.h"
|
||||
#include "txn.h"
|
||||
#include "txnmass.h"
|
||||
|
||||
#include "putil.h"
|
||||
|
||||
static short module = MOD_TXN;
|
||||
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
static gpointer
|
||||
get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
{
|
||||
GList *node, *xaction_list = (GList *) data;
|
||||
|
||||
Transaction *trans;
|
||||
gnc_commodity *currency = NULL;
|
||||
gint64 trans_frac = 0;
|
||||
@@ -85,9 +87,13 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
/* set timestamp as 'recent' for this data */
|
||||
trans->version_check = be->version_check;
|
||||
|
||||
return NULL;
|
||||
xaction_list = g_list_prepend (xaction_list, trans);
|
||||
|
||||
return xaction_list;
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
static gpointer
|
||||
get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
{
|
||||
@@ -169,9 +175,13 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
void
|
||||
pgendGetMassTransactions (PGBackend *be, AccountGroup *grp)
|
||||
{
|
||||
GList *node, *xaction_list = NULL;
|
||||
|
||||
gnc_engine_suspend_events();
|
||||
pgendDisable(be);
|
||||
|
||||
@@ -184,9 +194,34 @@ pgendGetMassTransactions (PGBackend *be, AccountGroup *grp)
|
||||
SEND_QUERY (be, "SELECT * FROM gncEntry;", );
|
||||
pgendGetResults (be, get_mass_entry_cb, NULL);
|
||||
|
||||
for (node=xaction_list; node; node=node->next)
|
||||
{
|
||||
Transaction *trans = (Transaction *)node->data;
|
||||
GList *splits;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
/* Restore any kvp data associated with the transaction and splits.
|
||||
* We won't do this en-mass, as there currently seems to be no
|
||||
* performance advantage to doing so */
|
||||
|
||||
trans->kvp_data = pgendKVPFetch (be, &(trans->guid), trans->kvp_data);
|
||||
|
||||
splits = xaccTransGetSplitList(trans);
|
||||
for (node = splits; node; node=node->next)
|
||||
{
|
||||
Split *s = node->data;
|
||||
s->kvp_data = pgendKVPFetch (be, &(s->guid), s->kvp_data);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
xaccTransCommitEdit (trans);
|
||||
}
|
||||
g_list_free(xaction_list);
|
||||
|
||||
xaccAccountGroupCommitEdit (grp);
|
||||
|
||||
pgendEnable(be);
|
||||
gnc_engine_resume_events();
|
||||
}
|
||||
|
||||
/* ======================== END OF FILE ======================== */
|
||||
|
||||
33
src/engine/sql/txnmass.h
Normal file
33
src/engine/sql/txnmass.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* txnmass.h -- transaction mass retreival for the postgres backend *
|
||||
* Copyright (c) 2001 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef POSTGRES_TXN_MASS_H
|
||||
#define POSTGRES_TXN_MASS_H
|
||||
|
||||
#include "Group.h"
|
||||
#include "Transaction.h"
|
||||
#include "PostgresBackend.h"
|
||||
|
||||
void pgendGetMassTransactions (PGBackend *be, AccountGroup *grp);
|
||||
|
||||
|
||||
#endif /* POSTGRES_TXN_MASS_H */
|
||||
Reference in New Issue
Block a user