pgsql: Fix issues with handling of expressions in extended stats restor

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix issues with handling of expressions in extended stats restor
Date: 2026-05-18 04:18:47
Message-ID: E1wOpRH-0006AC-1q@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix issues with handling of expressions in extended stats restore

This commit addresses some defects with the handling of expressions in
pg_restore_extended_stats() and pg_clear_extended_stats():
- Misleading WARNING for an incorrect number of expressions, where the
number of required expressions was reported as the number of elements
given in input rather than the actual number of expressions expected by
the extstats object definition.
- Incorrect matching of expression names, where a key name was
considered as valid as long as it matched with the prefix of a legit key
name. For example "correlatio" given in input would match with
"correlation", and be considered valid. The consequence of this bug was
a silent discard of the input data, where the operation would be
considered a success. The value associated to the prefixed key was not
inserted in the catalogs, just ignored. pg_dump would not generate such
input data patterns, but a user doing manual stats injection could.
- Missing heap_freetuple() in pg_clear_extended_stats(), for the case
where the extstats object in input does not match with its parent
relation.

Author: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/A7C11B83-7534-4A09-9071-FBD09175CFC8@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a28fa2947d2a507089605c47bbfa9016d457208c

Modified Files
--------------
src/backend/statistics/extended_stats_funcs.c | 6 +++--
src/test/regress/expected/stats_import.out | 32 +++++++++++++++++++++++++--
src/test/regress/sql/stats_import.sql | 19 +++++++++++++++-
3 files changed, 52 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-05-18 15:09:12 pgsql: oauth: Fix missing quote in errormessage
Previous Message Fujii Masao 2026-05-18 04:15:48 pgsql: Fix parsing of REPACK options