From 6550132711b5e111d2065232ee6ddf463cb9f808 Mon Sep 17 00:00:00 2001 From: om Date: Sat, 22 Jul 2006 10:41:38 +0000 Subject: 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 --- src/modules/extra/m_pgsql.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/modules') 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 */ -- cgit v1.2.3