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

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: [HACKERS] PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Дата
Msg-id CAB7nPqRh5mK+_zcfLf1UypqowsKrMz8atcCbQr2Eh7o8mqSqAA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE  (David Fetter <david@fetter.org>)
Ответы Re: [HACKERS] PoC: Make it possible to disallow WHERE-less UPDATEand DELETE  (David Fetter <david@fetter.org>)
Re: [HACKERS] PoC: Make it possible to disallow WHERE-less UPDATEand DELETE  (David Fetter <david@fetter.org>)
Список pgsql-hackers
On Sun, Jan 1, 2017 at 12:34 PM, David Fetter <david@fetter.org> wrote:
> I've rolled your patches into this next one and clarified the commit
> message, as there appears to have been some confusion about the scope.

Not all the comments have been considered!

Here are some example..

=# set require_where.delete to on;
SET
=# copy (delete from aa returning a) to stdout;
ERROR:  42601: DELETE requires a WHERE clause when
require_where.delete is set to on
HINT:  To delete all rows, use "WHERE true" or similar.
LOCATION:  require_where_check, require_where.c:42

COPY with DML returning rows are correctly restricted.

Now if I look at WITH clauses...
=# with delete_query as (delete from aa returning a) select * from delete_query;a
---
(0 rows)
=# with update_query as (update aa set a = 3 returning a) select *
from update_query;a
---
(0 rows)
Oops. That's not cool.

CTAS also perform no checks:
=# create table ab as with delete_query as (delete from aa returning
a) select * from delete_query;
SELECT 0

Is there actually a meaning to have two options? Couldn't we leave
with just one? Actually, I'd just suggest to rip off the option and
just to make the checks enabled when the library is loaded, to get a
module as simple as passwordcheck.

--- /dev/null
+++ b/contrib/require_where/data/test_require_where.data
@@ -0,0 +1,16 @@
+Four
There is no need to load fake data as you need to just check the
parsing of the query. So let's simplify the tests and remove that.

Except that the shape of the module is not that bad. The copyright
notices need to be updated to 2017, and it would be nice to have some
comments at the top of require_where.c to describe what it does.
-- 
Michael



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: [HACKERS] proposal: session server side variables
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: [HACKERS] Fixing pgbench's logging of transaction timestamps