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

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Date: 2017-01-09 22:52:11
Message-ID: 20170109225211.73hntk3zq6opzxth@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Fetter wrote:

> + if (query->commandType == CMD_UPDATE || query->commandType == CMD_DELETE)
> + {
> + /* Make sure there's something to look at. */
> + Assert(query->jointree != NULL);
> + if (query->jointree->quals == NULL)
> + ereport(ERROR,
> + (errcode(ERRCODE_SYNTAX_ERROR),
> + errmsg("%s requires a WHERE clause when the require_where hook is enabled.",
> + query->commandType == CMD_UPDATE ? "UPDATE" : "DELETE"),
> + errhint("To %s all rows, use \"WHERE true\" or similar.",
> + query->commandType == CMD_UPDATE ? "update" : "delete")));
> + }

Per my earlier comment, I think this should use
ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED instead.

I think this should say "the \"require_hook\" extension" rather than
use the term "hook".

(There are two or three translatability rules violations in this
snippet, but since this is an extension and those are not translatable,
I won't say elaborate further.)

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2017-01-09 22:54:05 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Previous Message Alvaro Herrera 2017-01-09 22:38:07 Re: ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type