v9-0003-Restore-pg_stats_ext_exprs-set-difference-checks.patch
text/x-patch
Filename: v9-0003-Restore-pg_stats_ext_exprs-set-difference-checks.patch
Type: text/x-patch
Part: 2
Patch
Format: format-patch
Series: patch v9-0003
Subject: Restore pg_stats_ext_exprs set difference checks
| File | + | − |
|---|---|---|
| src/test/regress/expected/stats_import.out | 75 | 1 |
| src/test/regress/sql/stats_import.sql | 69 | 1 |
From 91a00877dd11cc9092041d49523648727555d5af Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Mon, 9 Feb 2026 09:11:43 -0500
Subject: [PATCH v9 3/5] Restore pg_stats_ext_exprs set difference checks
---
src/test/regress/expected/stats_import.out | 76 +++++++++++++++++++++-
src/test/regress/sql/stats_import.sql | 70 +++++++++++++++++++-
2 files changed, 144 insertions(+), 2 deletions(-)
diff --git a/src/test/regress/expected/stats_import.out b/src/test/regress/expected/stats_import.out
index bb2b9abe9a0..3d2fe6b881f 100644
--- a/src/test/regress/expected/stats_import.out
+++ b/src/test/regress/expected/stats_import.out
@@ -2994,8 +2994,26 @@ SELECT e.statistics_name,
'dependencies', e.dependencies,
'most_common_vals', e.most_common_vals,
'most_common_freqs', e.most_common_freqs,
- 'most_common_base_freqs', e.most_common_base_freqs)
+ 'most_common_base_freqs', e.most_common_base_freqs,
+ 'exprs', x.exprs)
FROM pg_stats_ext AS e
+CROSS JOIN LATERAL (
+ SELECT jsonb_agg(jsonb_strip_nulls(jsonb_build_object(
+ 'null_frac', ee.null_frac::text,
+ 'avg_width', ee.avg_width::text,
+ 'n_distinct', ee.n_distinct::text,
+ 'most_common_vals', ee.most_common_vals::text,
+ 'most_common_freqs', ee.most_common_freqs::text,
+ 'histogram_bounds', ee.histogram_bounds::text,
+ 'correlation', ee.correlation::text,
+ 'most_common_elems', ee.most_common_elems::text,
+ 'most_common_elem_freqs', ee.most_common_elem_freqs::text,
+ 'elem_count_histogram', ee.elem_count_histogram::text)))
+ FROM pg_stats_ext_exprs AS ee
+ WHERE ee.statistics_schemaname = e.statistics_schemaname AND
+ ee.statistics_name = e.statistics_name AND
+ ee.inherited = e.inherited
+ ) AS x(exprs)
WHERE e.statistics_schemaname = 'stats_import'
AND e.statistics_name = 'test_stat';
statistics_name | pg_restore_extended_stats
@@ -3039,6 +3057,62 @@ SELECT o.inherited,
-----------+------------+--------------+------------------+-------------------+------------------------
(0 rows)
+-- Set difference for exprs: old MINUS new.
+SELECT o.inherited,
+ o.null_frac, o.avg_width, o.n_distinct,
+ o.most_common_vals::text AS most_common_vals,
+ o.most_common_freqs,
+ o.histogram_bounds::text AS histogram_bounds,
+ o.correlation,
+ o.most_common_elems::text AS most_common_elems,
+ o.most_common_elem_freqs, o.elem_count_histogram
+ FROM pg_stats_ext_exprs AS o
+ WHERE o.statistics_schemaname = 'stats_import' AND
+ o.statistics_name = 'test_stat'
+EXCEPT
+SELECT n.inherited,
+ n.null_frac, n.avg_width, n.n_distinct,
+ n.most_common_vals::text AS most_common_vals,
+ n.most_common_freqs,
+ n.histogram_bounds::text AS histogram_bounds,
+ n.correlation,
+ n.most_common_elems::text AS most_common_elems,
+ n.most_common_elem_freqs, n.elem_count_histogram
+ FROM pg_stats_ext_exprs AS n
+ WHERE n.statistics_schemaname = 'stats_import' AND
+ n.statistics_name = 'test_stat_clone';
+ inherited | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation | most_common_elems | most_common_elem_freqs | elem_count_histogram
+-----------+-----------+-----------+------------+------------------+-------------------+------------------+-------------+-------------------+------------------------+----------------------
+(0 rows)
+
+-- Set difference for exprs: new MINUS old.
+SELECT n.inherited,
+ n.null_frac, n.avg_width, n.n_distinct,
+ n.most_common_vals::text AS most_common_vals,
+ n.most_common_freqs,
+ n.histogram_bounds::text AS histogram_bounds,
+ n.correlation,
+ n.most_common_elems::text AS most_common_elems,
+ n.most_common_elem_freqs, n.elem_count_histogram
+ FROM pg_stats_ext_exprs AS n
+ WHERE n.statistics_schemaname = 'stats_import' AND
+ n.statistics_name = 'test_stat_clone'
+EXCEPT
+SELECT o.inherited,
+ o.null_frac, o.avg_width, o.n_distinct,
+ o.most_common_vals::text AS most_common_vals,
+ o.most_common_freqs,
+ o.histogram_bounds::text AS histogram_bounds,
+ o.correlation,
+ o.most_common_elems::text AS most_common_elems,
+ o.most_common_elem_freqs, o.elem_count_histogram
+ FROM pg_stats_ext_exprs AS o
+ WHERE o.statistics_schemaname = 'stats_import' AND
+ o.statistics_name = 'test_stat';
+ inherited | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation | most_common_elems | most_common_elem_freqs | elem_count_histogram
+-----------+-----------+-----------+------------+------------------+-------------------+------------------+-------------+-------------------+------------------------+----------------------
+(0 rows)
+
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 93ca7a52668..4ec8565c622 100644
--- a/src/test/regress/sql/stats_import.sql
+++ b/src/test/regress/sql/stats_import.sql
@@ -2054,8 +2054,26 @@ SELECT e.statistics_name,
'dependencies', e.dependencies,
'most_common_vals', e.most_common_vals,
'most_common_freqs', e.most_common_freqs,
- 'most_common_base_freqs', e.most_common_base_freqs)
+ 'most_common_base_freqs', e.most_common_base_freqs,
+ 'exprs', x.exprs)
FROM pg_stats_ext AS e
+CROSS JOIN LATERAL (
+ SELECT jsonb_agg(jsonb_strip_nulls(jsonb_build_object(
+ 'null_frac', ee.null_frac::text,
+ 'avg_width', ee.avg_width::text,
+ 'n_distinct', ee.n_distinct::text,
+ 'most_common_vals', ee.most_common_vals::text,
+ 'most_common_freqs', ee.most_common_freqs::text,
+ 'histogram_bounds', ee.histogram_bounds::text,
+ 'correlation', ee.correlation::text,
+ 'most_common_elems', ee.most_common_elems::text,
+ 'most_common_elem_freqs', ee.most_common_elem_freqs::text,
+ 'elem_count_histogram', ee.elem_count_histogram::text)))
+ FROM pg_stats_ext_exprs AS ee
+ WHERE ee.statistics_schemaname = e.statistics_schemaname AND
+ ee.statistics_name = e.statistics_name AND
+ ee.inherited = e.inherited
+ ) AS x(exprs)
WHERE e.statistics_schemaname = 'stats_import'
AND e.statistics_name = 'test_stat';
@@ -2088,4 +2106,54 @@ SELECT o.inherited,
WHERE o.statistics_schemaname = 'stats_import' AND
o.statistics_name = 'test_stat';
+-- Set difference for exprs: old MINUS new.
+SELECT o.inherited,
+ o.null_frac, o.avg_width, o.n_distinct,
+ o.most_common_vals::text AS most_common_vals,
+ o.most_common_freqs,
+ o.histogram_bounds::text AS histogram_bounds,
+ o.correlation,
+ o.most_common_elems::text AS most_common_elems,
+ o.most_common_elem_freqs, o.elem_count_histogram
+ FROM pg_stats_ext_exprs AS o
+ WHERE o.statistics_schemaname = 'stats_import' AND
+ o.statistics_name = 'test_stat'
+EXCEPT
+SELECT n.inherited,
+ n.null_frac, n.avg_width, n.n_distinct,
+ n.most_common_vals::text AS most_common_vals,
+ n.most_common_freqs,
+ n.histogram_bounds::text AS histogram_bounds,
+ n.correlation,
+ n.most_common_elems::text AS most_common_elems,
+ n.most_common_elem_freqs, n.elem_count_histogram
+ FROM pg_stats_ext_exprs AS n
+ WHERE n.statistics_schemaname = 'stats_import' AND
+ n.statistics_name = 'test_stat_clone';
+
+-- Set difference for exprs: new MINUS old.
+SELECT n.inherited,
+ n.null_frac, n.avg_width, n.n_distinct,
+ n.most_common_vals::text AS most_common_vals,
+ n.most_common_freqs,
+ n.histogram_bounds::text AS histogram_bounds,
+ n.correlation,
+ n.most_common_elems::text AS most_common_elems,
+ n.most_common_elem_freqs, n.elem_count_histogram
+ FROM pg_stats_ext_exprs AS n
+ WHERE n.statistics_schemaname = 'stats_import' AND
+ n.statistics_name = 'test_stat_clone'
+EXCEPT
+SELECT o.inherited,
+ o.null_frac, o.avg_width, o.n_distinct,
+ o.most_common_vals::text AS most_common_vals,
+ o.most_common_freqs,
+ o.histogram_bounds::text AS histogram_bounds,
+ o.correlation,
+ o.most_common_elems::text AS most_common_elems,
+ o.most_common_elem_freqs, o.elem_count_histogram
+ FROM pg_stats_ext_exprs AS o
+ WHERE o.statistics_schemaname = 'stats_import' AND
+ o.statistics_name = 'test_stat';
+
DROP SCHEMA stats_import CASCADE;
--
2.53.0