1

I have my mapfile. I am able to connect to my PostGIS database when my table is under the public schema.

Here is my database structure.

Database

Ingham
\__Schemas (3)
    \__2016
        \__Parcels
        \__Parcel Dimensions
    \__2017
        \__Parcels
        \__Parcel Dimensions
    \__public
        \__Parcels

The Parcels table under the public schema is a copy from 2016. I can connect to it from my mapfile this way.

CONNECTIONTYPE POSTGIS
CONNECTION 'host=XXX.XXX.XXX.XXX dbname=Ingham user=ingham_mapserver'
DATA 'wkb_geometry from Parcels'

This works great. When I try to specify a schema, like I would in a postgresql query,

CONNECTIONTYPE POSTGIS
CONNECTION 'host=XXX.XXX.XXX.XXX dbname=Ingham user=ingham_mapserver'
DATA 'wkb_geometry from "2017"."Parcels"'

Has anyone been able to specify a database schema in the mapfile for MapServer?

  • 1
    Which version of Mapserver are you using? – whyzar Nov 1 '18 at 19:19
  • Current: v7.2.1 – Christian4423 Nov 1 '18 at 19:21
1

MapServer tries to parse the SQL fragment.

When doing anything funny, better move it into a subquery, which will be given to the database as is:

DATA 'wkb_geometry from (select wkb_geometry from "2017"."Parcels") as subquery'
  • This worked for me :) It's funny though, I swear that I tried this a million times yesterday as it says in the documentation https://mapserver.org/input/vector/postgis.html that the subqueries get ran on the database server. Anyways, thank you! – Christian4423 Nov 2 '18 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.