Skip to content

Commit

Permalink
Matthew Vanecek's patch:
Browse files Browse the repository at this point in the history
This patch corrects some compiler warnings from gcc 2.96.x, and it fixes
some malformed SQL pointed out by Christopher Browne.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7762 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
derekatkins committed Jan 3, 2003
1 parent 7e731a1 commit 9faae84
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2003-01-03 Matthew Vanecek <mevanecek@yahoo.com>
* src/backend/postgres/Postgresbackend.c: Fixed some compiler
warning messages about MODE_NONE and a some GUIDs used as
string pointers in informational messages.

* src/backend/postgres/test/test-db.c: Commented out the
"short module" declaration. It was not used and was causing a
compiler warning.

* src/backend/postgres/upgrade.c: Changed the "ALTER TABLE table
ADD COLUMN..." statements to conform to the current Postgres
implementation (and SQL 92) standard by putting the DEFAULT
modifier in a separate ALTER statement. This was reported by
Christopher B. Browne.

2003-01-02 David Hampton <hampton@employees.org>

* src/report/report-system/html-utilities.scm: Fix malformed URLs
Expand Down
32 changes: 19 additions & 13 deletions src/backend/postgres/PostgresBackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pgendAccountLookup (PGBackend *be, const GUID *acct_guid)
GList *node;
Account * acc = NULL;

ENTER("guid = %s", acct_guid);
ENTER("guid = %s", guid_to_string(acct_guid));
for (node=be->blist; node; node=node->next)
{
GNCBook *book = node->data;
Expand All @@ -166,7 +166,7 @@ pgendTransLookup (PGBackend *be, const GUID *txn_guid)
GList *node;
Transaction * txn = NULL;

ENTER("guid = %s", txn_guid);
ENTER("guid = %s", guid_to_string(txn_guid));
for (node=be->blist; node; node=node->next)
{
GNCBook *book = node->data;
Expand All @@ -184,7 +184,7 @@ pgendSplitLookup (PGBackend *be, const GUID *split_guid)
GList *node;
Split * split = NULL;

ENTER("guid = %s", split_guid);
ENTER("guid = %s", guid_to_string(split_guid));
for (node=be->blist; node; node=node->next)
{
GNCBook *book = node->data;
Expand All @@ -202,7 +202,7 @@ pgendPriceLookup (PGBackend *be, const GUID *price_guid)
GList *node;
GNCPrice * price = NULL;

ENTER("guid = %s", price_guid);
ENTER("guid = %s", guid_to_string(price_guid));
for (node=be->blist; node; node=node->next)
{
GNCBook *book = node->data;
Expand All @@ -219,7 +219,7 @@ pgendGUIDType (PGBackend *be, const GUID *guid)
GList *node;
GNCIdType tip = GNC_ID_NONE;

ENTER("guid = %s", guid);
ENTER("guid = %s", guid_to_string(guid));
for (node=be->blist; node; node=node->next)
{
GNCBook *book = node->data;
Expand Down Expand Up @@ -1137,6 +1137,9 @@ pgendSessionGetMode (PGBackend *be)
return "POLL";
case MODE_EVENT:
return "EVENT";
/* quiet compiler warnings about MODE_NONE */
default:
return "ERROR";
}
return "ERROR";
}
Expand Down Expand Up @@ -1629,15 +1632,15 @@ pgend_do_begin (Backend *bend, GNCIdTypeConst type, gpointer object)
return pgend_book_transfer_begin (bend, object);

switch (be->session_mode) {
case MODE_EVENT:
case MODE_POLL:
case MODE_SINGLE_UPDATE:

if (!safe_strcmp (type, GNC_ID_PRICE))
return pgend_price_begin_edit (bend, object);
case MODE_EVENT:
case MODE_POLL:
case MODE_SINGLE_UPDATE:
if (!safe_strcmp (type, GNC_ID_PRICE))
return pgend_price_begin_edit (bend, object);

case MODE_SINGLE_FILE:
break;
case MODE_SINGLE_FILE:
case MODE_NONE:
break;
}

/* XXX: Add dynamic plug-in here */
Expand Down Expand Up @@ -1670,7 +1673,9 @@ pgend_do_commit (Backend *bend, GNCIdTypeConst type, gpointer object)
return pgend_account_commit_edit (bend, object);

case MODE_SINGLE_FILE:
case MODE_NONE:
break;

}

/* XXX: Add dynamic plug-in here */
Expand All @@ -1692,6 +1697,7 @@ pgend_do_rollback (Backend *bend, GNCIdTypeConst type, gpointer object)

case MODE_SINGLE_UPDATE:
case MODE_SINGLE_FILE:
case MODE_NONE:
break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/backend/postgres/test/test-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "test-stuff.h"
#include "test-engine-stuff.h"

static short module = MOD_TEST;
/* Prevent compiler warnings. Uncomment if LEAVE/WARN/et al get used*/
/* static short module = MOD_TEST; */

static void
save_xml_file (GNCSession *session, const char *filename_base)
Expand Down
18 changes: 12 additions & 6 deletions src/backend/postgres/upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ put_iguid_in_tables (PGBackend *be)
SEND_QUERY (be,buff, );
FINISH_QUERY(be->connection);

p = "ALTER TABLE gncEntry ADD COLUMN iguid INT4 DEFAULT 0;\n"
p = "ALTER TABLE gncEntry ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncEntry ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncEntry SET iguid = 0;\n"

"UPDATE gncEntry SET iguid = gncGUIDCache.iguid "
" FROM gncGUIDCache, gncKVPValue "
" WHERE gncGUIDCache.guid = gncEntry.entryGUID "
" AND gncGUIDCache.iguid = gncKVPValue.iguid;\n"

"ALTER TABLE gncEntryTrail ADD COLUMN iguid INT4 DEFAULT 0;\n"
"ALTER TABLE gncEntryTrail ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncEntryTrail ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncEntryTrail SET iguid = 0;\n"

"UPDATE gncEntryTrail SET iguid = gncGUIDCache.iguid "
Expand All @@ -170,15 +172,17 @@ put_iguid_in_tables (PGBackend *be)
SEND_QUERY (be,p, );
FINISH_QUERY(be->connection);

p = "ALTER TABLE gncTransaction ADD COLUMN iguid INT4 DEFAULT 0;\n"
p = "ALTER TABLE gncTransaction ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncTransaction ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncTransaction SET iguid = 0;\n"

"UPDATE gncTransaction SET iguid = gncGUIDCache.iguid "
" FROM gncGUIDCache, gncKVPValue "
" WHERE gncGUIDCache.guid = gncTransaction.transGUID "
" AND gncGUIDCache.iguid = gncKVPValue.iguid;\n"

"ALTER TABLE gncTransactionTrail ADD COLUMN iguid INT4 DEFAULT 0;\n"
"ALTER TABLE gncTransactionTrail ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncTransactionTrail ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncTransactionTrail SET iguid = 0;\n"

"UPDATE gncTransactionTrail SET iguid = gncGUIDCache.iguid "
Expand All @@ -188,15 +192,17 @@ put_iguid_in_tables (PGBackend *be)
SEND_QUERY (be,p, );
FINISH_QUERY(be->connection);

p = "ALTER TABLE gncAccount ADD COLUMN iguid INT4 DEFAULT 0;\n"
p = "ALTER TABLE gncAccount ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncAccount ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncAccount SET iguid = 0;\n"

"UPDATE gncAccount SET iguid = gncGUIDCache.iguid "
" FROM gncGUIDCache, gncKVPValue "
" WHERE gncGUIDCache.guid = gncAccount.accountGUID "
" AND gncGUIDCache.iguid = gncKVPValue.iguid;\n"

"ALTER TABLE gncAccountTrail ADD COLUMN iguid INT4 DEFAULT 0;\n"
"ALTER TABLE gncAccountTrail ADD COLUMN iguid INT4;\n"
"ALTER TABLE gncAccountTrail ALTER COLUMN iguid set DEFAULT 0;\n"
"UPDATE gncAccountTrail SET iguid = 0;\n"

"UPDATE gncAccountTrail SET iguid = gncGUIDCache.iguid "
Expand Down

0 comments on commit 9faae84

Please sign in to comment.