Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c6c66c
sqlite: add limits property to DatabaseSync
mertcanaltin Jan 6, 2026
ffd7dd0
lint
mertcanaltin Jan 6, 2026
2ab490a
fix reviews
mertcanaltin Jan 6, 2026
96f1410
Update node_sqlite.h
mertcanaltin Jan 6, 2026
d9d722e
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
6f093f4
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
3452324
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
d7ee60a
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
cdc1ac9
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
16b5720
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
e71e311
Update node_sqlite.cc
mertcanaltin Jan 6, 2026
f3a7f1e
reviews fixed
mertcanaltin Jan 6, 2026
2df2557
lint
mertcanaltin Jan 6, 2026
346d53c
added max value control
mertcanaltin Jan 6, 2026
7164b3d
used single cycle
mertcanaltin Jan 6, 2026
fd2a144
repair
mertcanaltin Jan 6, 2026
a45872b
lint
mertcanaltin Jan 6, 2026
44041d6
review fixed
mertcanaltin Jan 7, 2026
5a16bdc
lint
mertcanaltin Jan 7, 2026
ee8f356
update sqlite limits to allow null for resetting to compile-time maximum
mertcanaltin Jan 8, 2026
771ad11
lint
mertcanaltin Jan 8, 2026
2652ebc
update sqlite limits to reset using Infinity instead of null
mertcanaltin Jan 11, 2026
7bee714
Update src/node_sqlite.h
mertcanaltin Jan 17, 2026
854f486
Update src/node_sqlite.cc
mertcanaltin Jan 18, 2026
125715b
replace hardcoded limit size with constexpr variable for better maint…
mertcanaltin Jan 18, 2026
c38d02b
lint
mertcanaltin Jan 18, 2026
49c8fff
Update src/node_sqlite.h
mertcanaltin Jan 19, 2026
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
49 changes: 49 additions & 0 deletions doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`

<!-- 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;

// 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()`

<!-- YAML
Expand Down Expand Up @@ -1450,6 +1497,8 @@ callback function to indicate what type of operation is being authorized.
[Changesets and Patchsets]: https://www.sqlite.org/sessionintro.html#changesets_and_patchsets
[Constants Passed To The Conflict Handler]: https://www.sqlite.org/session/c_changeset_conflict.html
[Constants Returned From The Conflict Handler]: https://www.sqlite.org/session/c_changeset_abort.html
[Limit Constants]: https://www.sqlite.org/c3ref/c_limit_attached.html
[Run-Time Limits]: https://www.sqlite.org/c3ref/limit.html
[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection
[Type conversion between JavaScript and SQLite]: #type-conversion-between-javascript-and-sqlite
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.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