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 <[email protected]>
Author: Corey Huinker <[email protected]>
Author: Michael Paquier <[email protected]>
Discussion: 
https://postgr.es/m/CADkLM=eo7MtuCE=YjovW+=ASw1=q39qq3qarrsw+ekfu901...@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(-)

Reply via email to