[gdal-dev] OGR SQL problems

Even Rouault even.rouault at mines-paris.org
Fri Feb 25 17:11:49 EST 2011


Le vendredi 25 février 2011 22:09:01, Gauthier,Jean-Philippe [CMC] a écrit :
> Hi all,
> 
> I think there might be a bug with the OGR_DS_ExecuteSQL call in gdal 1.8,
> this worked fine with 1.7 and I see you`ve rebuilt the SQL part.
> 
> I've tried a select on a CANVEC layer which looks something like this:
> 
> 	ogrinfo CanVec/031/h/031h05/031h05_6_0_BS_2010009_2.shp -sql  "SELECT *
> FROM 031h05_6_0_BS_2010009_2"
> 
> And I get
> 
> 	ERROR 1: SQL Expression Parsing Error: syntax error
> 
> I've tried many other layers and it woks fine for all of them but not for
> any CANVEC layer.
> 
> I'm beginning to think the underscores in the layer name might cause a
> problem cause it`s the only differrence I can see

I think the issue is rather the 0 as first character of the layer name. In GDAL 
1.8.0 the SQL engine was rewritten and it seems to be stricter than the 
previous versions on what it recognizes as valid idents. You should be able to 
solve this by quoting it.

ogrinfo CanVec/031/h/031h05/031h05_6_0_BS_2010009_2.shp -sql  "SELECT * FROM 
'031h05_6_0_BS_2010009_2'"

(I've tested that Postgresql, Mysql and Sqlite also need quoting for such 
layer names)

> 
> Has anybody seen this behavior has well ?
> 
> Note the it does the same thing with the C API where I first stumbled on
> the problem
> 
>  Thanks.
> 
> ================================================================
> Jean-Philippe Gauthier Bilodeau		Direction des opérations
> Spécialiste principal,				Centre Météorologique Canadien
> programmation scientifique et infographie	2121 Route Transcanadienne
> Tel : (514) 421-4642				Dorval,Québec
> Fax: (514) 421-4679				H9P 1J3
> Email: Jean-Philippe.Gauthier at ec.gc.ca


More information about the gdal-dev mailing list