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

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: (view raw, whole thread or download thread mbox)
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

			regards, tom lane

In response to

pgsql-bugs by date

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

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