aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2010-03-08 13:07:00 +0000
committerMichael Meskes <meskes@postgresql.org>2010-03-08 13:07:00 +0000
commit2bf64bc275a9c173dbecae60e7ceaf3327f96db0 (patch)
treee1d1e3e2c1f081704300eabbdba70a215cb77aa5
parentb98e53213773123c1dc2dac87a825d5461074d89 (diff)
downloadpostgresql-2bf64bc275a9c173dbecae60e7ceaf3327f96db0.tar.gz
postgresql-2bf64bc275a9c173dbecae60e7ceaf3327f96db0.zip
Backport fix from HEAD that makes ecpglib give the right SQLSTATE if the connection disappears.
-rw-r--r--src/interfaces/ecpg/ecpglib/error.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index 8affc5ca67e..6313fa0019c 100644
--- a/src/interfaces/ecpg/ecpglib/error.c
+++ b/src/interfaces/ecpg/ecpglib/error.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.23 2009/06/11 14:49:13 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.23.2.1 2010/03/08 13:07:00 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -306,6 +306,17 @@ ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat)
message = PQerrorMessage(conn);
}
+ if (strcmp(sqlstate, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR) == 0)
+ {
+ /* we might get here if the connection breaks down, so let's
+ * check for this instead of giving just the generic internal error */
+ if (PQstatus(conn) == CONNECTION_BAD)
+ {
+ sqlstate = "57P02";
+ message = ecpg_gettext("the connection to the server was lost");
+ }
+ }
+
/* copy error message */
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "%s on line %d", message, line);
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);