In pg_dump, don't dump a stats object unless dumping underlying table.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 69d7edb06fc69da114b075be58dd4318916500e5
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2023-12-29T15:57:11Z
Releases: 12.18
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

Files

PathChange+/−
src/bin/pg_dump/pg_dump.c modified +26 −2
src/bin/pg_dump/pg_dump.h modified +1 −0
src/bin/pg_dump/t/002_pg_dump.pl modified +3 −3

Discussion