Menu

UPDATE without WHERE: what MySQL's safe-updates mode stops, and what it lets through
📰

UPDATE without WHERE: what MySQL's safe-updates mode stops, and what it lets through

DEV Community: mysql·Dudko Development·2 days ago
#lcZm2IkW
#devtomysql#devto#dev#blocked#table
Long article (1328 words) — no AI summary yet.
Reading 0:00
15s threshold

MySQL error 1175 has its own Stack Overflow question with more than three million views, and most of its answers explain how to switch safe-updates mode off. That's a shame, because the mode does catch the classic accident. It just doesn't catch all of it. And it blocks a fair amount of correct SQL, which is why people switch it off in the first place.

So we ran 22 write statements ( UPDATE , DELETE , a CALL and a TRUNCATE ) against MySQL 8.4 and MariaDB 11.4 with sql_safe_updates = 1 , each one against a fresh 1000-row table, and counted what actually changed.

The test

One table: orders (id PRIMARY KEY, customer_id INDEXED, status, total) , 1000 rows, 100 of them status = 'new' and 20 per customer. A small customers table for the join case. Default server settings, InnoDB, the official Docker images (MySQL 8.4.13 and MariaDB 11.4.13).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.