Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eB15X5F52466; Fri, 1 Dec 2000 00:33:05 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id eB15XMY01987; Fri, 1 Dec 2000 00:33:22 -0500 (EST) To: mhh@mindspring.com cc: "Joel Burton" , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [HACKERS] Re: Rules with Conditions: Bug, or Misunderstanding In-reply-to: <00113022072200.00743@jupiter.hollomon.fam> References: <3A255246.21430.688927F3@localhost> <19579.975544973@sss.pgh.pa.us> <00113022072200.00743@jupiter.hollomon.fam> Comments: In-reply-to Mark Hollomon message dated "Thu, 30 Nov 2000 22:07:22 -0500" Date: Fri, 01 Dec 2000 00:33:22 -0500 Message-ID: <1984.975648802@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200012/1 X-Sequence-Number: 332 Mark Hollomon writes: > On Wednesday 29 November 2000 19:42, Tom Lane wrote: >> Hm. Perhaps the "cannot update view" test is too strict --- it's not >> bright enough to realize that the two rules together cover all cases, >> so it complains that you *might* be trying to update the view. As the >> code stands, you must provide an unconditional DO INSTEAD rule to >> implement insertion or update of a view. > It is in InitPlan, the same place we check to make sure that we are > not changing a sequence or a toast table. (actually initResultRelInfo > called from InitPlan). I gathered from the backend flowchart that this > wasn't called until all rewriting was done. Was I wrong? The rewriting is done, all right, but what's left afterward still has references to the view, because each rule is conditional. Essentially, the rewriter output looks like -- rule 1 if (rule1 condition holds) -- rule 2 applied to rule1 success case if (rule2 condition holds) apply rule 2's query else apply rule 1's query else -- rule 2 applied to rule1 failure case if (rule2 condition holds) apply rule 2's query else apply original query If the system were capable of determining that either rule1 or rule2 condition will always hold, perhaps it could deduce that the original query on the view will never be applied. However, I doubt that we really want to let loose an automated theorem prover on the results of every rewrite ... regards, tom lane