pg_dump: Allow pg_dump to dump the statistics for foreign tables. master github/master
authorFujii Masao
Wed, 18 Jun 2025 05:53:55 +0000 (14:53 +0900)
committerFujii Masao
Wed, 18 Jun 2025 05:53:55 +0000 (14:53 +0900)
Commit 1fd1bd87101 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 
Reviewed-by: Corey Huinker
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/3772e4e4-ef39-4deb-bb76-aa8165f33fb6@oss.nttdata.com

doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_dumpall.sgml
src/bin/pg_dump/pg_dump.c

index d7595a7e5468d8a3f7ad90dca3a64802c59eed7a..1e06bd33bdcd1fb2cc0806b3e2fa20b56f3b0439 100644 (file)
@@ -1277,8 +1277,8 @@ PostgreSQL documentation
          
          
           The data section contains actual table data, large-object
-          contents, statistics for tables and materialized views and
-          sequence values.
+          contents, sequence values, and statistics for tables,
+          materialized views, and foriegn tables.
           Post-data items include definitions of indexes, triggers, rules,
           statistics for indexes, and constraints other than validated check
           constraints.
@@ -1359,7 +1359,8 @@ PostgreSQL documentation
       
        
         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.
        
       
      
index 723a466cfaad62783a59f3bbb2a5d9f81da25abe..43f384ed16a9cb040b34a8dc33db5bf1fb35e02b 100644 (file)
@@ -690,7 +690,8 @@ exclude database PATTERN
       
        
         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.
        
       
      
index 7bc0724cd301f50386a9e4b0a3ca63cb781e78f2..a8f0309e8fc1e49e8054c30aa3594f37fb8ca846 100644 (file)
@@ -6890,7 +6890,8 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages,
        (relkind == RELKIND_PARTITIONED_TABLE) ||
        (relkind == RELKIND_INDEX) ||
        (relkind == RELKIND_PARTITIONED_INDEX) ||
-       (relkind == RELKIND_MATVIEW))
+       (relkind == RELKIND_MATVIEW ||
+        relkind == RELKIND_FOREIGN_TABLE))
    {
        RelStatsInfo *info = pg_malloc0(sizeof(RelStatsInfo));
        DumpableObject *dobj = &info->dobj;
@@ -6929,6 +6930,7 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages,
            case RELKIND_RELATION:
            case RELKIND_PARTITIONED_TABLE:
            case RELKIND_MATVIEW:
+           case RELKIND_FOREIGN_TABLE:
                info->section = SECTION_DATA;
                break;
            case RELKIND_INDEX: