rogerbinns / apsw

Another Python SQLite wrapper
https://rogerbinns.github.io/apsw/
Other
715 stars 96 forks source link

Allow multiple auth/profile etc #502

Open rogerbinns opened 7 months ago

rogerbinns commented 7 months ago

Currently there can only be one profiler, one authorizer, one collation needed callback etc.

This is especially problematic with the profiler because apswtrace needs it, but if any other code installs a tracer then apswtrace sees nothing.

The simplest approach would be to add a name parameter when they are registered/unregistered. The default is None. Internally APSW would keep a list for the callback and invoke the appropriate ones.

As an example the sqlite3_tracev2 would be a array of:

PyObject *name;
unsigned mask;
PyObject *callback;

Then when a trace event fires the list is traversed and any whose mask matches the event is called.

Some additional things: