Re: autoupdating mtime column - Mailing list pgsql-sql

From Tom Lane
Subject Re: autoupdating mtime column
Date
Msg-id 29505.1154707823@sss.pgh.pa.us
Whole thread Raw
In response to Re: autoupdating mtime column  ("David Garamond" <davidgaramond@gmail.com>)
Responses Re: autoupdating mtime column
List pgsql-sql
"David Garamond" <davidgaramond@gmail.com> writes:
> On 8/4/06, Richard Huxton <dev@archonet.com> wrote:
>> Just check for OLD.mtime = NEW.mtime, or am I missing something here?

> How do I differentiate between:
> UPDATE t SET mtime=mtime ...;
> in which mtime is specifically set and should not change,

You don't.  A trigger has no way to know the history of the row it's
looking at --- consider the possibility that it was already modified
by earlier triggers.

If you are really intent on having a way to suppress the mtime update
you could dedicate an additional field to the purpose, eg

UPDATE t SET foo=..., bar=..., keepmtime = true ...

and in the trigger something like
if new.keepmtime then    new.keepmtime = false;else    new.mtime = now();

As long as nothing else ever touches keepmtime this would work.
Personally I'm dubious that it's worth the trouble --- do you
have a real use-case for suppressing mtime updates?
        regards, tom lane


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: autoupdating mtime column
Next
From: "David Garamond"
Date:
Subject: Re: autoupdating mtime column