diff options
author | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 10:41:38 +0000 |
---|---|---|
committer | om <om@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-22 10:41:38 +0000 |
commit | 6550132711b5e111d2065232ee6ddf463cb9f808 (patch) | |
tree | 9fd2e728edbaba60b00a30e063ffb236bf2505a9 | |
parent | 89bf10915cb8ec2aeac8446a8a458a5061183b11 (diff) |
Set the SQLresult's error field properly when the query fails
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4497 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 19fe1a1c4..b62c804ce 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -787,10 +787,21 @@ bool SQLConn::DoConnectedPoll() if(to) { /* ..and the result */ - log(DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result)); - PgSQLresult reply(us, to, query.id, result); + log(DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result)); + + switch(PQresultStatus(result)) + { + case PGRES_EMPTY_QUERY: + case PGRES_BAD_RESPONSE: + case PGRES_FATAL_ERROR: + reply.error.Id(QREPLY_FAIL); + reply.error.Str(PQresultErrorMessage(result)); + default:; + /* No action, other values are not errors */ + } + reply.Send(); /* PgSQLresult's destructor will free the PGresult */ |