1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

pg_dump: Allow pg_dump to dump the statistics for foreign tables.

Commit 1fd1bd8710 introduced support for dumping statistics with
pg_dump and pg_dumpall, covering tables, materialized views, and indexes.
However, it overlooked foreign tables, even though functions like
pg_restore_relation_stats() support them.

This commit fixes that oversight by allowing pg_dump and pg_dumpall
to include statistics for foreign tables.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/3772e4e4-ef39-4deb-bb76-aa8165f33fb6@oss.nttdata.com
This commit is contained in:
Fujii Masao
2025-06-18 14:53:55 +09:00
parent 9e1183953f
commit c2e2589ab9
3 changed files with 9 additions and 5 deletions

View File

@ -1277,8 +1277,8 @@ PostgreSQL documentation
</para> </para>
<para> <para>
The data section contains actual table data, large-object The data section contains actual table data, large-object
contents, statistics for tables and materialized views and contents, sequence values, and statistics for tables,
sequence values. materialized views, and foriegn tables.
Post-data items include definitions of indexes, triggers, rules, Post-data items include definitions of indexes, triggers, rules,
statistics for indexes, and constraints other than validated check statistics for indexes, and constraints other than validated check
constraints. constraints.
@ -1359,7 +1359,8 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
Dump only the statistics, not the schema (data definitions) or data. Dump only the statistics, not the schema (data definitions) or data.
Statistics for tables, materialized views, and indexes are dumped. Statistics for tables, materialized views, foreign tables,
and indexes are dumped.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -690,7 +690,8 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
<listitem> <listitem>
<para> <para>
Dump only the statistics, not the schema (data definitions) or data. Dump only the statistics, not the schema (data definitions) or data.
Statistics for tables, materialized views, and indexes are dumped. Statistics for tables, materialized views, foreign tables,
and indexes are dumped.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -6890,7 +6890,8 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages,
(relkind == RELKIND_PARTITIONED_TABLE) || (relkind == RELKIND_PARTITIONED_TABLE) ||
(relkind == RELKIND_INDEX) || (relkind == RELKIND_INDEX) ||
(relkind == RELKIND_PARTITIONED_INDEX) || (relkind == RELKIND_PARTITIONED_INDEX) ||
(relkind == RELKIND_MATVIEW)) (relkind == RELKIND_MATVIEW ||
relkind == RELKIND_FOREIGN_TABLE))
{ {
RelStatsInfo *info = pg_malloc0(sizeof(RelStatsInfo)); RelStatsInfo *info = pg_malloc0(sizeof(RelStatsInfo));
DumpableObject *dobj = &info->dobj; DumpableObject *dobj = &info->dobj;
@ -6929,6 +6930,7 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages,
case RELKIND_RELATION: case RELKIND_RELATION:
case RELKIND_PARTITIONED_TABLE: case RELKIND_PARTITIONED_TABLE:
case RELKIND_MATVIEW: case RELKIND_MATVIEW:
case RELKIND_FOREIGN_TABLE:
info->section = SECTION_DATA; info->section = SECTION_DATA;
break; break;
case RELKIND_INDEX: case RELKIND_INDEX: