Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite: refactor prepared statement iterator #57569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Mar 20, 2025

This commit refactors the StatementSync iterator implementation in two primary ways:

  • The iterator internal state is no longer exposed to JavaScript.
  • The iterator prevents the prepared statement from being GC'ed.

Fixes: #57493

This commit refactors the StatementSync iterator implementation
in two primary ways:

- The iterator internal state is no longer exposed to JavaScript.
- The iterator prevents the prepared statement from being GC'ed.

Fixes: nodejs#57493
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/sqlite

Sorry, something went wrong.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 20, 2025
THROW_AND_RETURN_ON_BAD_STATE(
env, iter->stmt_->IsFinalized(), "statement has been finalized");
Isolate* isolate = env->isolate();
LocalVector<Name> keys(isolate, {env->done_string(), env->value_string()});
Copy link
Member

Choose a reason for hiding this comment

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

Nit... LocalVector here might be overkill when a simple array would do. Non-blocking tho.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 84.21053% with 15 lines in your changes missing coverage. Please review.

Project coverage is 90.25%. Comparing base (5a7b7d2) to head (928e4a2).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 86.02% 2 Missing and 11 partials ⚠️
src/node_sqlite.h 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57569      +/-   ##
==========================================
+ Coverage   90.24%   90.25%   +0.01%     
==========================================
  Files         630      630              
  Lines      185013   184989      -24     
  Branches    36241    36233       -8     
==========================================
+ Hits       166966   166971       +5     
+ Misses      10998    10973      -25     
+ Partials     7049     7045       -4     
Files with missing lines Coverage Δ
src/node_sqlite.h 63.63% <0.00%> (-6.37%) ⬇️
src/node_sqlite.cc 80.79% <86.02%> (+2.27%) ⬆️

... and 45 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.

@tpoisseau
Copy link
Contributor

🙏 This implementation is better than my original one

Copy link
Contributor

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

lgtm!

@nodejs-github-bot
Copy link
Collaborator

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++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite: StatementSync#iterate fails with Error: statement has been finalized
6 participants