SQLITE_OPEN_WAL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SQLITE_OPEN_WAL

wmertens
Hi,

I'd like to create a database in WAL mode if it doesn't exist, so I'm
passing 0x00080000 as a flag to node-sqlite3, but it's not working.

It turns out the lib uses sqlite3_open_v2:
https://github.com/mapbox/node-sqlite3/blob/ac3666ddaab74331a065aafa5095eb338ed59a78/src/database.cc#L153

The SQLITE_OPEN_WAL flag is commented as "VFS only", so I don't know what
that means. Should the lib use a different call for this to work?
https://sqlite.org/c3ref/c_open_autoproxy.html

Wout.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: SQLITE_OPEN_WAL

Simon Slavin-3
On 6 Jun 2019, at 9:11am, Wout Mertens <[hidden email]> wrote:

> I'd like to create a database in WAL mode if it doesn't exist

Create it without the flag then execute

    PRAGMA journal_mode=WAL

The PRAGMA is harmless if the database is already in WAL mode.

If you want to get fussy about it execute

    PRAGMA journal_mode

once the database is open, and convert to WAL mode only if you get anything but WAL back.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: SQLITE_OPEN_WAL

wmertens
On Thu, Jun 6, 2019 at 10:17 AM Simon Slavin <[hidden email]> wrote:

> On 6 Jun 2019, at 9:11am, Wout Mertens <[hidden email]> wrote:
>
> > I'd like to create a database in WAL mode if it doesn't exist
>
> Create it without the flag then execute
>
>     PRAGMA journal_mode=WAL
>

Ah no, you see, the problem is that I can have multiple processes creating
the file at the same time, and then it gets ugly with SQLITE_CANTOPEN and
SQLITE_BUSY. I'd like to avoid that.

 Thinking about it, I have to handle these cases anyway when opening an
existing DB that's not in WAL mode, but still, it's cleaner to start it in
WAL mode from the get-go.

Wout.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users