The following bug has been logged online: Bug reference: 1175 Logged by: Joe Carlson
Email address: [EMAIL PROTECTED] PostgreSQL version: 7.3.2 Operating system: linux Description: insert rule action with defaults Details: I realize this was discussed 2 years ago; the issue is how to deal with default columns in rule-based actions. The issue I have is tracking inserts or updates to a collection of tables using a rule which will insert a transaction record for that operation. This illustrates the behavior: create table silly (id serial, item varchar(20)); create table action (item_id integer, whence datetime); create rule silly_insert_r as on insert to silly do insert into action (item_id,whence) values (new.id,'now'); insert into silly (item) value ('first'); select * from silly; id | item ----+------- 2 | first (1 row) select * from action; item_id | whence ---------+------------------------ 1 | 2004-06-21 16:24:51-07 (1 row) So, in the rule expansion, the default column for id is getting evaluation in a call to nextval, but this value is not being used in the insert to silly. One (namely, I) would like to have the same id values without the second call to nextval. I realize there are different ways to implement this behavior as a workaround; but these become quite complex in my real application. It would be good to have the rule expansion happen after default columns were identified and set rather than being specified in separate operations. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster