Probably the first one, as long as you're exporting only during build time.
The problem here is that while sys-libs/db is slotted, due to various reasons (many going back to times where slotting was far less common), it's done in a very crude way, mainly due to issues specific for this package (like databases generated by the lib being incompatible between versions).
Ebuilds using this package tend to have special fixes for this slotting. Actually, those that don't are even more annoying from maintainer's point of view, as they tend to have a random selection of the versions, they check for. That's one of the reasons why >=5.0 slots are still masked, years since release and getting a masked ebuild into the tree.