How does errorLogCallback interrupt my running program?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How does errorLogCallback interrupt my running program?

test user
Hello,

The error log takes a callback which is called when an error occurs from
any SQLite FFI function:
https://www.sqlite.org/errlog.html

How does this interrupt my program whilst its running? If my program is
busy, does it wait until the current function has completed and the process
is idle?

Also if I am using threads, do I need a callback handler per thread for all
file connections on that thread? Or can I just use one error handler for
all descendant threads of the root process?

Thanks.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How does errorLogCallback interrupt my running program?

Clemens Ladisch
test user wrote:
> The error log takes a callback which is called when an error occurs from
> any SQLite FFI function:

What exactly do you mean with "FFI"?  You did not mention any other language.

> How does this interrupt my program whilst its running?

As a library, SQLite is part of your program.  It just calls the callback
while sqlite3_exec()/sqlite3_step() etc. is being executed.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How does errorLogCallback interrupt my running program?

test user
By FFI I mean any of the public SQLite C functions exported from via FFI.

Ok thanks, this makes sense the error callback is called whilst SQLite is
executing exec/step.

Do I need on callback per thread?

On Sun, Aug 11, 2019 at 4:31 PM Clemens Ladisch <[hidden email]> wrote:

> test user wrote:
> > The error log takes a callback which is called when an error occurs from
> > any SQLite FFI function:
>
> What exactly do you mean with "FFI"?  You did not mention any other
> language.
>
> > How does this interrupt my program whilst its running?
>
> As a library, SQLite is part of your program.  It just calls the callback
> while sqlite3_exec()/sqlite3_step() etc. is being executed.
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How does errorLogCallback interrupt my running program?

Keith Medcalf

On Sunday, 11 August, 2019 10:31, test user <[hidden email]> wrote:

>By FFI I mean any of the public SQLite C functions exported from via
>FFI.

>Ok thanks, this makes sense the error callback is called whilst
>SQLite is executing exec/step.

>Do I need on callback per thread?

No, the callback configuration is per process (the callback address is stored in per process data).

That said, the callback is executed synchronously inline by the sqlite3 code detecting the error, so the callback function is executed on whatever thread encountered the error.  You cannot receive multiple simultaneous callbacks on the same thread (since one thread can only execute one instruction at a time).

I do not see anything in the sqlite3_log code which would serialize callbacks per process.  This means that you may, in a multithreaded program where multiple threads are active in the sqlite3 library code simultaneously (such as one connection per thread), receive callbacks simultaneously on multiple threads.  This means that if your implementation or the callback function manipulates per process data, that data will have to be protected against concurrent mutation by multiple threads.

>On Sun, Aug 11, 2019 at 4:31 PM Clemens Ladisch <[hidden email]>
>wrote:
>
>> test user wrote:
>> > The error log takes a callback which is called when an error
>occurs from
>> > any SQLite FFI function:
>>
>> What exactly do you mean with "FFI"?  You did not mention any other
>> language.
>>
>> > How does this interrupt my program whilst its running?
>>
>> As a library, SQLite is part of your program.  It just calls the
>callback
>> while sqlite3_exec()/sqlite3_step() etc. is being executed.



--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users