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 1w7BAh-0052Q7-0r for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2026 11:52:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7BAf-002yUc-1F for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2026 11:52:41 +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.96) (envelope-from ) id 1w732v-000gGA-1R for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 03:12:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w732q-00000001vLG-2dJA for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 03:12:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=mswgN3cpoocsIhVbrZmfGr0K3JNF/Oo8rVRNCJ2GIGI=; b=yQYoGCtGxYvjHe6ItNFvoekWyl M+Whw2gH0/kZETSaLOGLsiM36HtBikcrCbKsY3FDZxP7LPWdJXvDdlwgXLOfDd55Toq81MJEtym73 0Tdjp5fDF0+2BRAJqJHoJf4/xahqa7SBOy2qYCa6VkV+iStUnY3x78/4BHRr8AKR+ia0EeA8BAqGU Bj2ihwyqwjrSTJuRulHLfSHhBuUtbU8Wfk1b6ucfDkE42P9UkgqFqRHdaLrbEunrsOszqUE2mNzGA AysHWMr3mMozucRf2aZaxPir5BGe29H9soiD76XCM2KxJIzUivfKwK27UM5Yz+F5Sf6GulOBOYTIO MwXvrSoQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w732p-006ZB4-26 for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 03:12:03 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w732n-00ADXy-30 for pgsql-bugs@lists.postgresql.org; Mon, 30 Mar 2026 03:12:02 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19445: Domain DEFAULT not recorded in pg_attrdef (atthasdef false) in PostgreSQL 18.3 To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: zheng_xianghang@163.com Reply-To: zheng_xianghang@163.com, pgsql-bugs@lists.postgresql.org Date: Mon, 30 Mar 2026 03:11:35 +0000 Message-ID: <19445-f919d77c0e4f8d10@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: =20 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.adnum 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 domain 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 ---------------------------------------------------------------------------= -------------------------- 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.attnum = =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#