Patch: SQLSTATE not set properly on failed connection.

[email protected] (Chris Travers)
Newsgroups perl.dbd.pg
Message-ID <[email protected]>
Hi all;

Attached is a simple patch that sets the state on a failed connection to a
08-class status.

Thanks to RhodiumToad on #postgresql for helping spot the problem.

Best Wishes,
Chris Travers
dbd-sqlstate.diff (text/x-patch, 514 B)
--- dbdimp.c.old	2009-12-16 17:00:13.861919463 -0800
+++ dbdimp.c	2009-12-16 17:00:24.548918948 -0800
@@ -185,8 +185,8 @@
 	connstatus = PQstatus(imp_dbh->conn);
 	if (CONNECTION_OK != connstatus) {
 		TRACE_PQERRORMESSAGE;
-		pg_error(aTHX_ dbh, connstatus, PQerrorMessage(imp_dbh->conn));
 		strncpy(imp_dbh->sqlstate, "08006", 6); /* "CONNECTION FAILURE" */
+		pg_error(aTHX_ dbh, connstatus, PQerrorMessage(imp_dbh->conn));
 		TRACE_PQFINISH;
 		PQfinish(imp_dbh->conn);
 		sv_free((SV *)imp_dbh->savepoints);
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.