From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | 赵宇鹏(宇彭) <zhaoyupeng(dot)zyp(at)alibaba-inc(dot)com> |
Cc: | "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Automatic update of time column |
Date: | 2025-01-17 03:41:12 |
Message-ID: | 2166909.1737085272@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"=?UTF-8?B?6LW15a6H6bmPKOWuh+W9rSk=?=" <zhaoyupeng(dot)zyp(at)alibaba-inc(dot)com> writes:
> MySQL offers a similar feature through ON UPDATE CURRENT_TIMESTAMP. Is there any
> consideration for PostgreSQL to implement this functionality?
It's been considered and rejected multiple times before. I don't
really see why we'd alter that decision now. The argument that
a trigger is an expensive solution doesn't impress me, because a
built-in fix such as you propose has a distributed cost that is
paid in every query whether the user wants such functionality
or not. There are also interesting semantic problems such as
how can a dump-and-restore happen without causing the stored
timestamps to update? (pg_dump gets around that for triggers
by not installing triggers till after loading data. Yeah,
you could make something similar happen for this feature too,
but that's more code and more complexity that has to propagate
to every tool doing dump-and-restore-like tasks.)
Having said that, there's plenty to be said for providing a
pre-written trigger that's implemented as efficiently as possible,
to minimize users' effort when they want this behavior. We have a
few such things already, such as suppress_redundant_updates_trigger()
and tsvector_update_trigger(). So I think a patch to make a
pre-written trigger for this purpose would be much less controversial.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Shubham Khanna | 2025-01-17 04:22:07 | Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility. |
Previous Message | 赵宇鹏 (宇彭) | 2025-01-17 03:18:45 | Automatic update of time column |