Commit Graph
120 Commits
Author SHA1 Message Date
Trivikram Kamat 3abf65fc3e sqlite: validate StatementSync.run() integers
Use the standard SQLite integer conversion for changes and
lastInsertRowid. Throw ERR_OUT_OF_RANGE when a value cannot be
represented safely as a Number, or return it as a BigInt when
BigInt reads are enabled.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65178
Fixes: https://github.com/nodejs/node/issues/65177
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2026-08-17 04:01:47 +00:00
Guilherme Araújo c7b962c222 sqlite: add diagnostic channel
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62241
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-15 19:42:37 +00:00
Guilherme Araújo c8996eaec9 sqlite: add stmt persistent flag
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62757
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-08-14 21:57:31 +00:00
Trevor Burnham c4b755ee00 sqlite: reject connection access from authorizer callbacks
SQLite requires that an authorizer callback not modify the connection
that invoked it, and counts sqlite3_prepare_v2() and sqlite3_step() as
modifications. node:sqlite let the callback call prepare(), exec(), the
statement execution methods, and other connection-mutating APIs on the
same DatabaseSync. Track authorizer depth on DatabaseSync with an RAII
guard around the callback and throw ERR_INVALID_STATE from the affected
entry points while it is on the stack. Covering every authorizer
invocation, including the re-prepare that SQLite can run during
sqlite3_step(), exposed a second and distinct hazard: reentering a
statement that is currently being stepped is a use-after-free rather
than a contract violation, since finalizing it frees the virtual machine
under sqlite3_step() and re-running it resets that machine
mid-execution. Any callback SQLite invokes during execution can reach
it, so a user-defined function is enough. Track the statements currently
being stepped and reject reentry into only those, which leaves a
user-defined function free to prepare, run, and finalize its own helper
statements.

Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
Fixes: https://github.com/nodejs/node/issues/63207
Assisted-by: claude:opus-5
PR-URL: https://github.com/nodejs/node/pull/65156
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-14 21:43:35 +00:00
Edy Silva f46e96fe54 sqlite: expose prepared statement statistics
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64541
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2026-08-13 13:59:56 +00:00
Guilherme Araújo b0edc373a6 sqlite: manage sqlite3_stmt lifetime with RAII
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62419
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-11 23:47:37 +00:00
semimikoh 673cdef7d9 sqlite: check sqlite3_step() and sqlite3_reset() results
Signed-off-by: semimikoh <ejffjeosms@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63319
Fixes: https://github.com/nodejs/node/issues/63311
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-11 15:30:37 +00:00
Trevor Burnham cb9bb66780 sqlite: reject statement-less SQL in prepare()
Apply the same check to DatabaseSync::Prepare() so that statement-less
SQL is rejected at preparation instead of on first use. This matches
SQLite's own oo1 JavaScript API, which throws when the SQL contains no
statements rather than exposing the C API's null statement pointer.

Previously db.prepare('-- comment') returned a StatementSync whose
statement_ was null. Every method on it threw "statement has been
finalized", which was misleading because nothing had been finalized, and
the object was still inserted into statements_. Since IsFinalized() is
true for a null statement, its destructor skipped UntrackStatement() and
left a dangling pointer in the set that a later close() would finalize.

Refs: https://github.com/nodejs/node/pull/65157#discussion_r3742903347
Refs: https://sqlite.org/wasm/doc/trunk/api-oo1.md

Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65157
Fixes: https://github.com/nodejs/node/issues/65149
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-11 03:14:51 +00:00
Trevor Burnham 71b3676332 sqlite: reject statement-less SQL in SQLTagStore
sqlite3_prepare_v2() returns SQLITE_OK without producing a statement
when its input holds no SQL, such as a comment. PrepareStatement() only
checked the return code, so it cached a StatementSync wrapping a null
sqlite3_stmt. Executing it reached sqlite3_clear_bindings(), which only
guards against a null statement under SQLITE_ENABLE_API_ARMOR, and
segfaulted.

Reject such input instead of caching it. The StatementSync methods
already avoid the crash because their IsFinalized() guard treats a null
statement as finalized.

Fixes: https://github.com/nodejs/node/issues/65149

Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65157
Fixes: https://github.com/nodejs/node/issues/65149
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-11 03:14:50 +00:00
Kamat, Trivikram ab95309457 sqlite: isolate applyChangeset filter errors
Track filter callback failures within each applyChangeset() invocation.
Returning false from xFilter is not a SQLite error. This previously left
the database-wide suppression flag set, which could hide the next
unrelated SQLite error.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64823
Fixes: https://github.com/nodejs/node/issues/64822
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2026-08-09 23:03:08 -07:00
Kamat, Trivikram b2b7405d26 sqlite: reject deserialize() while in a callback
deserialize() could be called from a user-defined function invoked
during statement execution, tearing down the database connection while
sqlite3_step() was still using it. Reuse the existing callback depth
check to throw ERR_INVALID_STATE instead, matching the guard already
in place for close().

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64796
Refs: https://github.com/nodejs/node/issues/64795
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2026-08-09 16:26:58 -07:00
Nora Dossche 330f7b5503 sqlite: check null returns from sqlite value functions
sqlite3_column_text() can return nullptr on failure which
was not handled.
sqlite3_column_blob() can return nullptr for zero-length BLOBs,
which is then passed to memcpy() which is UB.
Avoid this by checking for a nullptr.

Signed-off-by: ndossche <nora.dossche@ugent.be>
PR-URL: https://github.com/nodejs/node/pull/63288
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-09 07:44:02 +00:00
Anshika Jain 98fd6cb1c0 sqlite: validate maxSize argument in createTagStore()
Signed-off-by: anshikakalpana <anshikajain196872@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63792
Fixes: https://github.com/nodejs/node/issues/63791
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-08 15:54:54 +00:00
Ali Hassan 347e266187 sqlite: refactor error helpers and user function pointers
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com>
PR-URL: https://github.com/nodejs/node/pull/62794
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-08 13:54:01 +00:00
Trivikram Kamat f538f11faf sqlite: reject non-positive backup rates
Passing a rate of 0 to backup() causes sqlite3_backup_step() to copy
no pages. The backup job then continually reschedules itself and the
returned promise never settles.

Require backup rates to be positive integers to prevent zero-work
backup jobs.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64893
Fixes: https://github.com/nodejs/node/issues/64892
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-08 07:29:36 +00:00
Matteo Collina 8fc73417fb sqlite: clear SQLTagStore bindings
SQLTagStore reused cached statements without clearing values bound by a
previous execution. Clear bindings before binding new values and reject
parameters that do not correspond to template substitutions.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65041
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-07 09:16:50 +00:00
mike-git374 de333e856d sqlite: bind Boolean
PR-URL: https://github.com/nodejs/node/pull/62001
Fixes: https://github.com/nodejs/node/issues/57862
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
2026-08-05 22:50:13 -07:00
Nora Dossche c18fd9060b sqlite: fix undefined behaviour in Session::Changeset()
If `nChangeset == 0`, the pointer `pChangeset` may be nullptr.
Passing a nullptr to `memcpy()` is undefined behaviour.
This can be triggered by running the test suite under UBSAN.

Signed-off-by: ndossche <nora.dossche@ugent.be>
PR-URL: https://github.com/nodejs/node/pull/63637
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-08-06 03:18:25 +00:00
Guilherme Araújo 51c0d94072 sqlite: add StatementSync.prototype.close()
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64232
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-08-05 18:10:35 -07:00
Guilherme Araújo 04c104a725 sqlite: add StatementSync.prototype[Symbol.dispose]()
This extends explicit resource management support to prepared
statements, allowing a StatementSync to be deterministically
finalized via a `using` declaration, mirroring the existing
DatabaseSync and Session dispose methods.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64232
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-08-05 18:10:31 -07:00
mike-git374 62acd4888c sqlite: bind ArrayBuffer
PR-URL: https://github.com/nodejs/node/pull/62061
Fixes: https://github.com/nodejs/node/issues/61396
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-08-05 22:43:40 +02:00
Matteo CollinaandAsroy Cristian Sitorus 5cef7673ae sqlite: prevent database close during callbacks
Co-authored-by: Asroy Cristian Sitorus <asroycristiansitorus@gmail.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64743
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-04 11:05:47 +00:00
Trivikram Kamat f00fb75051 sqlite: invalidate sessions when closing database
DatabaseSync::DeleteSessions() deleted native sqlite3_session handles
without clearing the pointers held by their Session wrappers. Reopening
the database allowed stale session handles to be used, crashing the
process.

Track Session wrappers and delete sessions through Session::Delete() so
the wrappers are marked closed.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64783
Fixes: https://github.com/nodejs/node/issues/64782
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-03 19:34:01 +00:00
Trivikram Kamat a58aad785b sqlite: check database state before calling SQLite
Check whether the database is open in enableLoadExtension() and
setAuthorizer() before passing the connection to SQLite. This prevents
calls after close() from terminating the process and makes them throw
ERR_INVALID_STATE instead.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/64812
Fixes: https://github.com/nodejs/node/issues/64811
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-07-31 04:11:16 +00:00
Matteo Collina d0387cf67c sqlite: invalidate tag store iterators on statement reset
SQLTagStore Run/Iterate/Get/All reset the shared cached statement via
raw sqlite3_reset(), bypassing ResetStatement() and its reset_generation_
bump, so live iterators were never invalidated. Also mark the iterator
done on SQLITE_DONE so it cannot restart the statement.

PR-URL: https://github.com/nodejs-private/node-private/pull/896
Refs: https://hackerone.com/reports/3564941
Reviewed-By: Robert Nagy <ronagy@icloud.com>
CVE-ID: CVE-2026-58041
2026-07-29 10:41:25 -03:00
Mohamed Sayed d4d35c6363 sqlite: fix crash when a session outlives its database
Keep the database alive while a session is open so that closing the
database before the session does not leave the session pointing at
freed memory.

Signed-off-by: Mohamed Sayed <k@3zrv.com>
PR-URL: https://github.com/nodejs/node/pull/63797
Fixes: https://github.com/nodejs/node/issues/63796
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-07-26 01:43:30 +00:00
Matteo Collina fd41198dff sqlite: fix use-after-free in Exec() and ApplyChangeset()
When sqlite3_exec() or sqlite3changeset_apply() call JavaScript
callbacks (user-defined functions, conflict handlers, or filter
callbacks), the DatabaseSync object could be garbage-collected
if the JavaScript code drops all references to it. Both methods
only held a raw DatabaseSync* pointer on the C++ stack, which
V8 GC does not track.

Add a BaseObjectPtr<DatabaseSync> guard that keeps the database
alive for the duration of these SQLite API calls, preventing a
use-after-free when the JavaScript callback triggers GC.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64535
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-07-23 14:37:21 +00:00
Guilherme Araújo 47e332d227 sqlite: read column count after step in StatementSync.all()
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64219
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-07-07 12:40:43 +00:00
Yagiz Nizipli cf89b61932 sqlite: do not leave database open after failed open
When sqlite3_open_v2() fails, SQLite still assigns a database handle
in a "sick" state. Such a handle may only be used to retrieve the
error and must then be released with sqlite3_close(). Keeping it in
connection_ meant that after a failed open():

- isOpen incorrectly reported true,
- every method passed the "database is not open" check and called
  SQLite APIs on the sick handle, which is an API misuse,
- registering a user-defined function leaked its user data in builds
  with SQLITE_ENABLE_API_ARMOR, because SQLite rejects the call
  before taking ownership of the user data,
- open() could not be retried since the database appeared open.

Close and reset the connection handle when open() fails at any point
so that the database remains closed and open() can be retried.

Fixes: https://github.com/nodejs/node/issues/63831
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
PR-URL: https://github.com/nodejs/node/pull/63854
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-06-16 16:29:30 +00:00
ndossche 25ffc1a164 sqlite: fix stack-use-after-scope with function callback
The `hasIt` block has `Local<Function>`s, but it's capture in the
lambda, yet the lambda is used after the locals go out of scope.

Signed-off-by: ndossche <nora.dossche@ugent.be>
PR-URL: https://github.com/nodejs/node/pull/63640
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-06-05 12:15:51 +02:00
Antoine du Hamel b9203ee79f src,sqlite: only pass xFilter when user provided a callback
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63516
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-05-25 17:20:10 +00:00
Edy Silva 6009d937f5 src,sqlite: remove dead code
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63204
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
2026-05-12 13:06:54 +00:00
Matteo Collina b5da7515f9 sqlite: keep source database alive during backup
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/62673
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-05-06 23:09:55 +00:00
Igor Sheludko 8aea917381 src: stop using v8::PropertyCallbackInfo<T>::This()
Refs: https://github.com/nodejs/node/issues/60616
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:35 +02:00
Ali Hassan ef8f8f886c sqlite: use OneByte for ASCII text and internalize col names
Use simdutf to detect ASCII text values and create them
via NewFromOneByte for compact one-byte representation.
Internalize column name strings with kInternalized so V8
shares hidden classes across row objects. Cache column
names on StatementSync for iterate(), invalidated via
SQLITE_STMTSTATUS_REPREPARE on schema changes.

Refs: https://github.com/nodejs/performance/issues/181
PR-URL: https://github.com/nodejs/node/pull/61954
Refs: https://github.com/nodejs/performance/issues/181
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-04-11 10:37:30 +00:00
Ali Hassan 4a41a002f6 sqlite: add serialize() and deserialize()
Add database.serialize() and database.deserialize() methods to
DatabaseSync, wrapping the sqlite3_serialize and sqlite3_deserialize
C APIs. These allow extracting an in-memory database as a Uint8Array
and loading one back, enabling snapshots, cloning, and transfer of
databases without filesystem I/O.

Refs: https://github.com/nodejs/node/issues/62575
PR-URL: https://github.com/nodejs/node/pull/62579
Refs: https://github.com/nodejs/node/issues/62575
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-04-10 20:40:01 +00:00
Edy Silva 40c625b0fd src,sqlite: fix filterFunc dangling reference
PR-URL: https://github.com/nodejs/node/pull/62281
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-03-18 16:15:32 +00:00
Anna Henningsen b872cc2fcf src: make AsyncWrap subclass internal field counts explicit
This helps ensure that we already set the correct number of
internal fields when creating objects, even if the number of
internal fields of e.g. AsyncWrap changes over time.

PR-URL: https://github.com/nodejs/node/pull/62103
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-03-06 16:44:32 +00:00
Guilherme Araújo 88be44db0e sqlite: handle stmt invalidation
PR-URL: https://github.com/nodejs/node/pull/61877
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-03-02 23:29:14 +00:00
Mert Can Altin 35d3bc8fe8 sqlite: add limits property to DatabaseSync
PR-URL: https://github.com/nodejs/node/pull/61298
Fixes: https://github.com/nodejs/node/issues/61268
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-02-27 19:00:28 +00:00
Anna Henningsen ad945c599c src: remove unnecessary c_str() conversions in diagnostic messages
PR-URL: https://github.com/nodejs/node/pull/61786
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2026-02-14 10:45:51 +00:00
Ali Hassan 346ad95c3c sqlite: avoid extra copy for large text binds
When binding UTF-8 strings to prepared statements, transfer ownership of
malloc-backed Utf8Value buffers to SQLite to avoid an extra copy for
large strings. Use sqlite3_bind_blob64() when binding BLOB parameters.

PR-URL: https://github.com/nodejs/node/pull/61580
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
2026-02-07 18:52:38 +00:00
Mert Can Altin e7d6728aef sqlite: use DictionaryTemplate for run() result
PR-URL: https://github.com/nodejs/node/pull/61432
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-02-05 14:30:42 +00:00
Bart Louwers f6464c57f6 sqlite: change approach to fix segfault SQLTagStore
PR-URL: https://github.com/nodejs/node/pull/60462
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
2026-01-31 06:35:30 +00:00
Guilherme Araújo 68d7b6f870 sqlite: reserve vectors space
PR-URL: https://github.com/nodejs/node/pull/61540
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2026-01-29 02:22:05 +00:00
Tobias Nießen a35944685a src: use C++ nullptr in sqlite
Refs: https://github.com/nodejs/node/pull/61407
PR-URL: https://github.com/nodejs/node/pull/61416
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-01-19 23:57:12 +00:00
Guilherme Araújo efa7621132 sqlite: add sqlite prepare options args
PR-URL: https://github.com/nodejs/node/pull/61311
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
2026-01-19 23:27:03 +00:00
Pramit Sharma 9c346d22a7 sqlite: improve error messages for tag store
When using SQLite tag store functions (sql.get`, sql.run`, etc.),
preparation errors now show descriptive SQLite error messages instead
of the generic 'Failed to prepare statement' message.

The tag store's GetOrCreateStatement function now passes the database
object to THROW_ERR_SQLITE_ERROR, allowing it to retrieve the actual
error message from sqlite3_errmsg(), matching the behavior of the
regular db.prepare() method.

Fixes: https://github.com/nodejs/node/issues/61051
PR-URL: https://github.com/nodejs/node/pull/61096
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-12-27 00:04:05 +00:00
Michaël Zasso 9a6e55ab3d src: remove unused private field in SQLTagStore
PR-URL: https://github.com/nodejs/node/pull/61027
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2025-12-20 06:22:38 +00:00
René a1f421feb6 sqlite: make SQLTagStore.prototype.size a getter
Drive-by: make callback `args` parameter names consistent
PR-URL: https://github.com/nodejs/node/pull/60246
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2025-12-11 02:29:09 +00:00