WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.26k stars 391 forks source link

Exposing file control operations #1101

Open devinivy opened 8 months ago

devinivy commented 8 months ago

We have a use case where it would be useful to be able to run file control operations (i.e. sqlite3_file_control()). Our primary use will actually be to set PERSIST_WAL, also mentioned by another user in #1029. More specifically, we're looking manage the database in such a way that it is safe to use with litestream, which as discussed in https://github.com/benbjohnson/litestream/issues/510 relies on the wal being persisted.

We understand that we could achieve this with a custom build, but this can also be set at runtime using sqlite3_file_control(), which of course would be a more convenient alternative. There's some prior art to setting file control operations at runtime, such as the sqlite3 CLI's .filectrl command and the go driver's SetFileControlInt().

Would the project be open to a contribution that exposes this interface through a method on Database?

JoshuaWise commented 3 months ago

better-sqlite3 is designed to be immune to segfaults and undefined behavior, regardless of what the user does. But perhaps this could be enabled for unsafe mode.