[gdal-dev] ogrinfo on JOINed layer empty

Frank Warmerdam warmerdam at pobox.com
Mon May 19 17:14:27 EDT 2008


William Kyngesburye wrote:
> While testing some connections for a Mapserver map file, I'm finding 
> that ogrinfo is not showing any info (layers, fields, features) on 
> JOINed layers.
> 
> A connection that works in Mapserver:
> 
> CONNECTION "/"
> DATA "SELECT * FROM some_shapefile LEFT JOIN 
> 'MYSQL:some_database,host=localhost,user=some_user,tables=some_table'.some_table 
> ON some_shapefile.id = some_table.id"
> 
> but in ogrinfo (on the Mapserver computer, so it's still local):
> 
> ogrinfo -al -so . "SELECT * FROM some_shapefile LEFT JOIN 
> 'MYSQL:some_database,host=localhost,user=some_user,tables=some_table'.some_table 
> ON some_shapefile.id = some_table.id"
> INFO: Open of `.'
>       using driver `ESRI Shapefile' successful.
> 
> It does not show any of the fields from the shapefile or the JOINed 
> MySQL table.  I get exactly the same output on a bad JOIN (or other 
> non-existent shapefile layer).
> 
> CPL_DEBUG=ON doesn't show any helpful debug messages, just (there are 5 
> shapefiles in the folder):
> 
> OGR: GetLayerCount() = 5
> 
> 
> Any hints on how to get ogrinfo to show JOINed layer info?  I think I've 
> seen this work in the past.
>
William,

There are two issues here.

1) ogrinfo does not report an error when you pass it a layer name that doesn't
exist on the commandline.

2) You aren't passing the SQL statement you want evaluated using the sql
commandline switch.  Try:

ogrinfo -al -so . -sql "SELECT * ...'

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list