| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
| Subject: | Re: pg_restore handles extended statistics inconsistently with statistics data |
| Date: | 2026-06-15 07:55:48 |
| Message-ID: | ai-wBPFhQOVVOJbx@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Jun 15, 2026 at 11:51:40AM +0800, Chao Li wrote:
> If the fix direction is to make pg_restore behave consistently with
> pg_dump, then I think Michael's change is correct.
I have been checking for a few hours, and well.. There was more.
> See the attached v2 for details.
That's nice, unfortunately incomplete. I have found a different
pattern that behaves incorrectly, reusing your script of upthread:
pg_restore --statistics --table t \
-f /tmp/archive-s1-stats.sql /tmp/stats.dump
pg_restore --statistics-only --table t \
-f /tmp/archive-s1-stats.sql /tmp/stats.dump
With "--statistics --table t", we restore the definition of table "t"
and its data (correct), miss the stats (incorrect!). With
"--statistics-only --table t", we restore no definition and no data
(correct), and still miss the stats (incorrect!). So we still have a
borked restore of the stats when selecting an individual table. We
don't care about extended stats with this case, as extstats are
objects defined at schema level and we cannot filter them, but I think
that we definitely care about attribute and relation stats here.
This case requires a second change in _tocEntryRequired() even after
the first fix so as it is possible to select a STATISTICS DATA that
depends on a table part of the authorized list close to the list that
includes the "SEQUENCE SET".
With all that in mind, I have the attached. I have expanded the tests
with the --table case, using dump and restore commands, and that seems
to work correctly now with the restores, including the cases with
extstats.
And I'm planning to apply that down to v18 tomorrow, after a second
round of lookups.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Fix-pg_restore-with-schema-table-and-statistics-o.patch | text/plain | 3.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-06-15 08:07:45 | Dead reference to schema_only_with_statistics in pg_dump TAP code |
| Previous Message | Akshay Joshi | 2026-06-15 07:52:03 | Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements |