| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix more issues with extended statistics on expressions |
| Date: | 2026-10-30 08:30:25 |
| Message-ID: | E1xMi0H-00000001NN7-2SzJ@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix more issues with extended statistics on expressions
When evaluating expressions (through make_build_data()) and building
stats data for expressions (through build_expr_data()), both routines
forgot that examine_expression() could return a NULL result, depending
on the data generated by the typanalyze function assigned to a type.
This would crash the server.
This commit includes some tests added to test_custom_types that are able
to reproduce all these issues with two fancy typanalyze callbacks:
- False result with a valid stats target, for the expression evaluation.
- False result with a valid stats target on second call, for the stats
data build.
No typanalyze callback in core have the idea to do that, and I doubt
that anything out there has the idea to do that. If they do, this
switches the expression stats to fail gracefully instead of crashing,
based on the combinations that are assumed as supported by the core
code.
This is a continuation of 3b7a6fa15720.
Reported-by: Yuelin Wang <1217816127(at)qq(dot)com>
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/19763-14da3f96c02f07e8@postgresql.org
Backpatch-through: 14
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/8b517a30c832d2614d00e1dbe53fe06216adf548
Modified Files
--------------
src/backend/statistics/extended_stats.c | 48 ++++++++++++++++++----
src/test/modules/test_custom_types/README | 4 ++
.../expected/test_custom_types.out | 36 ++++++++++++++++
.../test_custom_types/sql/test_custom_types.sql | 28 +++++++++++++
.../test_custom_types/test_custom_types--1.0.sql | 16 ++++++++
.../modules/test_custom_types/test_custom_types.c | 37 +++++++++++++++++
6 files changed, 161 insertions(+), 8 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-10-30 11:52:50 | pgsql: Fix crash-restart race in 041_checkpoint_at_promote.pl |
| Previous Message | John Naylor | 2026-10-30 05:36:12 | pgsql: Check all four box corners in SP-GiST quad tree <@ search |