I develop a library that implements transactions in Postgresql, and at my job we had a weird bug in production with it, when transaction failed not on one of the queries itself, but on
COMMIT, because of something failing in the triggers. Apparently, my library didn't handle this situation the right way.
Obviously, I wanted to replicate this bug in my test suit for the library, but I don't want to bring in all the complicated setup. All the behaviour I need, is that Postgresql has to return an error not to any of the queries inside transaction, but when you try to
COMMIT it. What's the minimal and stable way to achieve it?