Hi:
Just because it sounded interesting to do - I started to take a look
at what it'd require to convert gnucash from saving it's data in files
to saving it's data in a database. Here's my thoughts.
First, some comments and questions on the code in general (looking at
src/engine/FileIO.c):
* Generally well structured and documented - nice work !
* Some error handling questions:
** readGroup () - can return NULL indicating an error, this return is
ignored. Is this okay ?
** memory allocation code (e.g., xaccMallocAccount) doesn't check for
error. Should/can it ?
** readAccount () can return without calling xaccCommitAccountEdit (),
and will do so if it encounters any error, is this intended ?
* There appear to be globals modified across function boundries -
where is their use documented ? (e.g. "holder" is alloced in
xaccReadAccountGroup(), and used/modified again in readAccount().)
Is it possible for some of these variables to be used before
initialized, or used in the wrong order ...
* Why all the bother with byte ordering in the data file ? Are data
files x-platform portable ? If so, nifty ! Would preserving
x-platform capability be a concern ? I'm not certain that would be
possible - it could depend heavily on the back end platform ...
Okay, all the account i/o code looks nicely isolated to FileIO.c.
Here's a couple of possibilities I see for converting the i/o code to
do database i/o:
* Make all the low level i/o functions (readGroup, writeGroup,
readAccount, writeAccount, readTransaction, writeTransaction, etc) a
function pointer. During startup and initialization, set the
pointers to the correct "actual" i/o functions
(e.g. readAccountPostgres, readAccountODBC, readAccountFile)
** Advantages
*** Existing code which calls these functions should work unmodified,
including all the code which calls these functions that I know I
didn't see tonight. :-)
*** Allows multiple data store targets with little overhead
** Disadvantages
*** Flow of control confusing
*** Potentially a lot of code to modify/create - there are read() and
write () calls all over different FileIO.c functions, high
probability of unintended side effects at first.
* Conditionally code high level functions (xaccReadAccountGroupFile,
xaccReadAccountGroup, ...) to call the proper i/o function
** Advantages & disadvantages as above, negated. :-)
Any thoughts ?
-- Pat
--
Gnucash Developer's List
To unsubscribe send empty email to: [EMAIL PROTECTED]