Pseudo-Nested Database Transaction

@p.colbert I have tried using savepoints in the past, but I ended up with code that was difficult to maintain and error prone. If I remember, using endpoints still requires one transaction start and one end, so you still risk to start another transaction or to end the transaction twice.

When I split the code into smaller functions I find it easier to create worker functions that work on the tables without worrying about transactions and http endpoints / callable functions that decide whether the worker functions should be wrapped in a transaction or not.