Re: rule which unpredictable modify a sequence number

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Armand Turpel <armand(dot)turpel(at)googlemail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: rule which unpredictable modify a sequence number
Date: 2010-10-23 16:28:51
Message-ID: 13714.1287851331@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Armand Turpel <armand(dot)turpel(at)googlemail(dot)com> writes:
> I have a problem with a rule which unpredictable modify a sequence
> number. When I add a new table entry, the new id_keyword hasnt the value
> as expected. ex.: 1000000000000000, 1000000000000001,
> 1000000000000002,...... If i remove the rule it works.

Rules don't play very nicely together with volatile functions like
nextval(). The rule is just a macro, and so if you have multiple
references to new.id_keyword, that means multiple evaluations of
nextval().

You'd be better off using a trigger to do this, I think.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Gardner 2010-10-23 16:42:41 Re: Performance implications of creating many, many sequences
Previous Message Tom Lane 2010-10-23 15:48:30 Re: What is "return code" for WAL send command