Re: autoupdating mtime column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Garamond" <davidgaramond(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: autoupdating mtime column
Date: 2006-08-04 16:10:23
Message-ID: 29505.1154707823@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"David Garamond" <davidgaramond(at)gmail(dot)com> writes:
> On 8/4/06, Richard Huxton <dev(at)archonet(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Garamond 2006-08-04 17:36:42 Re: autoupdating mtime column
Previous Message Richard Huxton 2006-08-04 16:05:50 Re: autoupdating mtime column