The following bug has been logged on the website:
Bug reference: 17036
Logged by: Zhou Digoal
Email address: digoal@126.com
PostgreSQL version: 14beta1
Operating system: CentOS 7.7 x64
Description:
postgres=> create or replace function im_now () returns timestamptz as $$
select CURRENT_TIMESTAMP;
$$ language sql strict immutable;
CREATE FUNCTION
postgres=> create table t1 (id int primary key, info text, crt_time
timestamp,
mod_time
timestamptz GENERATED ALWAYS AS (im_now()) stored);
CREATE TABLE
postgres=> insert into t1 (id, info, crt_time) values (1,'test', now());
INSERT 0 1
postgres=> select * from t1;
id | info | crt_time | mod_time
----+------+----------------------------+-------------------------------
1 | test | 2021-05-26 16:38:26.675934 | 2021-05-26 16:38:26.675934+08
(1 row)
postgres=> update t1 set info='a' where id=1;
UPDATE 1
postgres=> select * from t1;
id | info | crt_time | mod_time
----+------+----------------------------+-------------------------------
1 | a | 2021-05-26 16:38:26.675934 | 2021-05-26 16:38:26.675934+08
(1 row)
why mod_time cann't updated automatic?
best regards,
digoal