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 1w7E3D-0055eV-1v for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2026 14:57:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7E3C-0047WZ-0Y for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2026 14:57:10 +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 1w7E3B-0047WO-2a for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 14:57:10 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7E3A-00000001ovg-2DCG for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 14:57:09 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-66a4c6bb6ecso8170144a12.1 for ; Mon, 30 Mar 2026 07:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774882627; cv=none; d=google.com; s=arc-20240605; b=ZiKdVVP8Lmf480RVlORFDt4OlArexFxUImyxDEjFoUduNqWGnNuF+E/2CEiZejlXA3 1ZAB5UZWO0xczmnLSf85kNohPBhoBZurdEFg42BC5bMJTqMXtDjPw4b3cheBiNl3o7dy kfjhODP+ZB8VaOZ6Pvgl46ErdA6KxC9ZDUA204rRGm0m0S/KmtJbFOkMKagr0z1U0MeM gYuaUjuT9owTsNM9jH3/vZcYw00GttrmvpLSoKFGVv3+eBTdjo5MmPvbjIvKLPN6TrjS dffP/mjM8Mp1vuG43JE1uFp1bWoxMg3Z/HSEnKvBLGZOy2S1NH8mFh7HEl8db71K2c2P TY/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Sa5BYmi6TbcDN25PlCS6Zhq3yOBf7r+NW50JS1tAyNE=; fh=ihEf2kd8iRPG0kSflL5MzdgzKi66G/z4ACVWJHUdnks=; b=jbFrBHSPb3qd/fc3/SC8F6ec4GZMgp4VOt4UYlEn7dJypAh2UFOIWWslIsHiZFwqaz KrJiGOQKy4mrMAFCE9vbifbmMlvu/1pG+CJYF2AzuQERr+gbkKnrijdoT1cqHy7vP8bZ S4x8pIfaundWt02x2mhRWejpoYfVylwfxX0FmNe5JJkiYF8V7mfSG5G5hGyv3ks1Xzg3 7ub2Ux6SlMQwkhCvMVH7zi7StDgxYtYOHfcUaCJ+0E2QeQdb98yUbuevdJ/zogAsCuhZ DhJfwXUccj+A8H5kT6fb08ZvEShCbOE0CWdXCCHaaq7DqYaa+1CxF2e7xpS0Y1uLobYd SMyQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774882627; x=1775487427; darn=lists.postgresql.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Sa5BYmi6TbcDN25PlCS6Zhq3yOBf7r+NW50JS1tAyNE=; b=fH/uecwwz1lDjO0ef+HVcoVcSQE8T8Ojklwo/hjpyBXr4M0QQMZQdNKZZ6xGjenKLf As+NNG+6o6m48Uh0YICE3kRqs1tKx83re/66dPSusLkzxYqSQRCz7P6VOJdOvPp4am34 /Qs1Abi3ZQS61S6gx/gapyyQ4iFgmsqXOBX7BjT573DH6rNKTNcUMii2pzYZ4fDByDKU rMYl9aqStpVhw5yosLbVP8Nm6o3vbX/Mya5ALOzLkaUoZO6dJxQPNCscSKGObrocFb5x t8TdrLrKNPRc3n76LsbgD/jZkujVeUdhIBk04wqpTGq7vkJFRwdunrgOoXZCVRPDQi3+ bxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774882627; x=1775487427; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Sa5BYmi6TbcDN25PlCS6Zhq3yOBf7r+NW50JS1tAyNE=; b=n+IXz2Cp618lLhJg7rdhwiW9kIvF1UGL140iF/mZ7IdYd1oZLBIEWnRRRCsLbNJOoL YQsa3Y+i7MwBqRThMmf6TD8i0GvIxfMGed6REyLqyARfQ/d8sbWah/8d+Tsng9WwfRrr SAJrZSKgKNii1Ob2MLLNlPuRzOYWLsMkVWyWbmoNlSvS72wlRAnEar59XnGxOd9Ne7Gl QDtgMUBaIu6i6P7CiLGJzeh8jBysJpkXvO0hUIseC3PQf3+NDsd762Jx0bgJsh+YJ9mY g7GyDbbl6RWosWme3pNKzaNEGXaXfIpI+zt8JQ6VdacP1gwcbu3158mF473dMxgCQIiF O8zw== X-Forwarded-Encrypted: i=1; AJvYcCWnywaMDfPlAuLu/7DfBoAWbhxf+h548BaTbh8uyNq+CqrluACxOX+vl8uDCEdhFAltqg95JuUckn37@lists.postgresql.org X-Gm-Message-State: AOJu0YzuHlgLO3hLdauopU1Gxe8FWy49zYEkFQD9XbwYeRNrJ3mcvKtO OUvWRV/sEoHCrnhbvV+20S8NlhujPx6jx8KM9xpDiO+bHP+wy9zUM01tYOEU5L77mdoGXE9tKAD xKKYcXVCekuFoOuczwxbP779EGMykzfTK4mly269xxA== X-Gm-Gg: ATEYQzz3He9NJLuM4GaCXJvbTOoupHll/i3vIyZ5ibn/5QQCBtkD7f6P6DwhJ255BAA kkrdddk1o39KKyeBQCucHsjUgLx0Bn8HhhXjMiFUmvMjBNKGrkEUDmrL01ThTotZTzhFMbfZ1QL bqqNyrdV8Z19rkGivhqqI71SmbSO7hEjiTf9MMfMnsTeSOe153gW6O0oHN5jMArd/vT4owdSD7Z yfhT8ypv+cQMvXpJsbB56+GV5qPkllQr//xdmrIDzSvJsvOGTRwa+97y9BB1jCZzJFb4wklhpQc /MjvIR0+TI92p/13KF7YnipNadSYh2y2Yj5J7E2tU7FufFq2FRi64SmtKevWxB7/6qiVUFHbJA= = X-Received: by 2002:a05:6402:378a:b0:66a:1983:2cde with SMTP id 4fb4d7f45d1cf-66b2846a496mr6592007a12.12.1774882626867; Mon, 30 Mar 2026 07:57:06 -0700 (PDT) MIME-Version: 1.0 References: <19445-f919d77c0e4f8d10@postgresql.org> In-Reply-To: <19445-f919d77c0e4f8d10@postgresql.org> From: Junwang Zhao Date: Mon, 30 Mar 2026 22:56:55 +0800 X-Gm-Features: AQROBzBh8rYEc4xIfg58uU4q21Yk_E7iWoFyaFXAFeP9aivITVPWQuazpe5arhk Message-ID: Subject: Re: BUG #19445: Domain DEFAULT not recorded in pg_attrdef (atthasdef false) in PostgreSQL 18.3 To: zheng_xianghang@163.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 30, 2026 at 7:52=E2=80=AFPM PG Bug reporting form wrote: > > The following bug has been logged on the website: > > Bug reference: 19445 > Logged by: Xianghang Zheng > Email address: zheng_xianghang@163.com > PostgreSQL version: 18.3 > Operating system: Linux x86_64 > Description: > > 1. PostgreSQL Version > PostgreSQL 18.3 (x86_64) > 2. Operating System > Linux x86_64 > 3. Problem Description > When a table column uses a domain that has a DEFAULT value, the column's > pg_attribute.atthasdef is false, and no entry exists in pg_attrdef. > However, the domain default value works correctly at runtime. > This is a system catalog metadata bug. > 4. Steps to Reproduce > CREATE DOMAIN my_arr_domain AS int[] DEFAULT '{}'; > CREATE TABLE t (col my_arr_domain); > SELECT > a.attname, > a.atthasdef, > pg_get_expr(adbin, adrelid) as default_value > FROM pg_attribute a > LEFT JOIN pg_attrdef d ON a.attrelid =3D d.adrelid AND a.attnum =3D d.adn= um > WHERE a.attrelid =3D 't'::regclass AND a.attnum > 0; > INSERT INTO t DEFAULT VALUES; > SELECT * FROM t; > 5. Actual Result > atthasdef =3D f > default_value is empty > But insert returns the correct default {} > 6. Expected Result > atthasdef should be true > System catalog must correctly reflect the default inherited from the doma= in > 7. Additional Information > - Domain default works correctly > - System metadata is wrong > - Affects pg_dump, information_schema, and 3rd party tools > - Bug exists in latest stable PostgreSQL 18.3 I think this is by design, postgres correctly distinguishes between column-= level defaults (stored in pg_attrdef) and type/domain-level defaults. > > -------------------------------------------------------------------------= ---------------------------- > > > postgres=3D# select version(); > version > -------------------------------------------------------------------------= -------------------------------- > PostgreSQL 18.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 > 20150623 (Red Hat 4.8.5-44), 64-bit > (1 row) > > postgres=3D# > postgres=3D# DROP TABLE IF EXISTS t CASCADE; > INSERT INTO t DEFAULT VALUES; > SELECT * FROM t; > > DROP TABLE t; > DROP DOMAIN my_arr_domain CASCADE;DROP TABLE > postgres=3D# DROP DOMAIN IF EXISTS my_arr_domain CASCADE; > DROP DOMAIN > postgres=3D# > postgres=3D# CREATE DOMAIN my_arr_domain AS int[] DEFAULT '{}'; > CREATE DOMAIN > postgres=3D# > postgres=3D# CREATE TABLE t (col my_arr_domain); > CREATE TABLE > postgres=3D# > postgres=3D# SELECT > postgres-# a.attname, > postgres-# a.atthasdef, > postgres-# pg_get_expr(adbin, adrelid) as default_value > postgres-# FROM pg_attribute a > postgres-# LEFT JOIN pg_attrdef d ON a.attrelid =3D d.adrelid AND a.attnu= m =3D > d.adnum > postgres-# WHERE a.attrelid =3D 't'::regclass > postgres-# AND a.attnum > 0; > attname | atthasdef | default_value > ---------+-----------+--------------- > col | f | > (1 row) > > postgres=3D# > postgres=3D# INSERT INTO t DEFAULT VALUES; > INSERT 0 1 > postgres=3D# SELECT * FROM t; > col > ----- > {} > (1 row) > postgres=3D# DROP TABLE t; > DROP TABLE > postgres=3D# DROP DOMAIN my_arr_domain CASCADE; > DROP DOMAIN > postgres=3D# > > > > --=20 Regards Junwang Zhao