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 1qCReA-0006J7-Hr for pgsql-admin@arkaria.postgresql.org; Thu, 22 Jun 2023 21:15:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qCRe8-0002qL-07 for pgsql-admin@arkaria.postgresql.org; Thu, 22 Jun 2023 21:15:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCRe7-0002qC-LI for pgsql-admin@lists.postgresql.org; Thu, 22 Jun 2023 21:15:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qCRe5-0045Ro-4G for pgsql-admin@lists.postgresql.org; Thu, 22 Jun 2023 21:15:15 +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 35MLF5GQ4108565; Thu, 22 Jun 2023 17:15:06 -0400 From: Tom Lane To: "David G. Johnston" cc: Ilya Kosmodemiansky , "Wetmore, Matthew (CTR)" , pgsql-admin@lists.postgresql.org Subject: Re: GENERATE AS In-reply-to: References: <7c48174f8ce449af8f3e875bdeca7150@express-scripts.com> Comments: In-reply-to "David G. Johnston" message dated "Thu, 22 Jun 2023 13:25:34 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4108563.1687468505.1@sss.pgh.pa.us> Date: Thu, 22 Jun 2023 17:15:05 -0400 Message-ID: <4108564.1687468505@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > The problem here is not timezone related - it is more fundamental in that > the stored data does not change but the expression, as time progresses, is > going to give different values and thus make what is stored incorrect. Right --- current_timestamp in a generation expression makes no sense. (There's also an issue about whether the surrounding calculation is timezone-dependent, but that could be fixed up. Depending on current time cannot be.) You could create a view in which this value is an extra computed column, but you can't do it as a stored generated column. regards, tom lane