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

Microsoft.Data.Sqlite: Virtual table modules #13823

Open
Tracked by #22949
bricelam opened this issue Apr 2, 2014 · 10 comments
Open
Tracked by #22949

Microsoft.Data.Sqlite: Virtual table modules #13823

bricelam opened this issue Apr 2, 2014 · 10 comments

Comments

@bricelam
Copy link
Contributor

bricelam commented Apr 2, 2014

SQLite supports creating virtual tables that are implemented by the host application. We should create an API for doing this. See Virtual Table Object.

@bricelam
Copy link
Contributor Author

bricelam commented May 1, 2017

Apparently these things can be used as TVFs. See the table-valued functions section.

(cc @divega)

@AlexanderTaeschner
Copy link
Contributor

We would need to have access to sqlite3_create_module or sqlite3_create_module_v2 in SQLitePCL.raw first.

@ericsink
Copy link

Yeah, that's an area of the sqlite API that I never implemented.

But I could...

:-)

@bricelam
Copy link
Contributor Author

bricelam commented Jan 3, 2018

(Depends on ericsink/SQLitePCL.raw#191)

@fdcastel
Copy link

This is a fantastic feature of SQLite! It's really sad it isn't available in netcore.

@ericsink any chance of unleash ericsink/SQLitePCL.raw#191 for us, mere mortals? 😉

I'm really interested to work on this (with an API similar to System.Data.SQLite, with room for improvements). But for now I'm yet trying to build https://github.com/ericsink/SQLitePCL.raw (and failing miserably 😄).

@ericsink
Copy link

@fdcastel Nobody needs my permission to work on a feature of SQLitePCL.raw. It's open source, so if you want to proceed, feel free.

Admittedly, getting your changes merged into my repo is another story. :-)

The real problem here is that SQLitePCL.raw is too hostile to work on. I'm planning some improvements in that area, to make things easier for other developers who want to collaborate. But I haven't got much done in that area yet.

@bricelam
Copy link
Contributor Author

(I've considered starting a PR, but my TODO list is pretty big...)

@fdcastel
Copy link

fdcastel commented Jul 26, 2018

@bricelam if you already made any work on this subject (even if largely incomplete/unusable) and could share it, it would be great.

I'm just starting to grasp some concepts of SQLitePCL.raw.

The good thing is: It's building now! 😄

@bricelam
Copy link
Contributor Author

I remember starting on a P/Invoke version of sqlite3_module similar to our or old sqlite3_vfs implementation, but decided I wasn't ready to see it through and threw it away.

@ajcvickers ajcvickers transferred this issue from aspnet/Microsoft.Data.Sqlite Oct 31, 2018
@ajcvickers ajcvickers added this to the Backlog milestone Oct 31, 2018
@ajcvickers ajcvickers changed the title Virtual table modules Microsoft.Data.Sqlite: Virtual table modules Oct 31, 2018
@bricelam
Copy link
Contributor Author

bricelam commented Dec 9, 2020

It would be nice to create sugar over this for TFVs. Something like...

connection.CreateTVF("generate_series", GenerateSeries);
record Row(int Value);

static IEnumerable<Row> GenerateSeries(int start, int stop, int step)
{
    for (var i = start; i <= stop; i += step)
    {
        yield return new (Value: i);
    }
}
SELECT value FROM generate_series(1, 10, 3);

Unfortunately, I don't see how we'd synthesize rowid (primary key) values with this approach. ☹

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

No branches or pull requests

5 participants