Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVZ5E-009bhB-CD for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 16:39:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tVZ5D-003Mja-NS for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 16:39:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVZ5D-003MjS-Dh for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 16:39:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVZ5B-000Y66-0U for pgsql-hackers@postgresql.org; Wed, 08 Jan 2025 16:39:02 +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 508GcwFi1662508; Wed, 8 Jan 2025 11:38:58 -0500 From: Tom Lane To: Peter Eisentraut cc: jian he , pgsql-hackers , Dean Rasheed Subject: Re: Virtual generated columns In-reply-to: <999d5c67-94f7-4ee8-82ec-09e1fd4bb689@eisentraut.org> References: <732a9543-0312-4f0c-a471-857b507a3546@eisentraut.org> <0f811f71-8c86-4e1b-b3bb-6a535674a440@eisentraut.org> <09800cb1-43aa-4239-8918-46b71ede4900@eisentraut.org> <536b281b-2cb3-4477-971f-c64838bc6263@eisentraut.org> <41f64e3c-db80-43b2-9a21-7ecc515f889f@eisentraut.org> <999d5c67-94f7-4ee8-82ec-09e1fd4bb689@! eisentraut.org> Comments: In-reply-to Peter Eisentraut message dated "Wed, 08 Jan 2025 17:25:07 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1662506.1736354338.1@sss.pgh.pa.us> Date: Wed, 08 Jan 2025 11:38:58 -0500 Message-ID: <1662507.1736354338@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 03.12.24 15:15, jian he wrote: >> SELECT attrelid, attname, attgenerated FROM pg_attribute WHERE >> attgenerated IN ('v') and (attnotnull or not atthasdef); > I don't understand what the purpose of testing attnotnull is. That is > independent of attgenerated, I think. Does it make any sense to set NOT NULL on a generated column (virtual or otherwise, but especially virtual)? What is the system supposed to do if the expression evaluates to null? That concern generalizes to any constraint really. Even if we checked it at row storage time, there's no real guarantee that the expression is immutable enough to pass the constraint later. regards, tom lane