From f9562b95c6e8a66b4cd081f09cc600bf7a364c46 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 28 Jan 2026 08:37:46 +0900 Subject: [PATCH] Add output test for pg_dependencies statistics import Commit 302879bd68d115 has added the ability to restore extended stats of the type "dependencies", but it has forgotten the addition of a test to verify that the value restored was actually set. This test is the pg_dependencies equivalent of the test added for pg_ndistinct in 0e80f3f88dea. Author: Corey Huinker Discussion: https://postgr.es/m/CADkLM=dZr_Ut3jKw94_BisyyDtNZPRJWeOALXVzcJz=ZFTAhvQ@mail.gmail.com --- src/test/regress/expected/stats_import.out | 12 ++++++++++++ src/test/regress/sql/stats_import.sql | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/test/regress/expected/stats_import.out b/src/test/regress/expected/stats_import.out index b5664e5513c..3c9e7e0d369 100644 --- a/src/test/regress/expected/stats_import.out +++ b/src/test/regress/expected/stats_import.out @@ -1814,6 +1814,7 @@ SELECT pg_catalog.pg_restore_extended_stats( t (1 row) +-- Check the presence of the restored stats, for each object. SELECT replace(e.n_distinct, '}, ', E'},\n') AS n_distinct FROM pg_stats_ext AS e WHERE e.statistics_schemaname = 'stats_import' AND @@ -1824,6 +1825,17 @@ WHERE e.statistics_schemaname = 'stats_import' AND [{"attributes": [2, 3], "ndistinct": 4}] (1 row) +SELECT replace(e.dependencies, '}, ', E'},\n') AS dependencies +FROM pg_stats_ext AS e +WHERE e.statistics_schemaname = 'stats_import' AND + e.statistics_name = 'test_stat_dependencies' AND + e.inherited = false; + dependencies +------------------------------------------------------------ + [{"attributes": [2], "dependency": 3, "degree": 1.000000},+ + {"attributes": [3], "dependency": 2, "degree": 1.000000}] +(1 row) + DROP SCHEMA stats_import CASCADE; NOTICE: drop cascades to 7 other objects DETAIL: drop cascades to type stats_import.complex_type diff --git a/src/test/regress/sql/stats_import.sql b/src/test/regress/sql/stats_import.sql index 3e70b817513..1161fcffe81 100644 --- a/src/test/regress/sql/stats_import.sql +++ b/src/test/regress/sql/stats_import.sql @@ -1297,10 +1297,17 @@ SELECT pg_catalog.pg_restore_extended_stats( 'dependencies', '[{"attributes": [2], "dependency": 3, "degree": 1.000000}, {"attributes": [3], "dependency": 2, "degree": 1.000000}]'::pg_dependencies); +-- Check the presence of the restored stats, for each object. SELECT replace(e.n_distinct, '}, ', E'},\n') AS n_distinct FROM pg_stats_ext AS e WHERE e.statistics_schemaname = 'stats_import' AND e.statistics_name = 'test_stat_ndistinct' AND e.inherited = false; +SELECT replace(e.dependencies, '}, ', E'},\n') AS dependencies +FROM pg_stats_ext AS e +WHERE e.statistics_schemaname = 'stats_import' AND + e.statistics_name = 'test_stat_dependencies' AND + e.inherited = false; + DROP SCHEMA stats_import CASCADE;