Rule uses wrong value

From: Jeff Boes <jboes(at)qtm(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Rule uses wrong value
Date: 2004-10-12 12:50:48
Message-ID: 1097585449.HGcFCga3WNPZ8aYh9EQG3A@teranews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

(I thought I posted this yesterday from Google Groups, but it doesn't
appear to have "taken".)

I'm having a problem with a rule designed to log new rows inserted into
one table. The base table is very volatile; rows are inserted from
various places, including both application code and triggers. Then they
are read out by another application (the table is used as a job queue)
and deleted. My rule attempts to re-record the rows in another table for
audit and debug purposes.

Here's the important bits of the base table:

Table "public.job_queue"
Column |Type |Modifiers

--------+--------+------------------
job_id |integer |not null default
nextval('"job_queue_job_id_seq"'::text)
...

The rule looks like this:

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

It appears that the rule is inserting the row copies into
job_queue_trace with a job_id value that is one higher than the job_id
from the original row. Almost as though it was re-evaluating the
sequence ...

--
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes(at)qtm(dot)net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2004-10-12 13:11:20 Re: 'NOW' in UTC with no timezone
Previous Message Karsten Hilbert 2004-10-12 12:43:51 Re: 'NOW' in UTC with no timezone