Skip to content

xConnect for virtual tables to query core db connection #1366

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 23 commits into from
May 25, 2025

Conversation

PThorpe92
Copy link
Collaborator

Re-Opening #1076 because it had bit-rotted to a point of no return.

However it has improved. Now with Weak references and no incrementing Rc strong counts.

This also includes a better test extension that returns info about the other tables in the schema.
image
(theme doesn't show rows column)

@penberg
Copy link
Collaborator

penberg commented May 20, 2025

This pull request has been marked as stale due to inactivity. It will be closed in 7 days if no further activity occurs.

@penberg penberg added the Stale label May 20, 2025
@jussisaurio jussisaurio removed the Stale label May 20, 2025
@jussisaurio jussisaurio requested a review from Copilot May 20, 2025 16:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the virtual table API to pass a live database connection into extensions, adds a new TableStats virtual table with tests for row counts, and revises the registration macros and core wiring to use weak references rather than bumping Rc strong counts.

  • Extend all VTabModule::open functions to accept an optional Connection handle.
  • Implement connect in the core so extensions get a weak-backed Conn pointer.
  • Add a new tablestats virtual table module and CLI tests for it.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
testing/cli_tests/extensions.py Added new test_tablestats and adjusted TestLimboShell callsite.
macros/src/lib.rs Updated generated FFI signatures to pass conn and register it.
extensions/tests/src/lib.rs Added TableStats module implementation and derive boilerplate.
extensions/series/src/lib.rs Updated GenerateSeriesVTab::open signature and tests.
extensions/core/src/vtabs.rs Added conn field and new FFI types, updated VTabModule trait.
extensions/core/src/types.rs Introduced new ResultCode variants and StepResult.
extensions/core/src/lib.rs Exposed the new StepResult and core Connection API.
extensions/core/README.md Updated example to show passing Connection into open.
extensions/completion/src/lib.rs Updated CompletionVTab::open signature.
core/types.rs Added OwnedValue::from_ffi_ptr helper.
core/ext/vtab_connect.rs New FFI shims using weak Rc for extension connections.
core/ext/mod.rs & core/ext/dynamic.rs Wire the new connect function into dynamic and built-in loading.
core/translate/main_loop.rs Skip zero‐index constraints in best_index loop.
core/lib.rs Updated VirtualTable::open to forward conn pointer.
Comments suppressed due to low confidence (2)

testing/cli_tests/extensions.py:502

  • Other tests still call TestLimboShell() without arguments. If the constructor signature changed, those will break—unify all calls to use the new signature or overload the constructor.
limbo = TestLimboShell("")

extensions/core/README.md:195

  • [nitpick] The example now mentions Rc<Connection> but does not show importing std::rc::Rc (or limbo_ext::Connection). Add those use statements to keep the snippet complete.
fn open(&self, conn: Option<Rc<Connection>>) -> Result<Self::VCursor, Self::Error> {

@jussisaurio jussisaurio merged commit f388bc5 into tursodatabase:main May 25, 2025
41 checks passed
@PThorpe92 PThorpe92 deleted the vtab_xconnect branch May 25, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants