Rule is using wrong values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff  Boes

    #1

    Rule is using wrong values

    I have a rule defined on a table, to log rows from that table (which
    tend to get read elsewhere and quickly deleted) into another table for
    audit. It looks like this:

    rul_job_queue_t race_log AS ON INSERT TO job_queue
    DO INSERT INTO job_queue_trace (job_id, ...)
    VALUES (new.job_id, ...)

    The table on which the rule is defined looks something like this:

    Column |Type |Modifiers
    -------+--------+--------------------------------------------------------
    job_id |integer |not null default
    nextval('"job_q ueue_job_id_seq "'::text)
    ....

    The problem is that rows appearing in job_queue_trace (the shadow audit
    table) end up with a value of job_id that is off by one (one higher)
    than the actual row; it's as though the sequence was being evaluated
    again, instead of taking the value from the "new.job_id " expression.

Working...