[mapserver-commits] r11915 - branches/branch-4-10/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Jul 12 16:28:02 EDT 2011
Author: assefa
Date: 2011-07-12 13:28:02 -0700 (Tue, 12 Jul 2011)
New Revision: 11915
Modified:
branches/branch-4-10/mapserver/mappostgis.c
Log:
Add missing escape function (#3903)
Modified: branches/branch-4-10/mapserver/mappostgis.c
===================================================================
--- branches/branch-4-10/mapserver/mappostgis.c 2011-07-12 20:05:04 UTC (rev 11914)
+++ branches/branch-4-10/mapserver/mappostgis.c 2011-07-12 20:28:02 UTC (rev 11915)
@@ -2468,7 +2468,40 @@
}
-int
+char *msPostGISEscapeSQLParam(layerObj *layer, const char *pszString)
+{
+#ifdef USE_POSTGIS
+ msPOSTGISLayerInfo *layerinfo = NULL;
+ int nError;
+ size_t nSrcLen;
+ char* pszEscapedStr =NULL;
+
+ if (layer && pszString && strlen(pszString) > 0)
+ {
+ if(!msPOSTGISLayerIsOpen(layer))
+ msPOSTGISLayerOpen(layer);
+
+ assert(layer->layerinfo != NULL);
+
+ layerinfo = (msPOSTGISLayerInfo *) layer->layerinfo;
+ nSrcLen = strlen(pszString);
+ pszEscapedStr = (char*) malloc( 2 * nSrcLen + 1);
+ PQescapeStringConn (layerinfo->conn, pszEscapedStr, pszString, nSrcLen, &nError);
+ if (nError != 0)
+ {
+ free(pszEscapedStr);
+ pszEscapedStr = NULL;
+ }
+ }
+ return pszEscapedStr;
+#else
+ msSetError( MS_MISCERR,
+ "PostGIS support is not available.",
+ "msPostGISEscapeSQLParam()");
+ return NULL;
+#endif
+}
+
msPOSTGISLayerInitializeVirtualTable(layerObj *layer)
{
assert(layer != NULL);
@@ -2496,6 +2529,7 @@
/* layer->vtable->LayerCreateItems, use default */
/* layer->vtable->LayerGetNumFeatures, use default */
+ layer->vtable->LayerEscapeSQLParam = msPostGISEscapeSQLParam;
return MS_SUCCESS;
}
More information about the mapserver-commits
mailing list