News for hackers. Stuff that matters.
Re:SQL: Incorrect by Construction by tcp_handshaker on Tuesday May 12, 2026 @06:26PM (#48115423)
Post shows beginner T-SQL under SQL Server lock-based READ COMMITTED defaults, then generalizes that to "SQL is incorrect by construction."

The conclusion should be much narrower. For the same row double debit, true SNAPSHOT isolation, enabled and actually used, not just RCSI, turns the loser into an update-conflict/retry. The idiomatic SQL fix is a conditional debit UPDATE, row-count check, constraints, and one transaction for the transfer.

The deadlock example is also overstated. SQL Server detects the cycle, rolls back a victim, returns error 1205 [1], and the application is expected to retry. Microsoft has shitty defaults and the author turned it into a much broader claim ..

[1] - "Your transaction (process ID #...) was deadlocked on {lock | communication buffer | thread} resources with another process and has been chosen as the deadlock victim. Rerun your transaction"

"Deadlocks guide" - https://learn.microsoft.com/en-us/sql/relational-databases/s...

Re:SQL: Incorrect by Construction by JohnyTex on Friday May 15, 2026 @09:20AM (#48148253)
If the failure mode of the "correct" solution is to exit the program, I stand by my assertion that it is incorrect by construction.