In pg_dump, don't dump a stats object unless dumping underlying table.
commitb2c9936a7156926ace70b89ffb9cfbe1e3b9a559
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Dec 2023 15:57:11 +0000 (29 10:57 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Dec 2023 15:57:11 +0000 (29 10:57 -0500)
tree86145d7b6f995e9639c20235a841c732b7428c00
parenta78b0b3dcf584559f24cfd90e35799150b5de6ba
In pg_dump, don't dump a stats object unless dumping underlying table.

If the underlying table isn't being dumped, it's useless to dump
an extended statistics object; it'll just cause errors at restore.
We have always applied similar policies to, say, indexes.

(When and if we get cross-table stats objects, it might be profitable
to think a little harder about what to do with them.  But for now
there seems no point in considering a stats object as anything but
an appendage of its table.)

Rian McGuire and Tom Lane, per report from Rian McGuire.
Back-patch to supported branches.

Discussion: https://postgr.es/m/7075d3aa-3f05-44a5-b68f-47dc6a8a0550@buildkite.com
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/t/002_pg_dump.pl