Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple auth/profile etc #502

Open
rogerbinns opened this issue Dec 2, 2023 · 0 comments
Open

Allow multiple auth/profile etc #502

rogerbinns opened this issue Dec 2, 2023 · 0 comments

Comments

@rogerbinns
Copy link
Owner

rogerbinns commented Dec 2, 2023

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:

  • It is common to remove callbacks while in a callback, so mutating the list while iterating it must work. The simplest thing is to make name and callback be NULL on deletion an never resize the list to be smaller.
  • Use PyObject_RichCompareBool with Py_EQ to see if name matches on register/unregister
  • They should be included during tp_traverse
@rogerbinns rogerbinns changed the title Connection hook to allow multiple auth/profile etc Allow multiple auth/profile etc May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant