Skip to content

sqlite: copy changeset before applying it - #65286

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-sqlite-apply-changeset-buffer
Open

sqlite: copy changeset before applying it#65286
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-sqlite-apply-changeset-buffer

Conversation

@mcollina

Copy link
Copy Markdown
Member

SQLite can invoke JavaScript conflict and filter callbacks while applying a changeset. Copy the input first so detaching or modifying its backing buffer during a callback does not affect the active operation.

SQLite can invoke JavaScript conflict and filter callbacks while
applying a changeset. Copy the input first so detaching or modifying
its backing buffer during a callback does not affect the active
operation.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

@mcollina
mcollina requested review from Renegade334 and trivikr and removed request for trivikr August 14, 2026 14:41
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.31%. Comparing base (41afbd3) to head (89990be).
⚠️ Report is 160 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 73.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65286      +/-   ##
==========================================
+ Coverage   90.30%   90.31%   +0.01%     
==========================================
  Files         759      751       -8     
  Lines      247597   250012    +2415     
  Branches    46679    47234     +555     
==========================================
+ Hits       223591   225805    +2214     
- Misses      15469    15571     +102     
- Partials     8537     8636      +99     
Files with missing lines Coverage Δ
src/node_sqlite.cc 81.42% <73.33%> (+0.90%) ⬆️

... and 154 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/node_sqlite.cc
}

std::unique_ptr<BackingStore> changeset;
if (buf.length() > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLite can invoke JavaScript conflict and filter callbacks while applying a changeset

We could check for the presence of filter and onConflict functions as well. If none is set, we don't need to copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants