Fixes #1645: Added support for nested DB transactions