postgres.git / summary / log / commit / refs
commit e51710d1e2d1ec8def47aac6b39997355c1ae8bb
Author: Michael Meskes <meskes@postgresql.org>
Date: Mon Mar 08 13:15:51 2010 +0000
First released in: 8.3.10, 8.4.3
Backport fix from HEAD that makes ecpglib give the right SQLSTATE if the connection disappears.
src/interfaces/ecpg/ecpglib/error.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index cce370aca65..fba7bc1c729 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.19 2007/11/15 21:14:45 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.19.2.1 2010/03/08 13:15:51 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@@ -172,6 +172,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 = "the connection to the server was lost";
+ }
+ }
+
/* copy error message */
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
"'%s' in line %d.", message, line);
[parent: 266c5e4d4fff]