[odb-users] Concerns/Pitfalls Using ODB in a Library?

Brian Coggins becoggins at hotmail.com
Wed Mar 13 08:35:26 EDT 2019


Are there any potential pitfalls to be aware of using ODB in a library whose clients may also be using ODB?

For example, imagine I have a component X which uses ODB to access a SQLite database.  This is built as a static library, libx.a.  This component libx.a would then be linked to several command line tools, one of which, Y, uses ODB to access a MySQL database.

My intention is that the ODB schema for these components will be completely separate, with data passed across an interface that does not expose ODB features.  That is, the ODB pragmas for X are not exposed to the client code at all and the client code will not know about any of X’s uses of ODB, and likewise ODB components from Y are not passed into X.  Thus the ODB compiler invocation for building libx.a will only be aware of X’s schema, while the ODB compiler invocation for building Y will only be aware of Y’s schema.

Of course, when all this is linked together, libodb will see both schema, and ODB instances for both may be active at the same time.  That’s why I’m asking this question of whether there are any potential problems.

One issue I thought of is odb::session, which is thread-specific.  If X needs to use an odb::session, presumably it should do this on a separate thread so that there are no potential conflicts with odb::session instances in Y?  Are there other concerns?  Will odb::schema_catalog handle things correctly if X and Y both invoke it?

Thanks,
Brian







More information about the odb-users mailing list