Skip to content

sqlite: reject plans with unusable virtual table parameters - #66215

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:sqlite-virtual-table-param-unavailable
Open

trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:sqlite-virtual-table-param-unavailable

Conversation

@trivikr

@trivikr trivikr commented Sep 22, 2026

Copy link
Copy Markdown
Member

Fixes: #66214

Return SQLITE_CONSTRAINT from xBestIndex() when a hidden column has an equality constraint that is not usable at the current point in the query plan. Accepting such a plan makes xFilter() call rows() with null, silently dropping rows and returning an empty result, e.g. for "SELECT DISTINCT * FROM m(t.a) JOIN t ON t.a = m.a".

Cost estimates alone cannot enforce parameter dependencies; rejecting the plan lets SQLite pick an ordering where the parameter value is available.


Assisted-by: opencode

@nodejs-github-bot

Copy link
Copy Markdown
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++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Sep 22, 2026
Return SQLITE_CONSTRAINT from xBestIndex() when a hidden column has
an equality constraint that is not usable at the current point in the
query plan. Accepting such a plan makes xFilter() call rows() with
null, silently dropping rows and returning an empty result, e.g. for
"SELECT DISTINCT * FROM m(t.a) JOIN t ON t.a = m.a". Cost estimates
alone cannot enforce parameter dependencies; rejecting the plan lets
SQLite pick an ordering where the parameter value is available.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: opencode
@trivikr
trivikr force-pushed the sqlite-virtual-table-param-unavailable branch from 8b0e7cc to cd29ffe Compare September 23, 2026 00:26
@trivikr
trivikr requested a review from araujogui September 23, 2026 01:22
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 23, 2026
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.27%. Comparing base (c0ed28f) to head (cd29ffe).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66215      +/-   ##
==========================================
- Coverage   90.29%   90.27%   -0.02%     
==========================================
  Files         790      790              
  Lines      272883   272891       +8     
  Branches    52118    52108      -10     
==========================================
- Hits       246387   246348      -39     
- Misses      16943    16996      +53     
+ Partials     9553     9547       -6     
Files with missing lines Coverage Δ
src/node_sqlite.cc 82.04% <75.00%> (-0.02%) ⬇️

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

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. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite virtual table silently returns empty rows for unavailable join parameters

2 participants