Re: pg_restore handles extended statistics inconsistently with statistics data

Corey Huinker <corey.huinker@gmail.com>

From: Corey Huinker <corey.huinker@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, PostgreSQL-development <pgsql-hackers@lists.postgresql.org>, Michael Paquier <michael.paquier@gmail.com>, Jeff Davis <pgsql@j-davis.com>
Date: 2026-06-15T19:25:39Z
Lists: pgsql-hackers
>
>
> We cannot just add a strcmp(te->desc, "STATISTICS DATA") == 0 check to the
> "else if (strcmp(te->desc, "INDEX") == 0)" branch, because STATISTICS DATA
> would already have matched the earlier table branch. So in v4, I pulled
> STATISTICS DATA into its own branch before the table and index branches.
>
>
v4 is looking good, though I'm a bit frustrated that that `pg_dump -s -t
s1.t` will include the index creations but not not the extended stats
objects. Feels like an oversight.

Commits

  1. pg_restore: Use dependency-based matching for STATISTICS DATA

  2. Fix inconsistencies with pg_restore --statistics[-only]