#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 |
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 (4)
comment:1 by , 16 years ago
Cc: | added |
---|---|
Keywords: | sqlite added |
Owner: | changed from | to
comment:2 by , 16 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 , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.