Index: connection.c =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/connection.c,v retrieving revision 1.107 diff -u -r1.107 connection.c --- connection.c 30 Aug 2005 09:19:50 -0000 1.107 +++ connection.c 30 Aug 2005 09:39:22 -0000 @@ -3171,6 +3171,22 @@ return NULL; } qres->status = PQresultStatus(pgres); + /* I assume PGRES_FATAL_ERROR is returned when the server is dead. + * Siva Kumar.K 30-8-2005 */ + if(qres->status == PGRES_FATAL_ERROR) + { + snprintf(errbuffer, ERROR_MSG_LENGTH, "%s", PQerrorMessage(self->pgconn)); + /* Remove the training CR that libpq adds to the message */ + pos = strlen(errbuffer); + if (pos) + errbuffer[pos - 1] = '\0'; + + mylog("The server could be dead: %s\n", errbuffer); + CC_set_error(self, CONNECTION_COULD_NOT_SEND, errbuffer); + CC_on_abort(self,CONN_DEAD); + PQclear(pgres); + return qres; + } if (strnicmp(cmdbuffer, "BEGIN", 5) == 0) { Index: qresult.h =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/qresult.h,v retrieving revision 1.30 diff -u -r1.30 qresult.h --- qresult.h 13 Jul 2005 14:23:35 -0000 1.30 +++ qresult.h 30 Aug 2005 09:33:26 -0000 @@ -130,6 +130,7 @@ #define QR_command_successful(self) ( !(self->status == PGRES_BAD_RESPONSE || self->status == PGRES_NONFATAL_ERROR || self->status == PGRES_FATAL_ERROR)) #define QR_command_maybe_successful(self) ( !(self->status == PGRES_BAD_RESPONSE || self->status == PGRES_FATAL_ERROR)) #define QR_command_nonfatal(self) ( self->status == PGRES_NONFATAL_ERROR) +#define QR_command_fatal(self) ( self->status == PGRES_FATAL_ERROR) #define QR_end_tuples(self) ( self->status == PGRES_END_TUPLES) #define QR_set_status(self, condition) ( self->status = condition ) #define QR_set_aborted(self, aborted_) ( self->aborted = aborted_) Index: statement.c =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/statement.c,v retrieving revision 1.95 diff -u -r1.95 statement.c --- statement.c 4 Aug 2005 13:39:28 -0000 1.95 +++ statement.c 30 Aug 2005 09:35:48 -0000 @@ -1092,7 +1092,7 @@ CSTR func = "SC_execute"; ConnectionClass *conn; IPDFields *ipdopts; - char was_ok, was_nonfatal; + char was_ok, was_nonfatal,was_fatal; QResultClass *res = NULL; Int2 oldstatus, numcols; @@ -1220,10 +1220,13 @@ { was_ok = QR_command_successful(res); was_nonfatal = QR_command_nonfatal(res); + was_fatal = QR_command_fatal(res); if (was_ok) SC_set_errornumber(self, STMT_OK); - else + else if (was_fatal) + SC_set_errornumber(self,STMT_BAD_ERROR); + else SC_set_errornumber(self, was_nonfatal ? STMT_INFO_ONLY : STMT_ERROR_TAKEN_FROM_BACKEND); /* set cursor before the first tuple in the list */