Go-sqlite3: Eponymous-only virtual tables

Created on 26 Aug 2020  路  6Comments  路  Source: mattn/go-sqlite3

Does this package support eponymous-only virtual tables? I see some vtable related files that have the sqlite_vtable and vtable build tags, but I can't tell if they would allow a NULL xCreate.

Most helpful comment

@rittneje FYI #885 attempts to implement what you suggested above - would love any feedback if you're available! Thanks again for the help!

All 6 comments

Did you try to build with -tags sqlite_vtable ?

It doesn't support them. This repo hard-codes xCreate to a function that ultimately calls the Create method on the Module interface implementation. Consequently, there is no mechanism at present to cause it to be null.

https://github.com/mattn/go-sqlite3/blob/6a8b30186d28277f09a0ba6df3d3fa3859c5c499/sqlite3_opt_vtable.go#L202-L227

Thank you @rittneje

Thank you @rittneje for providing context, coming across this issue when searching around for eponymous virtual table in this library and this is very helpful. Based on the current implementation, do you think it would be possible to implement a means of passing a null as the xCreate method? Unfortunately, I don't have much experience with c/cgo, but would love to experiment (ideally with some guidance!) to try adding support for eponymous virtual tables in this package. The current virtual table implementation is really cool and has been doing quite a bit of heavy lifting in a project I've been building!

One option I can think of is to add an optional interface. Something like:

type EponymousOnlyModule interface {
    Module
    EponymousOnlyModule()
}

Then you could say that if the module implements EponymousOnlyModule(), then xCreate should be null and the Create method is ignored. Regular modules will not define the EponymousOnlyModule() method at all.

In terms of the sqlite3_module object, the simplest approach is to copy the goModule object (except set xCreate to null), and then choose one or the other in CreateModule.

@rittneje FYI #885 attempts to implement what you suggested above - would love any feedback if you're available! Thanks again for the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackhu1990 picture jackhu1990  路  11Comments

jacentsao picture jacentsao  路  6Comments

gaorongfu picture gaorongfu  路  10Comments

barnettZQG picture barnettZQG  路  7Comments

student020341 picture student020341  路  9Comments