[mapserver-commits] r9311 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Sep 15 18:12:30 EDT 2009


Author: pramsey
Date: 2009-09-15 18:12:28 -0400 (Tue, 15 Sep 2009)
New Revision: 9311

Modified:
   trunk/mapserver/mappostgis.c
Log:
Fix to allow single-pass query implementation to work in PostGIS (#3069)


Modified: trunk/mapserver/mappostgis.c
===================================================================
--- trunk/mapserver/mappostgis.c	2009-09-15 17:26:56 UTC (rev 9310)
+++ trunk/mapserver/mappostgis.c	2009-09-15 22:12:28 UTC (rev 9311)
@@ -1808,6 +1808,7 @@
     PGresult *pgresult = NULL;
     msPostGISLayerInfo *layerinfo = NULL;
 	int result = MS_SUCCESS;
+	int status;
 
     assert(layer != NULL);
     assert(layer->layerinfo != NULL);
@@ -1826,10 +1827,11 @@
                     "msPostGISLayerResultsGetShape()");
         return MS_FAILURE;
     }
+    status = PQresultStatus(pgresult);
     if ( layer->debug > 1 ) {
-        msDebug("msPostGISLayerResultsGetShape query status: %s (%d)\n", PQresStatus(PQresultStatus(pgresult)), PQresultStatus(pgresult));
+        msDebug("msPostGISLayerResultsGetShape query status: %s (%d)\n", PQresStatus(status), status);
     }    
-    if( PQresultStatus(pgresult) != PGRES_COMMAND_OK ) {
+    if( ! ( status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) ) {
         msSetError( MS_MISCERR,
                     "PostgreSQL result set is not ready.",
                     "msPostGISLayerResultsGetShape()");
@@ -1838,8 +1840,9 @@
 
     /* Check the validity of the requested record number. */
     if( record >= PQntuples(pgresult) ) {
+        msDebug("msPostGISLayerResultsGetShape got record request (%d) but only has %d tuples", record, PQntuples(pgresult));
         msSetError( MS_MISCERR,
-                    "PostgreSQL result set is not ready.",
+                    "Got request larger than result set.",
                     "msPostGISLayerResultsGetShape()");
         return MS_FAILURE;
     }



More information about the mapserver-commits mailing list