Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ changes:
language features that allow ordinary SQL to deliberately corrupt the database file are disabled.
The defensive flag can also be set using `enableDefensive()`.
**Default:** `false`.
* `limits` {Object} Configuration for various SQLite limits. These limits
can be used to prevent excessive resource consumption when handling
potentially malicious input. See [Run-Time Limits][] in the SQLite
documentation for details. The following properties are supported:
* `length` {number} Maximum length of a string or BLOB.
* `sqlLength` {number} Maximum length of an SQL statement.
* `column` {number} Maximum number of columns.
* `exprDepth` {number} Maximum depth of expression tree.
* `compoundSelect` {number} Maximum number of terms in compound SELECT.
* `vdbeOp` {number} Maximum number of VDBE instructions.
* `functionArg` {number} Maximum number of function arguments.
* `attach` {number} Maximum number of attached databases.
* `likePatternLength` {number} Maximum length of LIKE pattern.
* `variableNumber` {number} Maximum number of SQL variables.
* `triggerDepth` {number} Maximum trigger recursion depth.

Constructs a new `DatabaseSync` instance.

Expand Down Expand Up @@ -443,6 +458,31 @@ added:
* Type: {boolean} Whether the database is currently within a transaction. This method
is a wrapper around [`sqlite3_get_autocommit()`][].

### `database.limits`

<!-- YAML
added: REPLACEME
-->

* Type: {Object}

An object for getting and setting SQLite database limits at runtime.
Each property corresponds to an SQLite limit and can be read or written.

```js
const db = new DatabaseSync(':memory:');

// Read current limit
console.log(db.limits.length);

// Set a new limit
db.limits.sqlLength = 100000;
```

Available properties: `length`, `sqlLength`, `column`, `exprDepth`,
`compoundSelect`, `vdbeOp`, `functionArg`, `attach`, `likePatternLength`,
`variableNumber`, `triggerDepth`.

### `database.open()`

<!-- YAML
Expand Down Expand Up @@ -1454,6 +1494,7 @@ callback function to indicate what type of operation is being authorized.
[Type conversion between JavaScript and SQLite]: #type-conversion-between-javascript-and-sqlite
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.html
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
[Run-Time Limits]: https://www.sqlite.org/c3ref/limit.html
[`SQLITE_DBCONFIG_DEFENSIVE`]: https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive
[`SQLITE_DETERMINISTIC`]: https://www.sqlite.org/c3ref/c_deterministic.html
[`SQLITE_DIRECTONLY`]: https://www.sqlite.org/c3ref/c_deterministic.html
Expand Down
2 changes: 2 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
V(kill_signal_string, "killSignal") \
V(kind_string, "kind") \
V(last_insert_rowid_string, "lastInsertRowid") \
V(limits_string, "limits") \
V(length_string, "length") \
V(library_string, "library") \
V(loop_count, "loopCount") \
Expand Down Expand Up @@ -436,6 +437,7 @@
V(sqlite_column_template, v8::DictionaryTemplate) \
V(sqlite_statement_sync_constructor_template, v8::FunctionTemplate) \
V(sqlite_statement_sync_iterator_constructor_template, v8::FunctionTemplate) \
V(sqlite_limits_template, v8::ObjectTemplate) \
V(sqlite_session_constructor_template, v8::FunctionTemplate) \
V(srv_record_template, v8::DictionaryTemplate) \
V(streambaseoutputstream_constructor_template, v8::ObjectTemplate) \
Expand Down
Loading
Loading