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.96) (envelope-from ) id 1wWeSb-002lS1-0s for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jun 2026 18:12:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wWeSZ-003T9s-06 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Jun 2026 18:12:27 +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.96) (envelope-from ) id 1wWeSY-003T9j-1y for pgsql-hackers@lists.postgresql.org; Mon, 08 Jun 2026 18:12:26 +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.98.2) (envelope-from ) id 1wWeSW-00000001ixl-0O0B for pgsql-hackers@lists.postgresql.org; Mon, 08 Jun 2026 18:12:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 658ICFcN578688; Mon, 8 Jun 2026 14:12:15 -0400 From: Tom Lane To: jian he cc: Heikki Linnakangas , pgsql-hackers@lists.postgresql.org, Chao Li , Andrew Dunstan Subject: Re: Fix domain fast defaults on empty tables In-reply-to: References: <7033D663-DDB4-4B35-922C-F33DE53B1502@gmail.com> <219843CF-9B49-404A-838D-88D51902B978@iki.fi> <3590551.1780668509@sss.pgh.pa.us> Comments: In-reply-to jian he message dated "Mon, 08 Jun 2026 08:33:53 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <578686.1780942335.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 08 Jun 2026 14:12:15 -0400 Message-ID: <578687.1780942335@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > On Fri, Jun 5, 2026 at 10:08=E2=80=AFPM Tom Lane wro= te: >> I think there's reason for concern here, which is that we do not throw >> an error for the apparently equivalent case >> regression=3D# create table t2 (a int, b d_div default 1); >> CREATE TABLE >> This will give you an error at INSERT, but not CREATE. So this >> is inconsistent, as well as different from the pre-v19 behavior. > However, this is normal behavior for non-domain types. > create table t2 (a numeric default (1::numeric/0.0::float4)); -- ok > alter table t2 add column b numeric default ((1::numeric/0.0::float4)); = -- error Well, that's not great either. The idea of avoiding evaluating the default expression altogether when the table is empty could ameliorate that problem too. But my point stands: a0b6ef29a introduces different treatment for domain-CHECK-constraint errors than other types of runtime errors in the default expression. I think that is fundamentally the wrong direction to go in. We want more consistency here, not less. regards, tom lane