cockroachdb / cockroach-go

Packages for go clients.
Apache License 2.0
159 stars 70 forks source link

User requested rollbacks #169

Open mbyio opened 1 year ago

mbyio commented 1 year ago

I have a use case where I want to a dry run of the transaction, and rollback right before returning. The docs are not very clear about the preferred way to achieve this. I decided to return my own error object that I can check for to know that it isn't a real error.

It would be nicer if this library defined a special ErrRollback value, and if it sees that value, rollback the transaction instead of committing, and then also don't return any error to the outer function. It would simplify the error handling code a bit.