mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/backend/postgres/PostgresBackend.c (pgendEnable):
Added ENTER/LEAVE statements * src/backend/postgres/escape.c: Adde gnc-engine-util.h, and "module = MOD_BACKEND" - (sqlEscape_destroy): Added ENTER/LEAVE statemtents. * src/backend/postgres/gncquery.c (sql_Query_destroy): Added ENTER/LEAVE statements. * src/backend/postgres/putil.h: Cleaned up the formatting on the SEND/FINISH/EXEC/GET_RESULT macros. Changed them to use PQresultErrorMessage where possible. Made them all set the Backend error message string. Removed the PQfinish() calls, and setting be->connection to NULL. Reasoning: if a malformed query fails, there is no reason to close the connection. If an update/insert fails, again, there is no need to close the connection. The user should be presented an error message and respond appropriately. If a update/insert/delete fails, then generally the transaction is rolled back to the last BEGIN, thereby preventing data corruption. * src/engine/QueryNew.c (gncQueryPrint): Check that q is not NULL prior to processing it. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7905 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
dda9a689f7
commit
5acf50fa9b
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
2003-02-01 Matthew Vanecek <mevanecek@yahoo.com>
|
||||||
|
|
||||||
|
* src/backend/postgres/PostgresBackend.c (pgendEnable):
|
||||||
|
Added ENTER/LEAVE statements
|
||||||
|
|
||||||
|
* src/backend/postgres/escape.c: Adde gnc-engine-util.h,
|
||||||
|
and "module = MOD_BACKEND"
|
||||||
|
- (sqlEscape_destroy): Added ENTER/LEAVE statemtents.
|
||||||
|
|
||||||
|
* src/backend/postgres/gncquery.c (sql_Query_destroy): Added
|
||||||
|
ENTER/LEAVE statements.
|
||||||
|
|
||||||
|
* src/backend/postgres/putil.h: Cleaned up the formatting on the
|
||||||
|
SEND/FINISH/EXEC/GET_RESULT macros. Changed them to use
|
||||||
|
PQresultErrorMessage where possible. Made them all set the Backend
|
||||||
|
error message string. Removed the PQfinish() calls, and setting
|
||||||
|
be->connection to NULL. Reasoning: if a malformed query fails, there is
|
||||||
|
no reason to close the connection. If an update/insert fails,
|
||||||
|
again, there is no need to close the connection. The user should
|
||||||
|
be presented an error message and respond appropriately. If
|
||||||
|
a update/insert/delete fails, then generally the transaction is
|
||||||
|
rolled back to the last BEGIN, thereby preventing data corruption.
|
||||||
|
|
||||||
|
* src/engine/QueryNew.c (gncQueryPrint): Check that q is not NULL
|
||||||
|
prior to processing it.
|
||||||
|
|
||||||
2003-02-01 Derek Atkins <derek@ihtfp.com>
|
2003-02-01 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
* src/gnome/window-register.c: fix the query code to use the correct
|
* src/gnome/window-register.c: fix the query code to use the correct
|
||||||
|
@ -2405,6 +2405,7 @@ pgendDisable (PGBackend *be)
|
|||||||
void
|
void
|
||||||
pgendEnable (PGBackend *be)
|
pgendEnable (PGBackend *be)
|
||||||
{
|
{
|
||||||
|
ENTER(" ");
|
||||||
if (0 >= be->nest_count)
|
if (0 >= be->nest_count)
|
||||||
{
|
{
|
||||||
PERR ("too many nested disables");
|
PERR ("too many nested disables");
|
||||||
@ -2428,6 +2429,8 @@ pgendEnable (PGBackend *be)
|
|||||||
be->be.percentage = be->snr.percentage;
|
be->be.percentage = be->snr.percentage;
|
||||||
be->be.events_pending = be->snr.events_pending;
|
be->be.events_pending = be->snr.events_pending;
|
||||||
be->be.process_events = be->snr.process_events;
|
be->be.process_events = be->snr.process_events;
|
||||||
|
|
||||||
|
LEAVE(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
@ -32,8 +32,11 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gnc-engine-util.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
|
|
||||||
|
static short module = MOD_BACKEND;
|
||||||
|
|
||||||
/* ================================================ */
|
/* ================================================ */
|
||||||
|
|
||||||
struct _escape {
|
struct _escape {
|
||||||
@ -129,9 +132,11 @@ sqlEscape_new (void)
|
|||||||
void
|
void
|
||||||
sqlEscape_destroy (sqlEscape *b)
|
sqlEscape_destroy (sqlEscape *b)
|
||||||
{
|
{
|
||||||
if (!b) return;
|
ENTER(" ");
|
||||||
|
if (!b) { LEAVE("b is (null)"); return; }
|
||||||
g_free (b->escape); b->escape = NULL;
|
g_free (b->escape); b->escape = NULL;
|
||||||
g_free (b);
|
g_free (b);
|
||||||
|
LEAVE(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================ END OF FILE ==================== */
|
/* ================ END OF FILE ==================== */
|
||||||
|
@ -83,11 +83,15 @@ sqlQuery_new(void)
|
|||||||
void
|
void
|
||||||
sql_Query_destroy(sqlQuery * sq)
|
sql_Query_destroy(sqlQuery * sq)
|
||||||
{
|
{
|
||||||
if (!sq)
|
ENTER(" ");
|
||||||
|
if (!sq) {
|
||||||
|
LEAVE("sq = (null)");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
g_free(sq->q_base);
|
g_free(sq->q_base);
|
||||||
sqlEscape_destroy(sq->escape);
|
sqlEscape_destroy(sq->escape);
|
||||||
g_free(sq);
|
g_free(sq);
|
||||||
|
LEAVE(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -99,7 +99,7 @@ int finishQuery(PGBackend *be);
|
|||||||
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR); \
|
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR); \
|
||||||
return retval; \
|
return retval; \
|
||||||
} \
|
} \
|
||||||
}
|
} \
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
/* The FINISH_QUERY macro makes sure that the previously sent
|
/* The FINISH_QUERY macro makes sure that the previously sent
|
||||||
@ -140,22 +140,22 @@ int finishQuery(PGBackend *be);
|
|||||||
*/
|
*/
|
||||||
#define GET_RESULTS(conn,result) \
|
#define GET_RESULTS(conn,result) \
|
||||||
{ \
|
{ \
|
||||||
|
gchar *msg = NULL; \
|
||||||
ExecStatusType status; \
|
ExecStatusType status; \
|
||||||
result = PQgetResult (conn); \
|
result = PQgetResult (conn); \
|
||||||
if (!result) break; \
|
if (!result) break; \
|
||||||
status = PQresultStatus(result); \
|
status = PQresultStatus(result); \
|
||||||
|
msg = PQresultErrorMessage(result); \
|
||||||
if ((PGRES_COMMAND_OK != status) && \
|
if ((PGRES_COMMAND_OK != status) && \
|
||||||
(PGRES_TUPLES_OK != status)) \
|
(PGRES_TUPLES_OK != status)) \
|
||||||
{ \
|
{ \
|
||||||
PERR("failed to get result to query:\n" \
|
PERR("failed to get result to query:\n\t%s", msg); \
|
||||||
"\t%s", PQerrorMessage((conn))); \
|
|
||||||
PQclear (result); \
|
PQclear (result); \
|
||||||
PQfinish (conn); \
|
xaccBackendSetMessage (&be->be, msg); \
|
||||||
be->connection = NULL; \
|
|
||||||
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR);\
|
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR);\
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
}
|
} \
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
/* The EXEC_QUERY macro executes a query and returns the results
|
/* The EXEC_QUERY macro executes a query and returns the results
|
||||||
@ -164,24 +164,28 @@ int finishQuery(PGBackend *be);
|
|||||||
*/
|
*/
|
||||||
#define EXEC_QUERY(conn,buff,result) \
|
#define EXEC_QUERY(conn,buff,result) \
|
||||||
{ \
|
{ \
|
||||||
|
gchar *msg = NULL; \
|
||||||
ExecStatusType status = 0; \
|
ExecStatusType status = 0; \
|
||||||
result = PQexec (conn, buff); \
|
result = PQexec (conn, buff); \
|
||||||
if (result) \
|
if (result) { \
|
||||||
status = PQresultStatus(result); \
|
status = PQresultStatus(result); \
|
||||||
|
msg = PQresultErrorMessage(result); \
|
||||||
|
} else { \
|
||||||
|
msg = PQerrorMessage(conn); \
|
||||||
|
} \
|
||||||
if (!result || \
|
if (!result || \
|
||||||
((PGRES_COMMAND_OK != status) && \
|
((PGRES_COMMAND_OK != status) && \
|
||||||
(PGRES_TUPLES_OK != status))) \
|
(PGRES_TUPLES_OK != status))) \
|
||||||
{ \
|
{ \
|
||||||
PERR("failed to get result to query:\n" \
|
PERR("failed to get result to query:\n" \
|
||||||
"\t%s", PQerrorMessage((conn))); \
|
"\t%s", msg); \
|
||||||
if (result) \
|
if (result) \
|
||||||
PQclear (result); \
|
PQclear (result); \
|
||||||
result = NULL; \
|
result = NULL; \
|
||||||
PQfinish (conn); \
|
xaccBackendSetMessage (&be->be, msg); \
|
||||||
be->connection = NULL; \
|
|
||||||
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR);\
|
xaccBackendSetError (&be->be, ERR_BACKEND_SERVER_ERR);\
|
||||||
} \
|
} \
|
||||||
}
|
} \
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
/* The IF_ONE_ROW macro counts the number of rows returned by
|
/* The IF_ONE_ROW macro counts the number of rows returned by
|
||||||
|
@ -1322,11 +1322,17 @@ gncQueryPrint (QueryNew * query)
|
|||||||
QueryNewSort_t s[3];
|
QueryNewSort_t s[3];
|
||||||
gint maxResults = 0, numSorts = 3;
|
gint maxResults = 0, numSorts = 3;
|
||||||
|
|
||||||
|
ENTER (" ");
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
LEAVE("query is (null)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
output = NULL;
|
output = NULL;
|
||||||
str = NULL;
|
str = NULL;
|
||||||
maxResults = gncQueryGetMaxResults (query);
|
maxResults = gncQueryGetMaxResults (query);
|
||||||
|
|
||||||
ENTER (" ");
|
|
||||||
output = gncQueryPrintSearchFor (query, output);
|
output = gncQueryPrintSearchFor (query, output);
|
||||||
output = gncQueryPrintTerms (query, output);
|
output = gncQueryPrintTerms (query, output);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user