-
Hello! I'd love to use grdb for my personal project. If I'm not mistaken, grdb makes use of the preupdate_hook extension of sqlite. I wouldn't dare ask to make changes to the codebase proper to get around this obstacle (that is, for me). I understand using the session api is a rather rare use case. Rather, I would like to ask those who are knowledgeable with the internals, to give me some direction/pointers/tips on how I could, perhaps using custom swift flags and/or some other mechanism and where I have to look, to disable preupdate_hook usage, along with, of course, all the functionality it provides so that I can fork grdb. I'm aware of the trade-offs and what will be lost but I don't have much choice in the matter. Thanks in advance for any help anyone can provide! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hello @dj-jqpub, You'll find a similar question in #1608 Unless I'm mistaken, the pre-update hook is not used by default in GRDB. But one can't reasonably use the pre-update hook without the commit and rollback hooks, owned by GRDB. I should also mention the authorization hook. It makes it possible to discard update events that are rollbacked in an intermediate savepoint. Of course GRDB owns it as well. If you want to install your own hooks with the SQLite C interface, you do indeed find GRDB on your way. Are we on the same track? The root problem is that SQLite APIs do not allow the installation of several hooks. All libraries that need a given hook are, to be short, mutually incompatible. There is currently no way to build GRBD without its hooks. The work needed to perform a clean cut (i.e. remove or adapt all public and internal apis that depend on those hooks) has to be done from zero (well, it is already done for SQLITE_ENABLE_PREUPDATE_HOOK). Honestly I'm not sure the authorization hook can be removed. It is used, for example, in the cancellation handling of I can answer specific questions if you need help. Meanwhile, GRDB exposes Swift APIs for accessing the pre-update hook: https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/transactionobserver. However, building your personal project on top of them would introduce a hard dependency on GRDB. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I should clarify, I don't want to install my own hooks, I'd like to wrap the sqlite session extension api (which makes use of pre update hook). Appreciate the quick reply and keep up the great work on GRDB! |
Beta Was this translation helpful? Give feedback.
Hello @dj-jqpub,
You'll find a similar question in #1608
Unless I'm mistaken, the pre-update hook is not used by default in GRDB. But one can't reasonably use the pre-update hook without the commit and rollback hooks, owned by GRDB.
I should also mention the authorization hook. It makes it possible to discard update events that are rollbacked in an intermediate savepoint. Of course GRDB owns it as well.
If you want to install your own hooks with the SQLite C interface, you do indeed find GRDB on your way. Are we on the same track?
The root problem is that SQLite APIs do not allow the installation of several hooks. All libraries that need a given hook are, to be short, mutually incompatible.