Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Julien Rouhaud <julien.rouhaud@dalibo.com>
From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: David Fetter <david@fetter.org>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>,
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>,
PostgreSQL Development <pgsql-hackers@postgresql.org>
Date: 2016-09-30T19:32:29Z
Lists: pgsql-hackers
On 30/09/2016 21:12, David Fetter wrote: > On Fri, Sep 30, 2016 at 06:37:17PM +0200, Julien Rouhaud wrote: >> On 30/09/2016 05:23, Thomas Munro wrote: >>> >>> It would be really nice to be able to set this to 'Ready for >>> Committer' in this CF. Do you want to post a v6 patch or are you >>> happy for me to ask a committer to look at v5 + these three >>> corrections? >> >> I just looked at the patch, and noticed that only plain DELETE and >> UPDATE commands are handled. Is it intended that writable CTE without >> WHERE clauses are not detected by this extension? I personally think >> that wCTE should be handled (everyone can forget a WHERE clause), but if >> not it should at least be documented. > > You are correct in that it should work for every unqualified UPDATE or > DELETE, not just some. Would you be so kind as to send along the > tests cases you used so I can add them to the patch? > Given your test case, these queries should fail if the related require_where GUCs are set (obviously last one should failed with either of the GUC set): WITH d AS (DELETE FROM test_require_where) SELECT 1; WITH u AS (UPDATE test_require_where SET t = t) SELECT 1; WITH d AS (DELETE FROM test_require_where), u AS (UPDATE test_require_where SET t = t) SELECT 1; -- Julien Rouhaud http://dalibo.com - http://dalibo.org