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 1wVqLM-002DzI-1c for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Jun 2026 12:41:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVqLL-00Fymt-1M for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Jun 2026 12:41:39 +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 1wVqLK-00Fyml-2z for pgsql-hackers@lists.postgresql.org; Sat, 06 Jun 2026 12:41:39 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVqLI-00000001OQN-10NH for pgsql-hackers@lists.postgresql.org; Sat, 06 Jun 2026 12:41:37 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-91588056619so196259685a.2 for ; Sat, 06 Jun 2026 05:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20251104.gappssmtp.com; s=20251104; t=1780749695; x=1781354495; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:subject:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=MzzSKi24wEAsGe5sAS4PylDXnTZXei35a4T7Mvxpi9Q=; b=w3jq955xAcNrq5Ba132DJkzYgmUYn4BPCun4aSxRxYNBnVxvO4850QBwIYJf5FqN/n DAvKx3doKmGQk8/lspIwBbP4k4rk3UpVRtulGIrAFg+3yDAdKLHVguHfOz2keZ2fpGS/ 4xth+chaXVWx+KtIpnyEz40GacN9JXfhRnv6sDFZpKV5YVs9Pix0r6s5Kc26kJ3NM2JT S67RhBuYyI9bwiqyBysUigGfWjOTGtbuAq7vDqYfHTv5mz44WVerIH3DQTwifHbxu5NH lNGEF2cKOMcyQ5RbnoukpPM5ne4z14YTpxAGIh20kuh2yffntrqWtv9dFQ+PH0+PB7aB hpoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780749695; x=1781354495; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:subject:from:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MzzSKi24wEAsGe5sAS4PylDXnTZXei35a4T7Mvxpi9Q=; b=OqMkx4BRZ0ROLtLJhHkWpDKuun7jPDSiu94S/0rozcdNz29UYRT0WiH97NN1gPGd2Y MhdfNGj0+TX+mWZdmIh4Y97mOgSdaa2kZ/lksvtdWRJgssxAZDHWyIGYLaFJvnlD24cl Bg+pZwLYiBGWaTkJwISooelE5qfKYMIpvR0eZGJAHuRFF9Ovz1bMVSokcGKXLd4BSF4i NkLrzoJTJaAkj/JFf1pepaeIMREr4+m6JnEwpD2c8C0mNfTQlNqJjPIdMmTzE4Wwxwkb wpuUA6FWzBQ9/njJ3YxjA5A1PLLdnbj2EfYRInQvCygFKMYe2DaKNMBpMtLqKmUHrv6E SB/A== X-Gm-Message-State: AOJu0YxYcyWX/ED+b+0JoCJPlDp9aBpJhQcfHOwVJIUD4diHFWFIcvND e8fyb7Gav+hOgbfYfr/cjb7DZ3+qdNMMzt+Q5xaQLYhltt94A629rZ2g9FYSsAq0MAc= X-Gm-Gg: Acq92OEYttk9/EFvrZQeU4OGaaW1oNICYXpxRt13RkLR8AaA/v5KtF84Pl0vY5GGAd1 5NGjxnY9DW3e6xsA0kaWrl7328oS6ppSyNIsK0jZ6qzX5KNJA4hz6UQE38pGIUsW+f39frGM/xJ Y78PFc2/b2jTntSR6GUCvq5qBtJt9FTwDizhSjwg65ghAqTVBbMgYIPfneRb+6jVuJa1lKadUpi dnoUITecdQ/G/My69VLzkm+YWb3tcowxlu/ABkaiHYhooKkB+4SGk6+R+8aZ9LNvsFZw25AcV10 mNNAzhRR6iTSxeH63dl+ucrQW57xNvQz7SeYfiH0EqVBOeOGAkN5P4R0PDbnY2LU4vjt3Mz1sCk 99p5g93tb24fAIkaOYjCC6tjIxxeVKdcMeqTnFgEGs29NbjMZuEBv6bWF6VuCOy9BJlTGJuXZk/ tcLmV6ksOtm3gKvkSvfyGpIpBd5/2WX7FxN/r2M+Zz4faX9q+ljIwlc1fICRh68UnNtbMFGr0ZI ijniNRGYUmhoO7r36S4 X-Received: by 2002:a05:620a:390e:b0:914:e3dd:17fd with SMTP id af79cd13be357-915a9c25a45mr1357395985a.6.1780749694642; Sat, 06 Jun 2026 05:41:34 -0700 (PDT) Received: from ?IPV6:2605:a601:a6b0:500:ccb8:56eb:bfc6:86b5? ([2605:a601:a6b0:500:ccb8:56eb:bfc6:86b5]) by smtp.googlemail.com with ESMTPSA id af79cd13be357-9158a3d2384sm1155958685a.39.2026.06.06.05.41.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Jun 2026 05:41:34 -0700 (PDT) Message-ID: <203a49c2-52e4-49ab-b644-ef6044266145@dunslane.net> Date: Sat, 6 Jun 2026 08:41:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Andrew Dunstan Subject: Re: Fix domain fast defaults on empty tables To: Tom Lane , Heikki Linnakangas Cc: pgsql-hackers@lists.postgresql.org, Chao Li , jian he References: <7033D663-DDB4-4B35-922C-F33DE53B1502@gmail.com> <219843CF-9B49-404A-838D-88D51902B978@iki.fi> <3590551.1780668509@sss.pgh.pa.us> Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR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WUg23p93w/pqXcxY6+k/8TEk+C4R+M6w7o2PLGOjdZ +kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaYL++LAEOqrlvm2Tvq QqZRtnEAEQEAAcLAfAQYAQgAJgIbDBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNI2BQkd EODdAAoJEJn6f8tZ/DuBfw0IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: <3590551.1780668509@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-06-05 Fr 10:08 AM, Tom Lane wrote: > Heikki Linnakangas writes: >> On 5 June 2026 10:48:00 EEST, Chao Li wrote: >>> evantest=# create domain d_div as int check (1 / (value - 1) > 0); >>> CREATE DOMAIN >>> evantest=# create table t (a int); >>> CREATE TABLE >>> evantest=# alter table t add column b d_div default 1; >>> ERROR: division by zero >> It seems totally reasonable to get an error in that case. '1' is not a valid value for the datatype, whether or not there are any rows in the table. > I think there's reason for concern here, which is that we do not throw > an error for the apparently equivalent case > > regression=# 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. > > Concretely, I'm pretty sure it is a hazard for pg_dump, which thinks > it can freely transform bits of CREATE operations into ALTERs. > I didn't try to make an example case, but I suspect it is now possible > to create a database that will fail dump/restore because of this > inconsistency. > > Seems reasonable. So which of Chao's solutions do you prefer? I think both will meet the pg_dump issue, not sure how much we care about the case where we have deleted all the rows but not truncated the table. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com