Add debugging hooks to database api