Re: updatable/deletable terminology - Mailing list pgsql-hackers
From | Dean Rasheed |
---|---|
Subject | Re: updatable/deletable terminology |
Date | |
Msg-id | CAEZATCXRe_kPk7t3ackSUZPsVcoPJahqUNXh9Sx5MUpqcO944g@mail.gmail.com Whole thread Raw |
In response to | Re: updatable/deletable terminology (Peter Eisentraut <peter_e@gmx.net>) |
Responses |
Re: updatable/deletable terminology
(Peter Eisentraut <peter_e@gmx.net>)
|
List | pgsql-hackers |
On 13 August 2013 00:01, Peter Eisentraut <peter_e@gmx.net> wrote: > On Wed, 2013-08-07 at 21:19 -0400, Peter Eisentraut wrote: >> To make the view updatable, provide an unconditional ON DELETE DO >> INSTEAD rule or an INSTEAD OF DELETE trigger. >> >> I think it's a bit strange to claim that adding a DELETE rule/trigger >> makes a view *updatable*. I suspect someone thought they would apply >> the term "updatable" in an SQL standard sense, but that seems >> backwards, >> because you get to these error conditions exactly because the view as >> defined was not Updatable(tm). > > After some consideration, I think the best fix here is to revert to the > 9.2 wording > > "You need an unconditional ON DELETE DO INSTEAD rule or an INSTEAD OF > DELETE trigger." > That's how I had it in the patch I submitted, but perhaps it should be "You need an INSTEAD OF DELETE trigger or an unconditional ON DELETE DO INSTEAD rule." to reflect the fact that the docs now recommend triggers ahead of rules. > The addition of the term "updatable" was simply wrong here. > In the docs we're using "udpatable" as a generic term meaning support for INSERT, UPDATE and DELETE, and we're not using the terms "insertable" or "deletable". Also the error detail that immediately precedes this hint uses the term "updatable". For example: CREATE VIEW one AS SELECT 1 AS val; INSERT INTO one VALUES (1); ERROR: cannot insert into view "one" DETAIL: Views that do not select from a single table or view are not automatically updatable. HINT: To make the view insertable, provide an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger. so if there is a problem there, it's in the mix of terminology between the detail and the hint ("updatable" vs "insertable"). But at least in this case the hint is technically correct -- adding such a rule or trigger would make the view insertable. In the UPDATE and DELETE cases, following the hint's suggestion and adding just an UPDATE rule or trigger, or just a DELETE rule or trigger, wouldn't actually make the view updatable according to our current interpretation of the spec, which would require both. So on balance I think you're right, and it would be better to simply say: ERROR: cannot insert into view "one" DETAIL: Views that do not select from a single table or view are not automatically updatable. HINT: You need an INSTEAD OF INSERT trigger or an unconditional ON INSERT DO INSTEAD rule. Regards, Dean
pgsql-hackers by date: