agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove fake FunctionCallInfos from the stats restore and import
Date: Wed, 02 Sep 2026 04:22:05 +0000
Message-ID: <E1x1cU8-000000037h9-2TP2@gemulon.postgresql.org> (raw)

Remove fake FunctionCallInfos from the stats restore and import code

The statistics import and restore paths built fake FunctionCallInfos
with LOCAL_FCINFO() and InitFunctionCallInfoData(), never calling
anything through them.  The only data relevantly used was the values
carried around as NullableDatum arrays, read back with PG_GETARG_*()
macros.

import_relation_statistics() and import_attribute_statistics() were
passing a set of NullablePointer pointers, leading to more round-trip
manipulations with the fake FunctionCallInfos.  These are reworked so as
the values pushed to pg_class (for relation stats) and pg_statistic (for
attribute stats) are passed around in dedicated structures with all the
values assigned based on positional indexes (import code cares about
less values than the restore code), simplifying their signatures and
reducing the number of code lines required to pass the data around.

The stats_check_*() functions now take the values and the attribute
names rather than a StatsArgInfo with positional indexes, as this code
is shared between the stats restore and import.  This removes the
dependency between the StatsArgInfo bits and the import code.
StatsArgInfo is used only for the restore code, for argument mapping.

No behavioral change should be introduced in this commit; this is
(should be) pure refactoring.

Reported-by: Robert Haas <robertmhaas@gmail.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CADkLM=eo7MtuCE=YjovW+=ASw1=q39qQ3qarrsw+EKfU901ztA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c           |  69 +++++----
src/backend/statistics/attribute_stats.c      | 215 +++++++++++---------------
src/backend/statistics/extended_stats_funcs.c |  81 +++++-----
src/backend/statistics/relation_stats.c       | 127 +++++++--------
src/backend/statistics/stat_utils.c           |  56 ++++---
src/include/statistics/stat_utils.h           |  19 +--
src/include/statistics/statistics.h           |  66 +++++---
src/tools/pgindent/typedefs.list              |   2 +
8 files changed, 300 insertions(+), 335 deletions(-)



Message-ID: <E1x1cU8-000000037h9-2TP2@gemulon.postgresql.org>
Permalink:  ../E1x1cU8-000000037h9-2TP2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x1cU8-000000037h9-2TP2@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Remove fake FunctionCallInfos from the stats restore and import
  In-Reply-To: <E1x1cU8-000000037h9-2TP2@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox