In working on a Python wrapper around virtual tables, I thought it might be
beneficial if SQLite provided an official C API for creating simple
table-valued functions. The wrapper could build on the existing virtual
table APIs and would consist of:

* user supplied list of parameters, which would be converted to HIDDEN
columns in a virtual table.
* user supplied list of column names, which would constitute the return
values of the table-valued function
* user supplied initialization function which would accept the parameters
passed, i.e. SELECT * FROM user_func(p1, p2, p3), the init function would
receive (p1, p2, p3).
* user supplied iterate function which would accept a zero-based index and
a result context, returning 1 to indicate EOF and 0 to indicate more
results exist.

I think this might lead to a larger ecosystem of quality open-source
table-valued functions. Given the fact that creating even a simple vtable
is cumbersome, providing an API that required the bare minimum seems like a
good idea to me.

Thoughts?

PS if you're curious about the Python wrapper, I posted on it a day or two
ago.

Reply via email to