From d37b9dcff807e9513dafb646d9060667d13d3547 Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH REL_19 v3 2/2] Test expression statistics with no common array elements Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/test/regress/expected/stats_ext.out | 11 +++++++++++ src/test/regress/sql/stats_ext.sql | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 5b4bcfae4e2..910521e5ed5 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -3760,3 +3760,14 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram (1 row) DROP TABLE stats_ext_tbl_range; +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; + a +--- +(0 rows) + +DROP TABLE stats_ext_tbl_mcelem; diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index 083a55fed2f..45fad70a84c 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -1944,3 +1944,11 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram FROM pg_stats_ext_exprs WHERE statistics_name = 'stats_ext_range'; DROP TABLE stats_ext_tbl_range; + +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; +DROP TABLE stats_ext_tbl_mcelem; -- 2.37.1 (Apple Git-137.1)