SQLite update hook in a multi process application
Asked Answered
D

1

7

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.

Denison answered 22/1, 2018 at 10:0 Comment(0)
M
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.

Miniskirt answered 22/1, 2018 at 17:49 Comment(2)
I read this, but I don't think thats obvious from that part. They should make it a little more explicit.Denison
Agree, it should say "invoked whenever a row is updated, inserted or deleted in a rowid table" ON THE SAME CONNECTIONFley

© 2022 - 2024 — McMap. All rights reserved.