From 7bb5353af0bb548f1a5a61d544c2059f1b31f19d Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 27 May 2001 17:50:24 +0000 Subject: [PATCH] minor bug fix git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4307 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/sql/PostgresBackend.c | 10 +++++++++- src/engine/sql/README | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/engine/sql/PostgresBackend.c b/src/engine/sql/PostgresBackend.c index 3d12b7f7db..46f5d323f9 100644 --- a/src/engine/sql/PostgresBackend.c +++ b/src/engine/sql/PostgresBackend.c @@ -1389,6 +1389,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data) gint64 num, denom; gnc_numeric value; GUID guid = nullguid; + int not_found = 0; gnc_commodity * modity; @@ -1401,11 +1402,13 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data) pr = gnc_price_create(); gnc_price_begin_edit (pr); gnc_price_set_guid (pr, &guid); + not_found = 1; } else { gnc_price_ref (pr); gnc_price_begin_edit (pr); + not_found = 0; } modity = gnc_string_to_commodity (DB_GET_VAL("commodity",j)); @@ -1425,7 +1428,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data) value = gnc_numeric_create (num, denom); gnc_price_set_value (pr, value); - gnc_pricedb_add_price(prdb, pr); + if (not_found) gnc_pricedb_add_price(prdb, pr); gnc_price_commit_edit (pr); gnc_price_unref (pr); @@ -2374,6 +2377,11 @@ pgend_session_begin (GNCBook *sess, const char * sessionid, g_free (be->hostname); be->hostname = NULL; } +/* hack alert -- we should connect to template1 first, and look for an +entry in the system table pgdatabase i.e. SELECT datname FROM +pg_database; this should tell us if it exists already, or if it needs to +be created. +*/ be->connection = PQsetdbLogin (be->hostname, be->portno, diff --git a/src/engine/sql/README b/src/engine/sql/README index 6848d03006..f8c4c037f3 100644 --- a/src/engine/sql/README +++ b/src/engine/sql/README @@ -153,7 +153,12 @@ Core bugs/features that still need work: this. So something is marking teh data 'not saved'. fix this (again ...) --- allow user to enter URL in GUI dialog, get GUI to remember the URL +-- allow user to enter URL in GUI dialog. User can currently type url + into the file dialog window; it would be nice to have something + slightly nicer tan this. + +-- change code for initial db access. We should query the pg_database + table to see if the database already exists. -- Wire in the GUI to ask user for username/password to log onto the server. (GUI already implemented, just not yet used).