I think you’re right. An UPDATE would fail, but not an INSERT.
Professional software engineer, musician, gamer, stoic, democratic socialist
- 12 Posts
- 657 Comments
tatterdemalion@programming.devto
Games@lemmy.world•What's a recent game you've tried playing that isn't worth the hype?English
193·2 days agoSkyrim came out 14 years ago.
I believe both
SERIALIZABLEandREPEATABLE READisolation levels would raise an error for this example.And I looked this up: Postgres won’t retry the transaction for you either. Though ultimately I think this a good default behavior.
Sqlite does not have a
SELECT ... FOR UPDATEfeature. The alternative isBEGIN IMMEDIATE.
There is a subtle scenario with read-modify-write transactions in MVCC where SQLite lacks some grace (in my opinion).
In MVCC, transactions work with a point-in-time (read “between atomic transactions”) consistent “read snapshot” of the database.
Consider this example:
- Transaction A begins and reads from table
foo. - Transaction B begins and updates table
foo. - Both transactions commit.
There is no conflict here because these transactions are isolated from each other via the snapshot mechanism. Transaction A’s read snapshot is immutable and will not see any writes from transaction B, even if they are happening concurrently.
Now what happens in this example (from the OP):
- Transaction A begins and reads from table
foo. - Transaction B begins and updates table
foo. - Transaction B commits.
- Transaction A tries to update
foo.
This is a true conflict because both transactions are trying to write to
foo, and transaction A’s writes might be based on what it just read. There is no consistent way for A to proceed, because B already wrote tofoo, invalidating A’s read snapshot.So SQLite handles this by returning an error to A, effectively requiring A to restart the transaction.
There are other ways this could be handled though. The DB could optimistically retry the transaction for you. There is even a special
BEGIN IMMEDIATE;statement that it could use to proactively take a write lock onfooso that the transaction doesn’t get starved by other writers. But SQLite puts all of the responsibility on users to handle this.I’m not an expert, so there could be a very good reason that SQLite works this way, but it feels a bit annoying as a user.
I don’t actually know off the top of my head how PostgresQL handles this particular scenario.
- Transaction A begins and reads from table
tatterdemalion@programming.devtoMicroblog Memes@lemmy.world•Just want to not feel like I'm running on fumesEnglish
37·2 days agoSpent way too long trying to see how oxford comma was relevant.
tatterdemalion@programming.devtoMicroblog Memes@lemmy.world•Which have you perfected?English
4·6 days ago- Saying goodbye to your friend before realizing you both parked next to each other, so you follow not too closely behind so they don’t notice.
tatterdemalion@programming.devtoMicroblog Memes@lemmy.world•Which have you perfected?English
3·6 days agoI just own the mistake and turn around. No one gives a fuck in public.
It’s funnier when you are leaving a social event and you need to change directions in front of the people you were just with.
tatterdemalion@programming.devto
THE POLICE PROBLEM@lemmy.world•Fascist paramilitary crashed into a U.S. citizen on her way to work, then dragged her out and arrested her [10/10/2025, Chicago] (Article)English
1·6 days agoIf they get sued they will claim it was a proper pit maneuver 🙄
tatterdemalion@programming.devto
Programming@programming.dev•Anyone have any favorite diffing tools?
15·8 days agoProbably won’t solve all of your problems, but I like to at least change git’s default pager to
delta.
tatterdemalion@programming.devto
THE POLICE PROBLEM@lemmy.world•Video of fascist paramilitary using excessive force on peaceful protesters in Portland used as evidence during Federal trial this week. Portland Police testified they observed ICE used excessive forceEnglish
33·8 days agoYour average ICE officer has the mind of a 3rd grade bully with a racist dad.
tatterdemalion@programming.devto
News@lemmy.world•Fury as ICE agents fire tear gas on street preparing for children’s Halloween parade
45·14 days agoIf it’s that prevalent, is it really improper at this point?
tatterdemalion@programming.devto
News@lemmy.world•Fury as ICE agents fire tear gas on street preparing for children’s Halloween parade
69·14 days agoLet’s stop referring to AAVE as “improper”.
tatterdemalion@programming.devto
Programming@programming.dev•The Maintainability Mindset: How to Write Code That Stands the Test of Time
7·17 days agoI agree with the article’s ideas, but certain things about the execution bother me.
calculate_order_total_for_customer. I’d just call itcalculate_order_total. It’s clear than any order will have a customer, it’s in the type signature.is_user_eligible_for_discount. I’d call ituser_is_eligible_for_discount. Because inevitably that function is getting called in anifstatement, and you’d rather it read closer to proper English:if user_is_eligible_for_discount: ....- “Designing for Tomorrow”. I agree that dependency injection is a valuable technique, but it’s not always strictly necessary and they seem to say you might as well always do it just in case. That’s counter to YAGNI. Make sure you have an immediate use case, or let future you do it if you end up needing it. It’s not hard to refactor something to inject a dependency.
tatterdemalion@programming.devtoMicroblog Memes@lemmy.world•*Permanently Deleted*English
4·18 days ago“BREAKING” is right. He’s breaking our fucking country.
tatterdemalion@programming.devto
Programming@programming.dev•Do you guys use AI when programming? If so, how?
3·18 days agoAs for actual coding, I use ChatGPT sometimes to write SDK glue boilerplate or learn about API semantics. For this kind of stuff it can be much more productive than scanning API docs trying to piece together how to write something simple. Like for example, writing a function to check if an S3 bucket is publicly accessible. That would have taken me a lot longer without ChatGPT.
In short: it basically replaced google and stack overflow in my workflow, at least as my first information source. I still have to fall back to a real search engine sometimes.
I do not give LLMs access to my source code tree.
Sometimes I’ll use it for ideas on how to write specific SQL queries, but I’ve found you have to be extremely careful with this use case because ChatGPT hallucinates some pretty bad SQL sometimes.
That does not look like steak.
tatterdemalion@programming.devto
Cool Guides@lemmy.ca•200 calories of various foodsEnglish
3·19 days agoI wonder how long I could survive on canola oil.
tatterdemalion@programming.devto
Today I Learned@lemmy.world•TIL the DCIM directory stands for "Digital Camera Images"English
1·19 days agoIt should have been not abbreviated this whole time.












ICE just needs to scan his face with the Racistron 2000 app and it overrides his birth certificate, haven’t you heard?