Re: Rulese Bug: Instead of reporting incorrect insert count.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Shawn Chasse" <schasse(at)exagrid(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Rulese Bug: Instead of reporting incorrect insert count.
Date: 2008-03-10 19:37:10
Message-ID: 21645.1205177830@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Shawn Chasse" <schasse(at)exagrid(dot)com> writes:
> According to the documentation:

> "If there is any unconditional INSTEAD rule for the query, then the
> original query will not be executed at all. In this case, the server
> will return the command status for the last query that was inserted by
> an INSTEAD rule (conditional or unconditional) and is of the same
> command type (INSERT, UPDATE, or DELETE) as the original query. If no
> query meeting those requirements is added
> by any rule, then the returned command status shows the original query
> type and zeroes for the row-count and OID fields."

> My understanding (and that of at least several others) indicates that
> only those conditional rules that are true should be added to the query
> plan. So if there are 3 rules, and 2 of them are false and only one is
> true, then the rule that met the "WHERE" criteria should be the only one
> added to the query plan.

This is mere wishful thinking, I'm afraid. You're supposing that the
WHERE clause is evaluated to decide whether to insert the rule query
into the plan, which is not the case --- it could not work in any
situation where the WHERE clause depends on runtime data. All rules
applicable to the query type are inserted in the plan, and their WHERE
clauses are applied at query runtime; as indeed is described in the
manual.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Giovani Murilo Dantas Correa 2008-03-10 20:58:02 BUG #4023: The transaction control does not work for sequences
Previous Message Alvaro Herrera 2008-03-10 15:25:06 Re: BUG #4020: RFE: have way to log autovacuum activity