[gdal-dev] about OGRSQL case sensitive

Even Rouault even.rouault at mines-paris.org
Thu Jun 13 15:00:58 PDT 2013


Le jeudi 13 juin 2013 09:46:16, 梁天辰 a écrit :
> Hi all,
> 
> According to page http://www.gdal.org/ogr/ogr_sql.html , I found that <, >,
> <= and >= operators are case sensitive. 

Hum, it appears that this was true before the rewriting of the OGR SQL engine 
for GDAL 1.8.0. The current implementation of <, >, <= and >= is also case 
insensitive as you've noticed... Not sure if we must change the doc or the 
implementation here...

If you use GDAL 1.10.0, and you've built is with SQLite support, you can use 
the following (convoluted) SQL :

"SELECT * FROM " + layername + " WHERE NOT codede != 'capital'"

and

poDSws->ExecuteSQL(sql,NULL,"SQLite");

so that the SQLite engine is used.

Well, why the above works, and not directly "SELECT * FROM " + layername + " 
WHERE codede = 'capital'" since '=' is case sensitive (by default) in SQLite. 
If you try this, the SQLite <--> OGR bridge will be smart and will forward the 
WHERE clause to the OGR SetAttributeFilter() method, that in turns will be 
evaluated by OGR SQL (for drivers that are not RDBMS). But by using "NOT foo 
!= 'bar'" this optimization isn't triggered and the expression is fully 
evaluated by the SQLite engine...

Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list