transactions
A constraint failed halfway through a multi step change Half written data is worse than no data That is why transactions exist
the shape
BEGIN;
INSERT INTO targets (host, port, severity) VALUES ('temp.local', 1, 'low');
ROLLBACK;
After the rollback the row count is unchanged The insert happened inside a boundary that could be discarded
commit
COMMIT makes the changes permanent
Until then another connection may not see them, depending on isolation level
Read the engine documentation for the exact rules
savepoint
SAVEPOINT creates a nested boundary
ROLLBACK TO SAVEPOINT undoes work after that marker without discarding everything
Useful in long migrations
Practical rule
One logical change , one transaction Do not wrap an entire import in one boundary unless you are happy losing all of it on the last bad row
Next
Reuse and speed in 08 views and indexes
Posted