Include extended statistics data in pg_dump This commit integrates the new pg_restore_extended_stats() function into pg_dump, so as the data of extended statistics is detected and included in dumps when the --statistics switch is specified. Currently, the same extended stats kinds as the ones supported by the SQL function can be dumped: "n_distinct" and "dependencies".
The extended statistics data can be dumped down to PostgreSQL 10, with the following changes depending on the backend version dealt with: - In v19 and newer versions, the format of pg_ndistinct and pg_dependencies has changed, catalogs can be directly queried. - In v18 and older versions, the format is translated to the new format supported by the backend. - In v14 and older versions, inherited extended statistics are not supported. - In v11 and older versions, the data for ndistinct and dependencies was stored in pg_statistic_ext. These have been moved to pg_stats_ext in v12. - Extended Statistics have been introduced in v10, no support is needed for versions older than that. The extended statistics data is dumped if it can be found in the catalogs. If the catalogs are empty, then no restore of the stats data is attempted. Author: Corey Huinker <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Discussion: https://postgr.es/m/CADkLM=dpz3KFnqP-dgJ-zvRvtjsa8UZv8wDAQdqho=qn3kx...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/c32fb29e979db4a7b92adb29007725eeacf91f64 Modified Files -------------- src/bin/pg_dump/pg_backup.h | 1 + src/bin/pg_dump/pg_backup_archiver.c | 3 +- src/bin/pg_dump/pg_dump.c | 209 +++++++++++++++++++++++++ src/bin/pg_dump/t/002_pg_dump.pl | 28 ++++ src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm | 8 +- 5 files changed, 244 insertions(+), 5 deletions(-)
