Re: BUG #3929: RULE causes unintended update of SEQUENCE - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #3929: RULE causes unintended update of SEQUENCE
Date
Msg-id 23074.1202230826@sss.pgh.pa.us
Whole thread Raw
In response to BUG #3929: RULE causes unintended update of SEQUENCE  ("Arjan Tuinhout" <at@tuko.nl>)
List pgsql-bugs
"Arjan Tuinhout" <at@tuko.nl> writes:
> -- However the intended code does not work: appearantly the SEQUENCE is
> update by calling the RULE; proofed by the workaround.

This is the expected behavior with a rule --- it's a macro, so multiple
references to the same input value risk multiple evaluations.

> -- Please help. Thanx. Arjan.

Use a trigger instead when your intent is to copy data from the
inserted/updated row to someplace else.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Florian Wunderlich
Date:
Subject: Re: BUG #3932: utf-8 and upper()/lower(): PANIC: ERRORDATA_STACK_SIZE exceeded
Next
From: "irfin"
Date:
Subject: BUG #3933: Update problem for 3 Foreign Keys referencing 1 field in another table (I'm not newbie in using SQL)