Re: Stamping rows... - Mailing list pgsql-admin

From Michael Fuhr
Subject Re: Stamping rows...
Date
Msg-id 20041123024329.GA22271@winnie.fuhr.org
Whole thread Raw
In response to Re: Stamping rows...  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-admin
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/

pgsql-admin by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: Stamping rows...
Next
From: mariabreis@ono.com
Date:
Subject: Synchronize 2 postgres db