[gdal-dev] SQLite-SQL problem with some layer names

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Wed Apr 12 00:40:04 PDT 2017


I have problems in using the SQLite dialect if layer names contains numbers or underscores. I am on Windows. 

ogrinfo -dialect sqlite 3d.shp -sql "select * from 3d"
INFO: Open of `3d.shp'
      using driver `ESRI Shapefile' successful.
ERROR 1: In ExecuteSQL(): sqlite3_prepare(select * from 3d):
  unrecognized token: "3d"

Same happens with a proper SQL with double quotes around the identifier
ogrinfo -dialect sqlite 3d.shp -sql "select * from "3d""

However, with single quotes it works
ogrinfo -dialect sqlite 3d.shp -sql "select * from '3d'"
Even this one, yields a correct result
ogrinfo -dialect sqlite 3d.shp -sql "select 'fixed_string'  from '3d'"

Layers without numbers or underscores in names behave right 
ogrinfo -dialect sqlite test.shp -sql "select * from "test"'"

Is there something that could be fixed in the code, or should I add a line to two into the documentation http://www.gdal.org/ogr_sql_sqlite.html?

-Jukka Rahkonen-

More information about the gdal-dev mailing list