Re: pg_dump: ALTER INDEX SET STATISTICS missing for index-backed constraints

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_dump: ALTER INDEX SET STATISTICS missing for index-backed constraints
Date: 2026-09-29 07:39:04
Message-ID: 86F86621-6E76-45F3-B9C6-AC9A79E0CABA@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jul 14, 2026, at 20:45, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> Hello hackers,
>
> I noticed this while reviewing the pg_get_tale_ddl patch and looking
> for inconsistencies compared to pg_dump.
>
> It seems like pg_dump emits SET STATISTICS for most cases since 2018
> (e4fca461), but it was missed in this case:
>
> CREATE TABLE t (a int, b int);
> ALTER TABLE t ADD CONSTRAINT name EXCLUDE USING gist ((a+b) WITH =);
> ALTER INDEX name ALTER COLUMN 1 SET STATISTICS 900;
>
> The last statement was missing from the pg_dump output.
>
> Attached patch fixes it and adds a test case.
> <0001-Dump-index-column-statistics-for-index-backed-constr.patch>

The patch looks good to me overall. My only nit is that it adds more dup code to dumpIndex(). Maybe we could factor that out into a small helper function shared by dumpIndex() and dumpConstraint().

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haibo Yan 2026-09-29 07:39:45 Re: [PATCH] Use Boyer-Moore-Horspool for simple LIKE contains patterns
Previous Message Daniel Gustafsson 2026-09-29 07:26:41 Re: Stabilize and shorten test_checksums/013_rewind test