Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Re: Rules with Conditions: Bug, or Misunderstanding

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mhh(at)mindspring(dot)com
Cc: "Joel Burton" <jburton(at)scw(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [HACKERS] Re: Rules with Conditions: Bug, or Misunderstanding
Date: 2000-12-01 05:33:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-sql
Mark Hollomon <mhh(at)mindspring(dot)com> 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
			apply rule 1's query
		-- rule 2 applied to rule1 failure case
		if (rule2 condition holds)
			apply rule 2's query
			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

In response to


pgsql-hackers by date

Next:From: Don BaccusDate: 2000-12-01 05:39:14
Subject: Re: beta testing version
Previous:From: The Hermit HackerDate: 2000-12-01 04:00:12
Subject: Re: beta testing version

pgsql-sql by date

Next:From: Robert B. EasterDate: 2000-12-01 06:32:12
Subject: Re: Help with Procedures in pgsql
Previous:From: Tom LaneDate: 2000-12-01 04:46:18
Subject: Re: pltcl: missing close-brace

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group