Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Date: 2016-07-21 13:59:06
Message-ID: 2d045a24-a09d-ae91-0114-9e775aec3f09@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 07/21/2016 06:49 AM, Tom Lane wrote:
> David Fetter <david(at)fetter(dot)org> writes:
>> Please find attached a patch which makes it possible to disallow
>> UPDATEs and DELETEs which lack a WHERE clause. As this changes query
>> behavior, I've made the new GUCs PGC_SUSET.
>
>> What say?
>

-1

> -1. This is an express violation of the SQL standard, and at least the
> UPDATE case has reasonable use-cases. Moreover, if your desire is to have
> training wheels for SQL, there are any number of other well-known gotchas
> that are just as dangerous, for example ye olde unintentionally-correlated
> subselect:
> https://www.postgresql.org/message-id/20160714135233.1410.92538%40wrigleys.postgresql.org
>

Yes but I used to teach a weak long class on relational databases using
PostgreSQL. The entire week I would iterate over and over and over that
you never use an UPDATE or DELETE without a transaction. Toward the end
of the class we would being do problem sets that included UPDATE and
DELETE. Guess how many would trash their data because they didn't use a
WHERE clause AND didn't use a transaction? 50%

These weren't kids, these weren't neophytes to technology. These were
professionals, many of them programmers (PICK).

> I wouldn't have any objection to an extension that enforces rules like
> these, but I don't think it belongs in core.

I agree it doesn't need to be in core.

JD

>
> regards, tom lane
>
>

--
Command Prompt, Inc. http://the.postgres.company/
+1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Teodor Sigaev 2016-07-21 15:20:37 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Previous Message Tom Lane 2016-07-21 13:49:33 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE