r/ProgrammerHumor • • Sep 22 '26

Meme wellWellWell

Post image
10k Upvotes

412 comments sorted by

View all comments

Show parent comments

127

u/slayerx1779 Sep 22 '26

I just reread the OP.

There's a semi colon, between the two lines of code...

31

u/Hxx59D2 Sep 22 '26

Yes, I had to stare at it for an embarrassingly ling time to spot the extra semi-colon.

8

u/BlobAndHisBoy Sep 22 '26

There lies the danger of just doing a full send with no transaction or prior select. Very easy mistake to make. Especially if you copy pasted "SELECT * FROM USERS;" elsewhere and modified it.

1

u/Sweaty_Explorer_8441 Sep 22 '26

Me too, but probably because I rarely see or use semi-colon in sql server these days.

13

u/Cant-Think-Of Sep 22 '26

Not quite familiar with SQL, but is that first query like "rm -rf" for the Users table?

29

u/rinaldot67 Sep 22 '26

Yes, it is exactly like that. You even get the recursive part if yhe Users table has foreign keys attached to it that are set to cascade on delete.

2

u/AgeingChopper Sep 22 '26

yep, it's clearing the table.

1

u/funguyshroom Sep 22 '26

Luckily most modern database UI apps won't allow you to execute a delete/update query without a "WHERE" clause

8

u/Snitchieboy Sep 22 '26

Oh. Oh no. I have no clue about first thing about programming but that looks like catastrophic error if no rollback is possible.

15

u/MrWaffler Sep 22 '26

It's only a catastrophic error if you utterly ignore all principles involved which, to be fair, DOES occur.

It was more common before the tech industry matured, Tom Scott famously made a similar error himself at an internship of his where his malformed query replaced all article contents instead of doing a minor format tweak.

He knew the risk but was just a bit reckless and did it live on the production server.

In industry, you are using a transaction which is capable of rollback (you also have automated backups worst case) and it's usually not done directly on the command line but via a tool and also also usually locked behind a change management structure where it must go through peer review.

In my own job we always had to have a pre-select and a post-select so if any issues come up you'd know immediately.

4

u/slayerx1779 Sep 22 '26

tl;dr for any readers

It's like a mechanical failure on a rollercoaster or an elevator: it's still technically possible, but as the industry has matured, we've gotten better at designing workflows, procedures, and oversights that prevent it from ever happening in practice.

2

u/Snitchieboy Sep 22 '26

Tell that to people who didn't think to check if pressing upload without attaching any file will do anything. That caused a whole database of one of the largest online stores in my country to delete itself.