[mapserver-commits] r7575 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon May 12 11:19:48 EDT 2008
Author: pramsey
Date: 2008-05-12 11:19:48 -0400 (Mon, 12 May 2008)
New Revision: 7575
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mappostgis.c
Log:
Fix PostGIS transaction behavior in fcgi situations (#2613)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-05-12 13:59:02 UTC (rev 7574)
+++ trunk/mapserver/HISTORY.TXT 2008-05-12 15:19:48 UTC (rev 7575)
@@ -25,7 +25,7 @@
- Remove C++-style comments and most other warnings thrown by -pedantic (#2598)
-- Fix PostGIS transaction behavior in fcgi situations (#2497)
+- Fix PostGIS transaction behavior in fcgi situations (#2497, #2613)
- Improve performance for large shape files (#2282)
Modified: trunk/mapserver/mappostgis.c
===================================================================
--- trunk/mapserver/mappostgis.c 2008-05-12 13:59:02 UTC (rev 7574)
+++ trunk/mapserver/mappostgis.c 2008-05-12 15:19:48 UTC (rev 7575)
@@ -535,24 +535,41 @@
}
/* Allocate buffer to fit the largest query string */
- query_string_0_6 = (char *) malloc(113 + 42 + strlen(columns_wanted) + strlen(data_source) + (layer->filter.string ? strlen(layer->filter.string) : 0) + 2 * strlen(geom_column) + strlen(box3d) + strlen(f_table_name) + strlen(user_srid) + 1);
+ query_string_0_6 = (char *) malloc(113 + 42 + 7 + 12 + strlen(columns_wanted) + strlen(data_source) + (layer->filter.string ? strlen(layer->filter.string) : 0) + 2 * strlen(geom_column) + strlen(box3d) + strlen(f_table_name) + strlen(user_srid) + 1);
assert( layerinfo->cursor_name[0] == '\0' );
strcpy( layerinfo->cursor_name, "mycursor" );
- if(!layer->filter.string) {
+ if( layer->maxfeatures > 0 ) {
+ if(!layer->filter.string) {
if(!strlen(user_srid)) {
- sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, find_srid('','%s','%s') )", columns_wanted, data_source, geom_column, box3d, f_table_name, geom_column);
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, find_srid('','%s','%s') ) limit %d", columns_wanted, data_source, geom_column, box3d, f_table_name, geom_column, layer->maxfeatures);
} else {
- /* use the user specified version */
- sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, %s )", columns_wanted, data_source, geom_column, box3d, user_srid);
+ /* use the user specified version */
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, %s ) limit %d", columns_wanted, data_source, geom_column, box3d, user_srid, layer->maxfeatures);
}
+ } else {
+ if(!strlen(user_srid)) {
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,find_srid('','%s','%s') )) limit %d", columns_wanted, data_source, layer->filter.string, geom_column, box3d, f_table_name, geom_column, layer->maxfeatures);
+ } else {
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,%s) ) limit %d", columns_wanted, data_source, layer->filter.string, geom_column, box3d, user_srid, layer->maxfeatures);
+ }
+ }
} else {
+ if(!layer->filter.string) {
if(!strlen(user_srid)) {
- sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,find_srid('','%s','%s') ))", columns_wanted, data_source, layer->filter.string, geom_column, box3d, f_table_name, geom_column);
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, find_srid('','%s','%s') )", columns_wanted, data_source, geom_column, box3d, f_table_name, geom_column);
} else {
- sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,%s) )", columns_wanted, data_source, layer->filter.string, geom_column, box3d, user_srid);
+ /* use the user specified version */
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE %s && setSRID(%s, %s )", columns_wanted, data_source, geom_column, box3d, user_srid);
}
+ } else {
+ if(!strlen(user_srid)) {
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,find_srid('','%s','%s') ))", columns_wanted, data_source, layer->filter.string, geom_column, box3d, f_table_name, geom_column);
+ } else {
+ sprintf(query_string_0_6, "DECLARE mycursor BINARY CURSOR FOR SELECT %s from %s WHERE (%s) and (%s && setSRID( %s,%s) )", columns_wanted, data_source, layer->filter.string, geom_column, box3d, user_srid);
+ }
+ }
}
free(data_source);
@@ -700,7 +717,12 @@
query_result = PQexec(layerinfo->conn, cmd_buffer );
if(query_result) {
PQclear(query_result);
- }
+ } else {
+ if (msPOSTGISSanitizeConnection(layerinfo->conn) != MS_SUCCESS)
+ {
+ return MS_FAILURE;
+ }
+ }
layerinfo->cursor_name[0] = '\0';
}
@@ -1434,7 +1456,9 @@
if(query_result) {
PQclear(query_result);
- }
+ } else {
+ msPOSTGISSanitizeConnection(layerinfo->conn);
+ }
free(sql);
free(geom_column_name);
@@ -1612,6 +1636,7 @@
msDebug("msPOSTGISLayerRetrievePGVersion: No results returned.\n");
}
free(tmp2);
+ msPOSTGISSanitizeConnection(layerinfo->conn);
return(MS_FAILURE);
}
@@ -1759,6 +1784,7 @@
msSetError(MS_QUERYERR, tmp2, "msPOSTGISLayerRetrievePK()");
free(tmp2);
free(sql);
+ msPOSTGISSanitizeConnection(layerinfo->conn);
return(MS_FAILURE);
}
More information about the mapserver-commits
mailing list