Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lm6Oi-0000W5-SZ for pgsql-bugs@arkaria.postgresql.org; Thu, 27 May 2021 03:09:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lm6Oh-0003BE-MO for pgsql-bugs@arkaria.postgresql.org; Thu, 27 May 2021 03:09:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lm6Oh-0003B6-Fh for pgsql-bugs@lists.postgresql.org; Thu, 27 May 2021 03:09:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lm6Of-0005ru-Ar for pgsql-bugs@lists.postgresql.org; Thu, 27 May 2021 03:09:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14R390Ju1684302; Wed, 26 May 2021 23:09:00 -0400 From: Tom Lane To: =?GBK?B?tcK45w==?= cc: "David G. Johnston" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #17036: generated column cann't modifyed auto when update In-reply-to: <2e46e6b5.1930.179abb8b6c0.Coremail.digoal@126.com> References: <17036-e4d41f4221873a17@postgresql.org> <23824c32.12e8.179ab97fa8a.Coremail.digoal@126.com> <2e46e6b5.1930.179abb8b6c0.Coremail.digoal@126.com> Comments: In-reply-to =?GBK?B?tcK45w==?= message dated "Thu, 27 May 2021 10:47:59 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1684300.1622084940.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 26 May 2021 23:09:00 -0400 Message-ID: <1684301.1622084940@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?GBK?B?tcK45w=3D=3D?=3D writes: > The generated column can be used to automatically generate the modified = timestamp of a tuple, but PG 12 currently supports this scenario. PG 13 ha= s started to change its behavior, which makes our application need to be m= odified. This is the first time I have ever seen a PG upgrade kill a nice = feature. You have been told several times already that this is not a "feature". The point of the restriction that GENERATED expressions be immutable is that the implementation need not recompute them during UPDATE (if none of their input columns changed). If v12 failed to exploit that fully, that's more a bug in v12 than it is in versions that do exploit it. If you need to update a column during every update, the best way to do that is with a BEFORE INSERT OR UPDATE trigger. I will also state categorically that lying about the mutability of a function is a technique that will bite you on the rear, and you will get no sympathy when it does. If it does what you want in version N, fine, but don't whine when it breaks in N+1. regards, tom lane