~ubuntu-branches/ubuntu/hoary/gnucash/hoary

« back to all changes in this revision

Viewing changes to src/engine/sql/PostgresBackend.h

  • Committer: Bazaar Package Importer
  • Author(s): James A. Treacy
  • Date: 2002-03-16 14:14:59 UTC
  • Revision ID: james.westby@ubuntu.com-20020316141459-wtkyyrpfovryhl1s
Tags: upstream-1.6.6
ImportĀ upstreamĀ versionĀ 1.6.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************\
 
2
 * PostgresBackend.h -- implements postgres backend                 *
 
3
 *                                                                  *
 
4
 * This program is free software; you can redistribute it and/or    *
 
5
 * modify it under the terms of the GNU General Public License as   *
 
6
 * published by the Free Software Foundation; either version 2 of   *
 
7
 * the License, or (at your option) any later version.              *
 
8
 *                                                                  *
 
9
 * This program is distributed in the hope that it will be useful,  *
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
 
12
 * GNU General Public License for more details.                     *
 
13
 *                                                                  *
 
14
 * You should have received a copy of the GNU General Public License*
 
15
 * along with this program; if not, contact:                        *
 
16
 *                                                                  *
 
17
 * Free Software Foundation           Voice:  +1-617-542-5942       *
 
18
 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
 
19
 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
 
20
\********************************************************************/
 
21
 
 
22
/* 
 
23
 * FILE:
 
24
 * PostgresBackend.h
 
25
 *
 
26
 * FUNCTION:
 
27
 * Implements the callbacks for the postgres backend.
 
28
 *
 
29
 * HISTORY:
 
30
 * Copyright (c) 2000, 2001 Linas Vepstas 
 
31
 */
 
32
 
 
33
 
 
34
#ifndef __POSTGRES_BACKEND_H__
 
35
#define __POSTGRES_BACKEND_H__
 
36
 
 
37
#include <libpq-fe.h>
 
38
 
 
39
#include "Group.h"
 
40
#include "guid.h"
 
41
#include "Transaction.h"
 
42
 
 
43
#include "builder.h"
 
44
#include "BackendP.h"
 
45
 
 
46
typedef struct _pgend PGBackend;
 
47
 
 
48
typedef enum {
 
49
   MODE_NONE = 0,
 
50
   MODE_SINGLE_FILE =1,
 
51
   MODE_SINGLE_UPDATE,
 
52
   MODE_POLL,
 
53
   MODE_EVENT
 
54
} AccessMode;
 
55
 
 
56
#define MAX_VERSION_AGE 10
 
57
 
 
58
struct _pgend {
 
59
   Backend be;
 
60
 
 
61
   /* session mode */
 
62
   AccessMode session_mode;
 
63
   GUID *sessionGuid;
 
64
   char session_guid_str[GUID_ENCODING_LENGTH+1];
 
65
 
 
66
   /* sql query compiler */
 
67
   sqlBuilder *builder;
 
68
 
 
69
   /* postgres-specific connection data */
 
70
   char * hostname;
 
71
   char * portno;
 
72
   char * username;
 
73
   char * dbName;
 
74
   PGconn * connection;
 
75
   gboolean freshly_created_db;
 
76
   gboolean freshly_created_prdb;
 
77
 
 
78
   /* counter used to nest callback disables */
 
79
   int nest_count;
 
80
   /* callback hooks are saved in snr during disables */
 
81
   Backend snr;    
 
82
 
 
83
   /* my postgres backend pid, used for telling apart notifies */
 
84
   int my_pid;
 
85
 
 
86
   /* notify counters */
 
87
   int do_account;
 
88
   int do_checkpoint;
 
89
   int do_price;
 
90
   int do_session;
 
91
   int do_transaction;
 
92
 
 
93
   /* notify dates */
 
94
   Timespec last_account;
 
95
   Timespec last_price;
 
96
   Timespec last_transaction;
 
97
 
 
98
   guint32 version_check; /* data aging timestamp */
 
99
 
 
100
   /* scratch space for constructing queries */ 
 
101
   int bufflen;
 
102
   char *buff;
 
103
   int nrows;  /* number of rows in query result */
 
104
 
 
105
   /* kvp path cache */
 
106
   char **path_cache;
 
107
   int path_cache_size;
 
108
   int ipath_max;
 
109
 
 
110
   /* enginge data caches -- not used anywhere except in session_end */
 
111
   AccountGroup *topgroup;
 
112
};
 
113
 
 
114
/*
 
115
 * pgendNew creates a new postgress backend
 
116
 */
 
117
Backend * pgendNew (void);
 
118
 
 
119
void pgendDisable (PGBackend *be);
 
120
void pgendEnable (PGBackend *be);
 
121
 
 
122
void pgendStoreOneTransactionOnly (PGBackend *be, Transaction *ptr, sqlBuild_QType update);
 
123
 
 
124
void pgendPutOneAccountOnly (PGBackend *be, Account *ptr);
 
125
void pgendPutOneCommodityOnly (PGBackend *be, gnc_commodity *ptr);
 
126
void pgendPutOnePriceOnly (PGBackend *be, GNCPrice *ptr);
 
127
void pgendPutOneSplitOnly (PGBackend *be, Split *ptr);
 
128
void pgendPutOneTransactionOnly (PGBackend *be, Transaction *ptr);
 
129
 
 
130
int pgendAccountCompareVersion (PGBackend *be, Account *ptr);
 
131
int pgendPriceCompareVersion (PGBackend *be, GNCPrice *ptr);
 
132
int pgendTransactionCompareVersion (PGBackend *be, Transaction *ptr);
 
133
 
 
134
void pgendStoreAuditAccount (PGBackend *be, Account *ptr, sqlBuild_QType update);
 
135
void pgendStoreAuditPrice (PGBackend *be, GNCPrice *ptr, sqlBuild_QType update);
 
136
void pgendStoreAuditSplit (PGBackend *be, Split *ptr, sqlBuild_QType update);
 
137
void pgendStoreAuditTransaction (PGBackend *be, Transaction *ptr, sqlBuild_QType update);
 
138
 
 
139
int pgendTransactionGetDeletedVersion (PGBackend *be, Transaction *ptr);
 
140
 
 
141
#endif /* __POSTGRES_BACKEND_H__ */