IreneKnapp / direct-sqlite

MIT License
35 stars 54 forks source link

Added open2 function (sqlite3_open_v2 in SQLite) #62

Closed Zigazou closed 2 years ago

Zigazou commented 8 years ago

Hi !

This pull request adds the ability to use the sqlite3_open_v2 with direct-sqlite.

It allows, among other things, to open a database in read-only mode as requested in the following issue https://github.com/IreneKnapp/direct-sqlite/issues/52

fosskers commented 5 years ago

Any chance of this being merged (after resolving the conflicts, of course)?

sigrlami commented 5 years ago

@fosskers if conflicts are resolved and single course of testing applied, then yes.

jchia commented 2 years ago

It seems that calling sqlite3_open() is strictly a specialization of calling sqlite3_open_v2() , and that every call to sqlite3_open() can be rephrased as a call to sqlite3_open_v2() using SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE for the 3rd argument and nullptr for the 4th argument. https://github.com/sqlite/sqlite/blob/dcd7408db8d1c68995bdc4825d281e7cc8dfa54e/src/main.c#L3494 https://www.sqlite.org/c3ref/open.html

Consequently, perhaps open can be implemented as a call to open2 and the tests deal only with open2, reducing some of the difficulties regarding test duplication. Some of the remaining difficulties are related to the behavior difference arising from opening a DB with different 3rd & 4th arguments, e.g. the behavior from trying to write is different between opening RW and opening RO.

jchia commented 2 years ago

I've pushed commits for open2 with refactored tests.