"PostgreSQL Bugs List" <[EMAIL PROTECTED]> writes: > [ double evaluation of serial-column default with ] > > create rule silly_insert_r as on insert to silly do > insert into action (item_id,whence) > values (new.id,'now');
The standard answer to this is "use a trigger, not a rule, to copy inserted or updated data to another table". A rule is basically a macro and as such has the usual multiple-evaluation hazards that all C programmers are familiar with :-(. There are times when this behavior is just what you want, but not when trying to copy the results of volatile expressions. People are often scared away from triggers because of the apparent notational complexity. This is too bad, because conceptually triggers are *much* simpler than rules. Someday I'd like to rewrite the docs so that triggers are discussed first and made to look like the simpler facility ... regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match