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

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, 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: 2016-09-30 18:19:07
Message-ID: 20160930181907.GA485070@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro wrote:
> On Thu, Sep 29, 2016 at 6:19 PM, David Fetter <david(at)fetter(dot)org> wrote:

> > Please find attached the next revision.
>
> I'm not sold on ERRCODE_SYNTAX_ERROR. There's nothing wrong with the
> syntax, since parsing succeeded. It would be cool if we could use
> ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED, though I'm not sure
> what error class 38 really means. Does require_where's hook function
> count as an 'external routine' and on that basis is it it allowed to
> raise this error? Thoughts, anyone?

I don't think it's appropriate to use class 38. "Part 1: Framework"
saith
An external routine is an SQL-invoked routine that references some
compilation unit of a specified programming language that is outside
the SQL-environment. The mechanism and time of binding of such a
reference is implementation-defined.
It seems to me that what matters here is that what the user is doing is
an UPDATE, and the restriction is about it's SQL-written WHERE clause;
not whether require_where module is written in SQL or not (which seems
irrelevant to me). So this is not "external" IMO.

But there's class 2F "SQL routine exception" which has 003 for
"prohibited SQL-statement attempted" ... oh, and we even have that in
errcodes.txt as ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED. Seems
apropos.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2016-09-30 19:06:11 Re: pgbench more operators & functions
Previous Message Stephen Frost 2016-09-30 18:11:04 Re: COPY command with RLS bug