Re: Change in rule behavior? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Change in rule behavior?
Date
Msg-id 5691.1006730227@sss.pgh.pa.us
Whole thread Raw
In response to Change in rule behavior?  (Sergio Pili <sergiop@sinectis.com.ar>)
List pgsql-hackers
Sergio Pili <sergiop@sinectis.com.ar> writes:
> psql:sql/rd_ri/bug_upd.sql:11: ERROR:  Rules with WHERE conditions may
> only have SELECT, INSERT, UPDATE, or DELETE actions
> Why was changed?
> Is it possible to maintain the previous behavior  with my correction?

Because it didn't work.  Your patch might prevent a coredump, but it
doesn't make the rule work correctly.  See the comment on the error
message:
           /*            * We cannot support utility-statement actions (eg NOTIFY)            * with nonempty rule
WHEREconditions, because there's no way            * to make the utility action execute conditionally.            */
      if (top_subqry->commandType == CMD_UTILITY &&               stmt->whereClause != NULL)               elog(ERROR,
"Ruleswith WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions");
 

What actually happened in your patched 7.1 was that the NOTIFY message
was sent regardless of whether the WHERE condition was true or not.
If you want that behavior, it's easy enough to get: put the NOTIFY in a
separate rule that has no WHERE.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Call for objections: deprecate postmaster -o switch?
Next
From: Tom Lane
Date:
Subject: Re: Bug in pg_get_ruledef?