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 1toGai-008Teg-50 for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Mar 2025 06:44:53 +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 1toGZj-006DwZ-Jl for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Mar 2025 06:43:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1toGZj-006DwR-9H for pgsql-hackers@lists.postgresql.org; Sat, 01 Mar 2025 06:43:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1toGZd-000JO9-3B for pgsql-hackers@postgresql.org; Sat, 01 Mar 2025 06:43:49 +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 5216hihT2901600; Sat, 1 Mar 2025 01:43:44 -0500 From: Tom Lane To: jian he cc: PostgreSQL-development Subject: Re: bug when apply fast default mechanism for adding new column over domain with default value In-reply-to: References: Comments: In-reply-to jian he message dated "Sat, 01 Mar 2025 13:39:56 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2901598.1740811424.1@sss.pgh.pa.us> Date: Sat, 01 Mar 2025 01:43:44 -0500 Message-ID: <2901599.1740811424@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > then I think I found a bug for applying fast default over domain with > default value. Yeah, that's definitely a bug: it worked correctly in versions before we invented the attmissingval mechanism. > column b type is domain int_domain3, which has a constraint. > As a result, adding column b triggers a table rewrite, ensuring the > domain default value is successfully applied. I do not believe that case should require a table rewrite. Both the default and the check constraint are immutable, so we ought to be able to apply the check once and then use the default as the attmissingval. > Attach a patch to fix this issue by cause it to table rewrite. I see no attached patch, but in any case forcing a table rewrite seems like the wrong direction... regards, tom lane