A bug in Vault Banking's transfer system has been deducting money from sender accounts but failing to credit receivers when the server crashes mid-operation. The result: money disappears. Your job is to wrap the transfer in an atomic transaction so it either fully completes or fully rolls back โ no partial states.
BEGIN;SAVEPOINT before_debit;UPDATE accounts SET balance = balance - 1500 WHERE id = 'ACC-10042';SAVEPOINT after_debit;UPDATE accounts SET balance = balance + 1500 WHERE id = 'ACC-10091';COMMIT;Run BEGIN and the first UPDATE, then click "SIMULATE SERVER CRASH" in the Accounts window. The debit should be rolled back automatically, leaving both accounts unchanged. This is how atomicity protects data integrity.
SAVEPOINT name; โ mark a point to return toROLLBACK TO SAVEPOINT name; โ undo back to that pointRELEASE SAVEPOINT name; โ discard the savepoint