[svn:DBD-Pg] r12682 - DBD-Pg/trunk

[email protected]
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Author: turnstep
Date: Thu Apr  9 08:52:56 2009
New Revision: 12682

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/dbdimp.c

Log:
Return better SQLSTATE code when the connection has failed - [email protected]
CPAN bug #44744


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes	(original)
+++ DBD-Pg/trunk/Changes	Thu Apr  9 08:52:56 2009
@@ -2,9 +2,12 @@
 
 2.12.1
 
-  - Fix minor Perl::Critic nags (CPAN bug #44704) (Debian #bug 521969) [GSM]
   - Ensure we always set sqlstate inside of pg_st_prepare_statement
     (CPAN bug #44732) [[email protected]]
+  - When libpq has a connection error, return SQLSTATE 08000 ( "CONNECTION EXCEPTION" )
+    instead of the more generic 02000 ( "DATA EXCEPTION" ) (CPAN bug #44744)
+    [[email protected]]
+  - Fix minor Perl::Critic nags (CPAN bug #44704) (Debian #bug 521969) [GSM]
 
 2.12.0 Released March 28, 2009
 

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c	(original)
+++ DBD-Pg/trunk/dbdimp.c	Thu Apr  9 08:52:56 2009
@@ -377,6 +377,10 @@
 			strncpy(imp_dbh->sqlstate, "01000", 6); /* WARNING */
 			break;
 		case PGRES_FATAL_ERROR:
+			if (!result) { /* libpq returned null - some sort of connection problem */
+				strncpy(imp_dbh->sqlstate, "08000", 6); /* CONNECTION EXCEPTION */
+				break;
+			}
 		default:
 			strncpy(imp_dbh->sqlstate, "22000", 6); /* DATA EXCEPTION */
 			break;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.