Skip to content

Commit cece44d

Browse files
committedApr 25, 2020
documented unsafe mode
1 parent a8ee5a5 commit cece44d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ For these situations, you should probably use a full-fledged RDBMS such as [Post
6969
- [Performance](./docs/performance.md) (also see [benchmark results](./docs/benchmark.md))
7070
- [64-bit integer support](./docs/integer.md)
7171
- [Worker thread support](./docs/threads.md)
72+
- [Unsafe mode (advanced)](./docs/unsafe.md)
7273
- [SQLite3 compilation](./docs/compilation.md)
7374

7475
# License

‎deps/sqlite3.gyp

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
'includes': ['defines.gypi'],
5757
}, {
5858
'defines': [
59-
# These are currently required by better-sqlite3.
60-
'SQLITE_USE_URI=1',
59+
# This is currently required by better-sqlite3.
6160
'SQLITE_ENABLE_COLUMN_METADATA',
6261
],
6362
}]

‎docs/unsafe.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Unsafe mode
2+
3+
By default, `better-sqlite3` prevents you from doing things that might corrupt your database or cause undefined behavior. Such unsafe operations include:
4+
5+
- Anything blocked by [`SQLITE_DBCONFIG_DEFENSIVE`](https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive)
6+
- Mutating the database while [iterating](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#iteratebindparameters---iterator) through a query's result set
7+
8+
However, some advanced users might want to use these functionalities at their own risk. For this reason, users have the option of enabling "unsafe mode".
9+
10+
```js
11+
db.unsafeMode(); // Unsafe mode ON
12+
db.unsafeMode(true); // Unsafe mode ON
13+
db.unsafeMode(false); // Unsafe mode OFF
14+
```
15+
16+
Unsafe mode can be toggled at any time, and independently for each database connection. While toggled on, `better-sqlite3` will not prevent you from performing the dangerous operations listed above.

0 commit comments

Comments
 (0)
Please sign in to comment.