> Hick Gunter wrote:
>
> You can pass parameters to the xCreate function in the CREATE VIRTUAL TABLE 
> statement, if the setting you desire remains unchanged during the lifetime of 
> the table.
> 
> CREATE VIRTUAL TABLE <name> USING <module> [ ( <parameter>,...) ];
> 
> You can declare hidden fields in the call to sqlite3_declare_vtab() call 
> within your xCreate function if the setting you desire are specific to a 
> query. The constraint will be passed to your xBestIndex function, and (if the 
> query plan is selected) the value will be passed to your xFilter function.
> 
> CREATE VIRTUAL TABLE with_foo USING handle_foo;
> 
> Sqlite3_declare_vtab(db_hanlde, "CREATE TABLE x ( ..., foo integer hidden, 
> ...);");
> 
> SELECT .... FROM with_foo wf .... WHERE wf.foo = 'bar';

I have to admit that I don't have much experience with the vtable concept. My 
extensions consist of a set of functions that can be used in SQL statements. 
During a single database connection the behaviour of the functions will be 
deterministic, but the user should be able to set certain initialization 
parameters.

Dominique Devienne proposed in his answer to implement a vtable with a fixed 
set of rows for the configuration parameters. That approach seems to be a bit 
simpler to implement than a fully fledged vtable solution.

> Or, for "none of the above", create a user defined function that will handle 
> storing/retrieving the settings and provide a C interface for your virtual 
> table implementation to access them directly
> 
> SELECT param('foo','bar') AS p;
> p
> ----------
> NULL
> 
> SELECT param('foo') AS foo;
> foo
> ---------
> bar

Yes, that's the approach I already mentioned in my original post. Adding a C 
interface is probably a good idea, too. However, setting parameters should be 
possible without calling a C interface function, for example, if a user loads 
the extension from the default SQLite shell coming with the SQLite distribution.

I would have preferred a more PRAGMA like syntax, but that could probably be 
called "syntactic sugar" - a SELECT with a user-defined function will work and 
the syntax is simple enough.

Regards,

Ulrich
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to