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';

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



-----Urspr√ľngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Ulrich Telle
Gesendet: Dienstag, 06. Februar 2018 09:34
An: sqlite-users@mailinglists.sqlite.org
Betreff: [EXTERNAL] [sqlite] How to parameterize a loadable extension at runtime

I have implemented a loadable SQLite extension. The behaviour of the extension 
can be configured by setting various parameters. Currently I select the 
parameter settings at compile time. However this is not very flexible. I would 
like to be able to modify the parameters at runtime.

The most logical way would be to add extension-specific pragmas, but it doesn't 
seem to be possible to intercept the pragma handling of SQLite without 
modifying the SQLite source.

Another possibility would be to add a user-defined function for the 
configuration of the extension that could be called from a SELECT
statement:

SELECT myextension_config('param-name', 'param-value');

Is there a better (or even recommended) way how to accomplish such 
parameterization at runtime?

Regards,

Ulrich
--
E-Mail privat:  ulrich.te...@gmx.de
World Wide Web: http://www.telle-online.de


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


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to