Skip to content

Commit

Permalink
Add missing escape function (#3903)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/mapserver/branches/branch-4-10@11915 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information
Assefa Yewondwossen committed Jul 12, 2011
1 parent d42bb31 commit efd3989
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion mappostgis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,40 @@ msPOSTGISLayerGetShapeVT(layerObj *layer, shapeObj *shape, int tile, long record
}


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);
Expand Down Expand Up @@ -2496,6 +2529,7 @@ msPOSTGISLayerInitializeVirtualTable(layerObj *layer)
/* layer->vtable->LayerCreateItems, use default */
/* layer->vtable->LayerGetNumFeatures, use default */

layer->vtable->LayerEscapeSQLParam = msPostGISEscapeSQLParam;

return MS_SUCCESS;
}
Expand Down

0 comments on commit efd3989

Please sign in to comment.