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.98.2) (envelope-from ) id 1x93BG-00000001iLP-0fUc for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Sep 2026 16:17:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x93AF-0000000HO06-23ff for pgsql-bugs@arkaria.postgresql.org; Tue, 22 Sep 2026 16:16:15 +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.98.2) (envelope-from ) id 1x935M-0000000HEtr-13j8 for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:11:12 +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 1x935I-00000000j8V-0yL2 for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:11:11 +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=OXGtZHZL1ItZqg6kGF91/nM1T9QDqCDAn2w3Ubt43AA=; b=sKe/nBAKpGSXzZq5kk8j6aGksQ u7XMlS5tn8V+RnwCwQEx4mAYFcgpz/eGLwwHIOhqzf5kEokOt4+c/VNwdpAd+6EFNkuyCex5d3KLM 0OuyZ2wQ4eeB4kqb0nnFLyXySqpYbj/mbATtgPBtGRiMxfJTmY1Ay/QJ8ILSxOKXaxkQJFbebrynE PPgCc8Ne3+fzZlnkoGoG+YpvzHGHlke1Y68HCF7G5I7xp6WJKap0x3X8vRNQzqhkU6FMkIgKrNiT6 GbNlO0rM+JFtjpzqj8xKeQ64Vobf7qM7r7BxgMUhjzM4f40MZhFC2jtMy2Kn+bjb6KmNmJLWQUpO3 HhMb+Qhg==; 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 1x935E-00287x-30 for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:11:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x935D-00000005xt1-0hLo for pgsql-bugs@lists.postgresql.org; Tue, 22 Sep 2026 16:11:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19715: pg_restore_attribute_stats() rejects range statistics for a domain over int4multirange To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: imchifan@163.com Reply-To: imchifan@163.com, pgsql-bugs@lists.postgresql.org Date: Tue, 22 Sep 2026 16:10:04 +0000 Message-ID: <19715-b8be35083016f289@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: 19715 Logged by: Qifan Liu Email address: imchifan@163.com PostgreSQL version: 18.6 Operating system: Linux/amd64 Description: =20 pg_restore_attribute_stats() rejects range length and bounds histograms for a column whose type is a domain over int4multirange. It returns false and warns that the column is not a range type. However, ANALYZE generates both range-specific statistic kinds 6 and 7 for a column of the same domain type. As a result, statistics exported for a domain over a multirange type cannot be faithfully restored to an equivalent column. Steps to reproduce ------------------ Run the following input with psql -X: \set ON_ERROR_STOP on CREATE DOMAIN restore_stats_mr AS int4multirange; CREATE TABLE restore_stats_src (v restore_stats_mr); CREATE TABLE restore_stats_dst (v restore_stats_mr); INSERT INTO restore_stats_src VALUES ('{[1,3)}'), ('{[5,9)}'), ('{[11,15)}'); ANALYZE restore_stats_src; SELECT array_agg(k ORDER BY k) AS analyze_range_kinds FROM ( SELECT unnest(ARRAY[stakind1, stakind2, stakind3, stakind4, stakind5]) AS k FROM pg_statistic WHERE starelid =3D 'restore_stats_src'::regclass AND staattnum =3D 1 ) s WHERE k IN (6, 7); SELECT pg_catalog.pg_restore_attribute_stats( 'schemaname', 'public', 'relname', 'restore_stats_dst', 'attname', 'v', 'inherited', false, 'range_length_histogram', '{2,4,4}'::text, 'range_empty_frac', 0::real, 'range_bounds_histogram', ARRAY['[1,3)', '[5,9)', '[11,15)']::text ) AS restore_ok; SELECT count(*) =3D 2 AS restored_both_range_kinds FROM ( SELECT unnest(ARRAY[stakind1, stakind2, stakind3, stakind4, stakind5]) AS k FROM pg_statistic WHERE starelid =3D 'restore_stats_dst'::regclass AND staattnum =3D 1 ) s WHERE k IN (6, 7); Actual result ------------- analyze_range_kinds --------------------- {6,7} WARNING: column "v" is not a range type DETAIL: Cannot set STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM or STATISTIC_KIND_BOUNDS_HISTOGRAM. restore_ok ------------ f restored_both_range_kinds --------------------------- f Expected result --------------- pg_restore_attribute_stats() should return true and restore statistic kinds 6 and 7. ANALYZE produces those range statistics for the same domain type, so the restoration path should not reject them as belonging to a non-range column. Additional information ---------------------- The issue was reproduced on PostgreSQL 20devel and PostgreSQL 18.6. PostgreSQL 17.11 does not provide pg_restore_attribute_stats().