only commit in case a transaction is active

fixes #9806 

@karlitschek @craigpg setting this to 7.0.1

@icewind1991 @PVince81 please review - thx