Hi List,

I would like to propose a feature and I believe here is the best place.
Please keep in mind that I am ready to work on a patch for this feature if
needed, but I would like to discuss it here first.

I would like to propose a function (named `sqlite3_stmt_action` for the sake
of discussion) that allow to understand if a specific statement is either a
SELECT, UPDATE, DELETE or INSERT.

Similar functionalities are provided by the authorizer which has a quite
non-ergonomic interface relying on callbacks. Indeed the use of the
authorizer for this is challenging, especially in a multi-threaded
environments with several databases.

The prototype that I am envisioning for the function would be something
like:

    int sqlite3_stmt_action(sqlite3_stmt* stmt)

where the function will return the action code
(https://www.sqlite.org/c3ref/c_alter_table.html) of the statement passed as
input.

We could go even a little further and return something similar to the
authorizer input itself:

   int sqlite3_stmt_action(sqlite_stmt* stmt, const char**, const char**,
const char**, const char**) 

where the extra `const char**` will point to the NULL terminated string --
just like the authorizer -- that indicates tables name and index names where
it makes sense.

This new interface will make possible to even deprecate the authorizer
itself, since it can be implemented on top of `sqlite3_stmt_action` while
being more ergonomic especially in multi-threaded, multi-database
environments. 

This same feature is already been required in the list itself:

o)
http://sqlite.1065341.n5.nabble.com/Determine-type-of-prepared-statement-via-C-Interface-td82075.html

o)
http://sqlite.1065341.n5.nabble.com/Determine-query-type-td83553.html#a83554

o)
http://sqlite.1065341.n5.nabble.com/Distinguish-type-of-statements-td106281.html#a106282
(myself)

even if most of those use cases have been solved using the stmt_readonly
interface.

Thanks for your attention!

Cheers,
Simone



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to