pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Greg Sabino Mullane <greg@turnstep.com>
Cc: pgsql-admin@postgresql.org
Cc: dicroce@pelco.com
Subject: Re: Stamping rows...
Date: Mon, 22 Nov 2004 19:43:29 -0700
Message-ID: <20041123024329.GA22271@winnie.fuhr.org> (raw)
In-Reply-To: <20d7d6be8697b20a7ba8a1b09cbff757@biglumber.com>
References: <B2CC0E0F2C10D511B86600B0D06898420EA053DE@NETSRVR1.pelco.org>
	<20d7d6be8697b20a7ba8a1b09cbff757@biglumber.com>

On Tue, Nov 23, 2004 at 02:14:52AM -0000, Greg Sabino Mullane wrote:

> CREATE OR REPLACE FUNCTION update_mtime() RETURNS TRIGGER LANGUAGE PLPGSQL AS
> 'BEGIN NEW.mtime = now(); RETURN NEW; END;';
>  
> CREATE TRIGGER people_update_mtime BEFORE UPDATE ON people
> FOR EACH ROW EXECUTE PROCEDURE update_mtime();
>  
> (I use a version of this for my incremental backup scheme)
>  
> Now every update (or insert) will cause all the rows changed to have the
> same unique value.

Since now() doesn't advance during a transaction, every other update
or insert in the same transaction will get the same "unique" value
even if they were performed as separate statements; that may or may
not meet the requirements for uniqueness.  It also assumes that no
two transactions will ever start at exactly the same time.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (4+ messages)

Message-ID: <20041123024329.GA22271@winnie.fuhr.org>
Permalink:  ../20041123024329.GA22271@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20041123024329.GA22271@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mike@fuhr.org, greg@turnstep.com, dicroce@pelco.com
  Subject: Re: Stamping rows...
  In-Reply-To: <20041123024329.GA22271@winnie.fuhr.org>
  References: <B2CC0E0F2C10D511B86600B0D06898420EA053DE@NETSRVR1.pelco.org> <20d7d6be8697b20a7ba8a1b09cbff757@biglumber.com> <20041123024329.GA22271@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox