Re: Stamping rows...
От | Michael Fuhr |
---|---|
Тема | Re: Stamping rows... |
Дата | |
Msg-id | 20041123024329.GA22271@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: Stamping rows... ("Greg Sabino Mullane" <greg@turnstep.com>) |
Список | 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 по дате отправления: