Re: Rule/sequence weirdness

From: Richard Huxton <dev(at)archonet(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Rule/sequence weirdness
Date: 2004-09-01 08:30:42
Message-ID: 413588B2.6070708@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Crawford wrote:
>
> I want to monitor inserts to table "foo":
> guid: integer not null default nextval('public.guid'::text)
> end_time: integer
[snip]
> I expected the guid to match. Unfortunately there are no matching
> guids between the two tables. It appears that the sequence is being
> called twice so the guid in the log table is one greater than the
> guid in the main table.
>
> Did I miss something in my rule logic or is this a bug?

Rules are simply macros, so you are right and the sequence will be
accessed twice. You'll want to look at triggers.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Schuchardt 2004-09-01 08:51:24 Re: Exporting/moving Postgress Instance
Previous Message John Sidney-Woollett 2004-09-01 07:43:27 Re: Suppress output from psql?