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 1wVRFD-001xgf-2R for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 09:53:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVRFC-00Ba0y-1U for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Jun 2026 09:53:38 +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 1wVRFC-00Ba0p-0X for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 09:53:38 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVRFA-00000001DWz-0Uc8 for pgsql-hackers@lists.postgresql.org; Fri, 05 Jun 2026 09:53:37 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-c85a2c012e5so675819a12.1 for ; Fri, 05 Jun 2026 02:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780653215; x=1781258015; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1V8l6BZBi/bG+eH/VrBnh39ds22M/QyI634Y9LhQX6w=; b=Nf/pe0ZH3d5c1GgBRIejPy1I9Q4ujdyICV5uwhs5gsPg6K9VJHipBe0zyGlhCY5Puu 7bwXf8QyhzrBlbg1FNikPo9Ch4qo4VEXdVlh5Pel59LV009LOENQ50L2Hxmkjrmb3M9/ 0X4NIGvHaFNYN88nPYaz6RfDec5mYmSh3thDMNZRG5SXTyiyRBemjdDt/DtlM+yrz3Qc NV2WD1kVlSiz/+3A0M5b/st1QjAk5S4jt+wbXKLkiwVkhP2wlEBUgaDHTLQDl59DYddM A/HMZv/FQ9ywzWkiXw5fDzTzoaQ57cEumD2QaUcY+zgduTzV6EkkQ40BBT+/hcXST4T2 XrHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780653215; x=1781258015; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1V8l6BZBi/bG+eH/VrBnh39ds22M/QyI634Y9LhQX6w=; b=ctIMUVE11ihX6rK7ZqcgRw/rbQNIICk0mGoj2e3i+9vhVD+WcwfcngJn82sQ0NUtFs tPvqrAeKvONCyykrIZc7JbwagM5qL3Wsvyv+rp7TFWVTv4CS8+f5G5xHv71teXqByC2Y ME8TUKFyt7TnAEvb0LQNOPVfQHyLtJ4EhW+8nKR8N6eUBaWv4aKv6TV3VtGY0lJf1mw1 svvivzKu/n2u4mXmsWuJiJ7vPcQsKHyd5/KxIi090wG1F/BkupCz/ptc++877O+dHBrQ YYBSN/BcCZFPFWUSbqbnn32syXlRrOjIealTlDEOMliE4WWiV1CumO12pUOg1EwRo9vY QaCQ== X-Gm-Message-State: AOJu0YyHoESuUJsReevmvtER58MQKUbJNTubpUr/GQzxnWT2lzQmobHZ gU8lL+Zh0Cb9ulZWZphMZwZBxX6YoV7LXtTBfJGc88siOCp3ZX7AO0AO X-Gm-Gg: Acq92OH7VXFkW//E6+UyU88u7SbbLrSUFVu8jrrC6sHBX7SC1AroT4luijoRSLScUDG DdVeBxSqVTNwnMS2+aw2r9/Vu0JPWiKNBsNqm458vvZGwcaHaUFPZxORnInAGqbXjRmh+bxstY4 zVsMlkTCtLsDsm3lr7iZd5oxwlQgykxpeCmbyloT15KzO0KsnMHt5y/D73hpHQ1Cg9DgTZmNcZW Aut9RYmDGyFWBneZCfv539nFwaqYmhDRjG/5sWXVpdklsD2MWIPA9CTNyUdrUXrO5KJfxgxzXO1 E/VoUTSlAeMfJRWjuLQO5TaohYerDNnIebklqKfkvuN42TF24CxodLMCMhLKqdoibRI/+vP/CwX VGfYmYZsMAgsu3EzI6HJeEgVJr5r3Rx8d/icWpAzY+zAxU8lfrLnJz2iubgiMAGQs94bIg6rq6J FILixQY1EuOiOGgHb1ngVFkRWnIj99E1ZbE9Bbz+N1ZA== X-Received: by 2002:a17:903:1245:b0:2c0:d9b7:b7a3 with SMTP id d9443c01a7336-2c1e8220b57mr27740475ad.21.1780653215018; Fri, 05 Jun 2026 02:53:35 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f88473sm96169135ad.25.2026.06.05.02.53.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2026 02:53:34 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: Fix domain fast defaults on empty tables From: Chao Li In-Reply-To: <219843CF-9B49-404A-838D-88D51902B978@iki.fi> Date: Fri, 5 Jun 2026 17:52:54 +0800 Cc: pgsql-hackers@lists.postgresql.org, Andrew Dunstan , jian he Content-Transfer-Encoding: quoted-printable Message-Id: <1A33470E-FCAE-42F0-8790-EE928058262B@gmail.com> References: <7033D663-DDB4-4B35-922C-F33DE53B1502@gmail.com> <219843CF-9B49-404A-838D-88D51902B978@iki.fi> To: Heikki Linnakangas X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jun 5, 2026, at 17:04, Heikki Linnakangas wrote: >=20 >=20 >=20 > On 5 June 2026 10:48:00 EEST, Chao Li wrote: >> Hi, >>=20 >> I tested "[a0b6ef29a] Enable fast default for domains with = non-volatile constraints". After tracing some cases from the regression = tests, I came up with this test case and found a bug: >> ``` >> evantest=3D# create domain d_div as int check (1 / (value - 1) > 0); >> CREATE DOMAIN >> evantest=3D# create table t (a int); >> CREATE TABLE >> evantest=3D# alter table t add column b d_div default 1; >> ERROR: division by zero >> ``` >>=20 >> It looks like errors inside the CHECK expression itself, such as the = int4div division-by-zero in this test, are still hard errors that can = fail the ALTER TABLE command. >=20 > 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. >=20 > - Heikki I agree that rejecting the default is semantically reasonable. But the = concern is that this is a user-visible behavior change, and the feature = didn=E2=80=99t seem intended to make that change. Before a0b6ef29a, this = ALTER TABLE command could succeed. If we now want to reject such = defaults, I think that should be documented explicitly. Also, there might be some practical use for the current behavior. For = example, an invalid default can be used to prevent INSERT from omitting = the column. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/