Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#2879 closed defect (fixed)

sqlite metadata=no option causes error

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


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 (4)

comment:1 by warmerdam, 13 years ago

Cc: warmerdam added
Keywords: sqlite added
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.

comment:2 by warmerdam, 13 years ago

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.

comment:3 by chaitanya, 13 years ago

Resolution: fixed
Status: newclosed

comment:4 by crschmidt, 13 years ago

Fix was r16597.

Note: See TracTickets for help on using tickets.