]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add output test for pg_dependencies statistics import
authorMichael Paquier <michael@paquier.xyz>
Tue, 27 Jan 2026 23:37:46 +0000 (08:37 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 27 Jan 2026 23:37:46 +0000 (08:37 +0900)
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 <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/CADkLM=dZr_Ut3jKw94_BisyyDtNZPRJWeOALXVzcJz=ZFTAhvQ@mail.gmail.com

src/test/regress/expected/stats_import.out
src/test/regress/sql/stats_import.sql

index b5664e5513c14e86f104709fc1b989b63f070f65..3c9e7e0d3693f867afd9950c9e88dd5247a5d1ff 100644 (file)
@@ -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
index 3e70b81751333ec8884078277a84d5bce0c9e781..1161fcffe8152c524ae3ac17cc53131b55ef370b 100644 (file)
@@ -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;