[mapserver-commits] r11068 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Mar 4 07:29:49 EST 2011
Author: tamas
Date: 2011-03-04 04:29:49 -0800 (Fri, 04 Mar 2011)
New Revision: 11068
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapmssql2008.c
Log:
Implement single-pass query handling in mssql2008 driver as per RFC 65
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-03-04 11:27:19 UTC (rev 11067)
+++ trunk/mapserver/HISTORY.TXT 2011-03-04 12:29:49 UTC (rev 11068)
@@ -14,6 +14,8 @@
Current Version (SVN trunk):
----------------------------
+- Implement single-pass query handling in mssql2008 driver as per RFC 65.
+
- Fixed Sql Server 2008 key column name truncation (#3654)
- Added label position binding (#3612) and label shadow size binding (#2924)
Modified: trunk/mapserver/mapmssql2008.c
===================================================================
--- trunk/mapserver/mapmssql2008.c 2011-03-04 11:27:19 UTC (rev 11067)
+++ trunk/mapserver/mapmssql2008.c 2011-03-04 12:29:49 UTC (rev 11068)
@@ -707,6 +707,7 @@
return set_up_result; /* relay error */
}
+ msFree(layerinfo->sql);
layerinfo->sql = query_str;
layerinfo->row_num = 0;
@@ -1410,6 +1411,7 @@
record_oid = strtol(oidBuffer, NULL, 10);
shape->index = record_oid;
+ shape->resultindex = (*record);
find_bounds(shape);
(*record)++; /* move to next shape */
@@ -1465,6 +1467,7 @@
int t;
char buffer[32000] = "";
long shapeindex = record->shapeindex;
+ long resultindex = record->resultindex;
if(layer->debug) {
msDebug("msMSSQL2008LayerGetShape called for shapeindex = %i\n", shapeindex);
@@ -1479,6 +1482,32 @@
return MS_FAILURE;
}
+ if (resultindex >= 0 && layerinfo->sql)
+ {
+ /* trying to provide the result from the current resultset (single-pass query) */
+ if( resultindex < layerinfo->row_num)
+ {
+ /* re-issue the query */
+ if (!executeSQL(layerinfo->conn, layerinfo->sql))
+ {
+ msSetError(MS_QUERYERR, "Error executing MSSQL2008 SQL statement: %s\n-%s\n", "msMSSQL2008LayerGetShape()", layerinfo->sql, layerinfo->conn->errorMessage);
+
+ return MS_FAILURE;
+ }
+ layerinfo->row_num = 0;
+ }
+ while( layerinfo->row_num < resultindex )
+ {
+ /* move forward until we reach the desired index */
+ if (msMSSQL2008LayerGetShapeRandom(layer, shape, &(layerinfo->row_num)) != MS_SUCCESS)
+ return MS_FAILURE;
+ }
+
+ return msMSSQL2008LayerGetShapeRandom(layer, shape, &(layerinfo->row_num));
+ }
+
+ /* non single-pass case, fetch the record from the database */
+
if(layer->numitems == 0)
{
snprintf(buffer, sizeof(buffer), "%s.STAsBinary(), convert(varchar(20), %s)", layerinfo->geom_column, layerinfo->urid_name);
@@ -1516,8 +1545,8 @@
return MS_FAILURE;
}
- msFree(layerinfo->sql);
- layerinfo->sql = query_str;
+ /* we don't preserve the query string in this case (cannot be re-used) */
+ msFree(query_str);
layerinfo->row_num = 0;
return msMSSQL2008LayerGetShapeRandom(layer, shape, &(layerinfo->row_num));
More information about the mapserver-commits
mailing list