[mapserver-commits] r7258 - branches/branch-5-0/mapserver

svn at osgeo.org svn at osgeo.org
Tue Jan 15 01:12:11 EST 2008


Author: sdlime
Date: 2008-01-15 01:12:11 -0500 (Tue, 15 Jan 2008)
New Revision: 7258

Modified:
   branches/branch-5-0/mapserver/mappostgis.c
Log:
Added a bit of error checking when opening a PostGIS connection. (bug #2430)

Modified: branches/branch-5-0/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-0/mapserver/mappostgis.c	2008-01-12 05:13:13 UTC (rev 7257)
+++ branches/branch-5-0/mapserver/mappostgis.c	2008-01-15 06:12:11 UTC (rev 7258)
@@ -212,6 +212,11 @@
             msDebug("MSPOSTGISLayerOpen -- shared connection not available.\n");
         }
 
+        if (!layer->connection) {
+          msSetError(MS_MISCERR, "Missing CONNECTION keyword.", "msPOSTGISLayerOpen()");
+          return MS_FAILURE;
+        }
+
         /* Decrypt any encrypted token in connection and attempt to connect */
         conn_decrypted = msDecryptStringTokens(layer->map, layer->connection);
         if (conn_decrypted == NULL) {
@@ -237,7 +242,7 @@
               }
             }
             
-            msSetError(MS_QUERYERR, "couldnt make connection to DB with connect string '%s'.\n\nError reported was '%s'.\n\n\nThis error occured when trying to make a connection to the specified postgresql server.  \n\nMost commonly this is caused by \n(1) incorrect connection string \n(2) you didnt specify a 'user=...' in your connection string \n(3) the postmaster (postgresql server) isnt running \n(4) you are not allowing TCP/IP connection to the postmaster \n(5) your postmaster is not running on the correct port - if its not on 5432 you must specify a 'port=...' \n (6) the security on your system does not allow the webserver (usually user 'nobody') to make socket connections to the postmaster \n(7) you forgot to specify a 'host=...' if the postmaster is on a different machine\n(8) you made a typo \n  ", "msPOSTGISLayerOpen()", maskeddata,PQerrorMessage(layerinfo->conn));
+            msSetError(MS_QUERYERR, "Couldn't make connection to DB with connect string '%s'.\n\nError reported was '%s'.\n\n\nThis error occured when trying to make a connection to the specified postgresql server.  \n\nMost commonly this is caused by \n(1) incorrect connection string \n(2) you didnt specify a 'user=...' in your connection string \n(3) the postmaster (postgresql server) isnt running \n(4) you are not allowing TCP/IP connection to the postmaster \n(5) your postmaster is not running on the correct port - if its not on 5432 you must specify a 'port=...' \n (6) the security on your system does not allow the webserver (usually user 'nobody') to make socket connections to the postmaster \n(7) you forgot to specify a 'host=...' if the postmaster is on a different machine\n(8) you made a typo \n  ", "msPOSTGISLayerOpen()", maskeddata, PQerrorMessage(layerinfo->conn));
 
             free(maskeddata);
             free(layerinfo);



More information about the mapserver-commits mailing list