Hi,
While testing “[c32fb29e9] Include extended statistics data in pg_dump”, I noticed that pg_dump and pg_restore behave
asymmetricallyfor --statistics-only when a schema is specified.
This command dumps relation stats, attribute stats, and extended stats from the schema:
```
pg_dump --statistics-only -n s1 -f /tmp/plain-s1-stats.sql stats_src
```
However, this command will only restore extended stats for the schema:
```
pg_restore --statistics-only -n s1 -f /tmp/archive-s1-stats.sql /tmp/stats.dump
```
I tried the same test against 1ea44d7ddfb, the immediate predecessor of c32fb29e9. pg_dump dumped relation stats and
attributestats, while pg_restore restored nothing. So the asymmetric behavior for stats already existed. c32fb29e9 then
addedextended stats to both pg_dump and pg_restore, but the new EXTENDED STATISTICS DATA entries are handled
differentlyfrom STATISTICS DATA during selective pg_restore, making the inconsistency visible.
The asymmetric behavior was not introduced by c32fb29e9, so I think we probably should not change that for v19. If it's
confirmedthat this needs to be fixed and nobody else plans to work on it, I would be happy to add it to my TODO list
forv20.
For v19, I wonder if we should also exclude extended stats from selective pg_restore in the same way as other stats, so
thatEXTENDED STATISTICS DATA is treated consistently with STATISTICS DATA. That only requires a one-line change, see
theattached exclude_ext_stats.diff. Actually, I suspect c32fb29e9 simply missed that change.
Also, attached test_pgdump_stats.sh is the script I ran to verify the problem.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/