Scope of sqlite3_update_hook?

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

Scope of sqlite3_update_hook?

Jens Alfke-2
Does a registered sqlite3_update_hook get called when _any_ SQLite connection modifies the database (not just the connection it's registered with)?

If so, then does that include connections in other OS processes? (I'm looking for a way to detect this.)

—Jens
_______________________________________________
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: Scope of sqlite3_update_hook?

Igor Tandetnik-2
On 12/1/2016 7:51 PM, Jens Alfke wrote:
> Does a registered sqlite3_update_hook get called when _any_ SQLite connection modifies the database (not just the connection it's registered with)?

No, only the connection it's registered with.

> If so, then does that include connections in other OS processes? (I'm looking for a way to detect this.)

There's nothing in SQLite that would help with that, to my knowledge.
--
Igor Tandetnik

_______________________________________________
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: Scope of sqlite3_update_hook?

Roger Binns
In reply to this post by Jens Alfke-2
On 01/12/16 16:51, Jens Alfke wrote:
> If so, then does that include connections in other OS processes? (I'm looking for a way to detect this.)

You can't get a callback when other processes change the database for
many reasons.  However it is possible to detect if the database has changed:

  https://www.sqlite.org/pragma.html#pragma_data_version
  https://www.sqlite.org/fileformat2.html#file_change_counter

In theory some combination of file change notification from the OS (eg
inotify) and inspecting the database should come close to meeting your
needs.

Roger


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

signature.asc (169 bytes) Download Attachment