Skip to content

sqlite: refactor prepared statement iterator #57569

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

Merged
merged 1 commit into from
Apr 3, 2025

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

@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 586 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
Member

@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

@cjihrig
Copy link
Contributor Author

cjihrig commented Mar 24, 2025

I'm not sure if anyone else has permission to resume the CI, but I don't.

@nodejs-github-bot
Copy link
Collaborator

@gurgunday gurgunday added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 2, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Apr 3, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 3, 2025
@nodejs-github-bot nodejs-github-bot merged commit 771b682 into nodejs:main Apr 3, 2025
72 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 771b682

@cjihrig cjihrig deleted the iterator branch April 3, 2025 14:16
JonasBa pushed a commit to JonasBa/node that referenced this pull request Apr 11, 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: nodejs#57493
PR-URL: nodejs#57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
RafaelGSS pushed a commit that referenced this pull request May 1, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
RafaelGSS pushed a commit that referenced this pull request May 2, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 6, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 6, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
RafaelGSS pushed a commit that referenced this pull request May 14, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 16, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 18, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
aduh95 pushed a commit that referenced this pull request May 19, 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
PR-URL: #57569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Edy Silva <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
@marco-ippolito marco-ippolito added dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. sqlite Issues and PRs related to the SQLite subsystem. labels Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. lib / src Issues and PRs related to general changes in the lib or src directory. sqlite Issues and PRs related to the SQLite subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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