[gdal-dev] GeoPackage fails after touching it with Spatialite-gui

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Mon Feb 17 07:27:35 PST 2014


Even Rouault <even.rouault <at> mines-paris.org> writes:

> 
> Jukka,
> 
> I highly suspect that the ALTER TABLE must imply a rewriting of the file by
> spatialite/spatialite-gui, and when doing so, it doesn't preserve the
> "application id" (4 bytes in the header of sqlite file), that geopackage
> specification mentions to be set to a particular value. Consequently the
> geopackage driver later fails when checking the signature.

I have not yet found a way to reproduce crash in a reliable way but while
testing I found something else. Does the following mean that the GPKG file
is not totally valid SQLite file or just that GDAL gets puzzled because
there are separate implementations for SQLite/Spatialite and GPKG?


Step 1: create plain SQLite and GPKG databases

C:\data>ogr2ogr -f sqlite  test.sqlite temp.shp
C:\data>ogr2ogr -f gpkg  test.gpkg temp.shp

Step 2: try to rename a table
C:\data>ogrinfo test.sqlite -dialect sqlite -sql "alter table temp rename to
temp2"
INFO: Open of `test.sqlite'
      using driver `SQLite' successful.

C:\data>ogrinfo test.gpkg -dialect sqlite -sql "alter table temp rename to
temp2"
INFO: Open of `test.gpkg'
      using driver `GPKG' successful.
ERROR 1: In ExecuteSQL(): sqlite3_prepare(alter table temp rename to temp2):
  no such table: temp 

I noticed that OGR dialect does not support renaming tables, it suggests to
rename a column instead.

-Jukka-



More information about the gdal-dev mailing list