Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparently support nested transactions in withTransaction #1

Open
rightfold opened this issue Dec 22, 2016 · 1 comment
Open

Transparently support nested transactions in withTransaction #1

rightfold opened this issue Dec 22, 2016 · 1 comment

Comments

@rightfold
Copy link
Owner

This can be implemented using a WeakMap, mapping connections to nesting counts.

@akheron
Copy link
Contributor

akheron commented Nov 16, 2018

After #29 has been merged, this can be achieved by chaning the library monad to e.g.

newtype PG a = StateT (Maybe Int) (ExceptT PGError Aff) a

with the following rules for the state:

  • Nothing -> not in a transaction
  • Just 0 -> in a top-level transaction (BEGIN/ROLLBACK/COMMIT)
  • Just n -> in n'th nested transaction (SAVEPOINT savepoint-n/ROLLBACK TO SAVEPOINT savepoint-n/RELEASE SAVEPOINT savepoint-n)

This change would also require us to add a function

runPG :: forall a. PG a -> Aff (Either PGError a)

as runExceptT alone wouldn't be enough anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants