diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index 186e70784b94d0..7209badc9df43c 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -155,6 +155,23 @@ 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][] and [Limit Constants][] + in the SQLite documentation for details. Default values are determined by + SQLite's compile-time defaults and may vary depending on how SQLite was + built. 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. @@ -443,6 +460,36 @@ added: * Type: {boolean} Whether the database is currently within a transaction. This method is a wrapper around [`sqlite3_get_autocommit()`][]. +### `database.limits` + + + +* 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; + +// Reset a limit to its compile-time maximum +db.limits.sqlLength = Infinity; +``` + +Available properties: `length`, `sqlLength`, `column`, `exprDepth`, +`compoundSelect`, `vdbeOp`, `functionArg`, `attach`, `likePatternLength`, +`variableNumber`, `triggerDepth`. + +Setting a property to `Infinity` resets the limit to its compile-time maximum value. + ### `database.open()`