6

I am using sqlite in a multi process scenario. The sqlite library was compiled with the threadsafe serialized mode (-DSQLITE_THREADSAFE=1).

I want to be notified on datachanges and found sqlite3_update_hook. Every process would register it's own update hook to be notified of changes to the database.

The question now is: If a process A modifies the database, will the update hook of process B be called? Or do hooks only work within the same process or the same connection?

Sadly, the documentation is not very clear about that.

Felix
  • 6,885
  • 1
  • 29
  • 54

1 Answers1

7

The documentation says:

The sqlite3_update_hook() interface registers a callback function with the database connection identified by the first argument

The database connection is a local object; the hook will not fire for any other connection, in this or another process.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • 1
    I read this, but I don't think thats obvious from that part. They should make it a little more explicit. – Felix Jan 22 '18 at 18:20
  • Agree, it should say "invoked whenever a row is updated, inserted or deleted in a rowid table" ON THE SAME CONNECTION – malhal Dec 04 '20 at 20:20