Transactions and Error Handling in PostgreSQL
Jason Myers
Instructor
Isolation Level | Dirty Read | Nonrepeatable Read | Phantom Read | Serialization Anomaly |
---|---|---|---|---|
Read Uncommitted | Protected (PostgreSQL) | vulnerable | vulnerable | vulnerable |
Read Committed | Protected | vulnerable | vulnerable | vulnerable |
Repeatable Read | Protected | Protected | Protected (PostgreSQL) | vulnerable |
Serializable | Protected | Protected | Protected | Protected |
START TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT COUNT(*) FROM cookies WHERE name = 'lemon drop';
-- Cookie 6 has been added in an external transaction.
SELECT COUNT(*) FROM cookies WHERE name = 'lemon drop';
COMMIT;
Statement results
START TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT COUNT(*) FROM cookies WHERE name = 'lemon drop';
-- Cookie 6 has been added in an external transaction.
SELECT COUNT(*) FROM cookies WHERE name = 'lemon drop';
COMMIT;
Statement results
Transactions and Error Handling in PostgreSQL