]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Set the SQLresult's error field properly when the query fails
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 22 Jul 2006 10:41:38 +0000 (10:41 +0000)
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 22 Jul 2006 10:41:38 +0000 (10:41 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4497 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/extra/m_pgsql.cpp

index 19fe1a1c4629e2bf5bb29b952124711774a0b504..b62c804ce8c0291265844dcd0c3b718d2ad8d595 100644 (file)
@@ -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 */