[mapserver-commits] r11921 - branches/branch-5-2/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Jul 12 16:46:16 EDT 2011
Author: assefa
Date: 2011-07-12 13:46:16 -0700 (Tue, 12 Jul 2011)
New Revision: 11921
Modified:
branches/branch-5-2/mapserver/mappostgis.c
Log:
Add missing escape function (#3903)
Modified: branches/branch-5-2/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-2/mapserver/mappostgis.c 2011-07-12 20:44:45 UTC (rev 11920)
+++ branches/branch-5-2/mapserver/mappostgis.c 2011-07-12 20:46:16 UTC (rev 11921)
@@ -2421,6 +2421,41 @@
}
+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
+}
+
+
int
msPOSTGISLayerInitializeVirtualTable(layerObj *layer)
{
@@ -2449,7 +2484,8 @@
/* 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