Search code examples
sqlpostgresqlsavepoints

In SQL, what happens if you try to rollback to a savepoint from another user?


If USER1 does some work, adds a savepoint SP1 but does not commit.

Then, USER2 does some other work, and tries to rollback to SP1.

Would there be an error? Thanks


Solution

  • Yes, there would be an error.

    A savepoint is only visible and valid inside the transaction that created the savepoint.

    So a transaction can only rollback to a savepoint that was created in that transaction.