[mapserver-commits] r11916 - branches/branch-5-4/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Jul 12 16:39:02 EDT 2011
Author: assefa
Date: 2011-07-12 13:39:02 -0700 (Tue, 12 Jul 2011)
New Revision: 11916
Modified:
branches/branch-5-4/mapserver/mappostgis.c
Log:
Add missing escape function (#3903)
Modified: branches/branch-5-4/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-4/mapserver/mappostgis.c 2011-07-12 20:28:02 UTC (rev 11915)
+++ branches/branch-5-4/mapserver/mappostgis.c 2011-07-12 20:39:02 UTC (rev 11916)
@@ -2463,6 +2463,40 @@
return MS_FALSE;
}
+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->pgconn, 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) {
assert(layer != NULL);
assert(layer->vtable != NULL);
@@ -2489,6 +2523,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