Hacker News new | ask | show | jobs
by werdnapk 520 days ago
What's a real nested transaction? What's postgresql missing? https://www.postgresql.org/docs/current/subxacts.html
3 comments

Transactions are the only composable concurrency control primitive, but this requires that they be nestable.

It’s a key “primitive” missing from almost all high-level programming languages, with the notable exception of some SQL dialects.

Savepoints are not considered legitimately isolated nested transactions.

To the best of my knowledge.

Note: Am not a DBA, merely a full stack dev that has worked with various databases over the years.

Had a fascinating conversation with Claude about this (don't worry about the unhinged personality I gave it with preprompting):

https://gist.github.com/pmarreck/970e5d040f9f91fd9bce8a4bcee...

Pasted it there for brevity here. Also includes an easy way to export a Claude conversation (made with the help of Claude, of course).

LLMs are not a great source for this type of information. This mess in no way articulated in what way savepoints and transactions are different.

Savepoints are fully equivalent to nested transactions with the constraint that only one is concurrently active. This limitation is just from the SQL standard programming model. At least in PostgreSQL implementation it would be reasonably simple to support multiple concurrent subtransactions. They are even called subtransactions internally.

What on Earth are you using as your system prompt!!?
LOL, it's amazing