Skip to content

Add colsUsed to vtable BestIndex callback#1378

Open
theimpostor wants to merge 2 commits intomattn:masterfrom
theimpostor:pr-1323-bestindex-colused
Open

Add colsUsed to vtable BestIndex callback#1378
theimpostor wants to merge 2 commits intomattn:masterfrom
theimpostor:pr-1323-bestindex-colused

Conversation

@theimpostor
Copy link
Copy Markdown
Contributor

Split out of #1336 per review feedback.

Summary

  • pass sqlite3_index_info.colUsed through to the Go VTab.BestIndex callback
  • update the examples and tests for the new callback signature
  • add test coverage for the propagated colsUsed mask

Fixes #1323.

@mattn
Copy link
Copy Markdown
Owner

mattn commented Apr 29, 2026

Thanks for splitting this out. The feature itself is welcome — colUsed is a useful planner hint and #1323 is a real gap.

My concern is that changing the VTab.BestIndex signature is a breaking API change. Every external implementer of VTab will fail to compile after upgrading, which we want to avoid in v1.

This repo already uses optional interfaces for extensions (see VTabUpdater, EponymousOnlyModule). Could you take the same approach here? Something like:

type VTabBestIndexV2 interface {
    BestIndexV2([]InfoConstraint, []InfoOrderBy, uint64) (*IndexResult, error)
}

In goVBestIndex, type-assert and call BestIndexV2 if implemented, otherwise fall back to the existing BestIndex. That way existing users keep compiling and only those who need colUsed opt in.

Minor: SQLite names the field colUsed (singular) — matching that naming would make the docs easier to follow.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vtable BestIndex callback missing colUsed input

2 participants