Ticket #2879 (closed defect: fixed)

Opened 1 year ago

Last modified 11 months ago

sqlite metadata=no option causes error

Reported by: crschmidt Assigned to: chaitanya
Priority: normal Milestone: 1.7.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: sqlite
Cc: warmerdam

Description

The SQLite driver CreateDataset? call opens the sqlite file with sqlite3_open. Then, it writes some metadata, if METADATA is true (hich is the default). In the non-default case, it drops through, the ncalls sqlite3_close, and passes the filename off to Open().

Open() checks for a magic header ("sqlite format 3") at the beginning of the file. if it is not there, then the file is not opened, and NULL is returned.

However, if metadata is no, no data is written the sqlite file; it is left at 0 bytes, and no magic header is written. This is okay, because sqlite can still write to the file (I believe), but the end result is that something like ogr2ogr complains.

I think the right solution to this is not to depend on Open(), at least in the case where metadata is not true; instead, simply return the dataset from CreateDataset? directly. However, I'm not sure, and since I just spent 20 minutes in gdb, I'll let somene slightly more sane take up the question.

The end result of this behavior is that ogr2ogr fails a la:

disciplina:~ crschmidt$ ogr2ogr -f SQLite -dsco METADATA=FALSE bybane.sql bybane2spor.shp SQLite driver failed to create bybane.sql

Change History

03/09/09 11:27:14 changed by warmerdam

  • cc set to warmerdam.
  • keywords set to sqlite.
  • owner changed from warmerdam to chaitanya.

After discussion, it seems like I might add a flag on the sqlite datasource open method to force trying to open without checking if the file is an sqlite file and that this flag would only be passed as true from the datsource create method.

Turning over to Chaitanya to implement.

03/13/09 00:19:03 changed by warmerdam

I see that CreateDataSource?() is actually calling the OGRSqliteDriver::Open() which is where the magic string test is done.

I would suggest altering it to create a datasource object and call OGRSqliteDataSource::Open() instead which skips this test.

03/23/09 10:11:55 changed by chaitanya

  • status changed from new to closed.
  • resolution set to fixed.

03/23/09 10:42:50 changed by crschmidt

Fix was r16597.