In many cases, a DELETE or UPDATE not having a WHERE clause (or having it with a condition matching all rows in the table) is a sign of some kind of mistake, leading to accidental data loss, performance issues, producing a lot of dead tuples, and so on. Recently, this topic was again discussed [1]
Attached is a patch implemented by Andrey Boroding (attached) during our today's online session [2], containing a rough prototype for two new GUCs:
- prevent_unqualified_deletes
- prevent_unqualified_updates
Both are "false" by default; for superusers, they are not applied.
There is also another implementation of this idea, in the form of an extension [3], but I think having this in the core would be beneficial to many users.
Looking forward to your feedback.