]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Simplify some stats restore code with InputFunctionCallSafe()
authorMichael Paquier <michael@paquier.xyz>
Mon, 29 Jun 2026 23:30:08 +0000 (08:30 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 29 Jun 2026 23:30:08 +0000 (08:30 +0900)
commitefa59a500457f310abbc38dc472f03e959ccd5b8
tree3caeff064ca0728dc44c6de27bbfb08834720ca5
parenta281a3e6dbb45d5cca41ea5f7b746724eb3ca70d
Simplify some stats restore code with InputFunctionCallSafe()

statatt_build_stavalues() and array_in_safe() have been relying on
InitFunctionCallInfoData() with a locally-filled state to call a data
type input function.  InputFunctionCallSafe() can be used to achieve the
same job, simplifying some code.

This fixes an over-allocation of FunctionCallInfoBaseData done in
statatt_build_stavalues(), where there was space for 8 elements but only
3 were needed.  The over-allocation exists since REL_18_STABLE, and was
harmless in practice.

While on it, fix some comments for both routines, where elemtypid was
mentioned.

Backpatch down to v19.  This code has been reworked during the last
development cycle while working on the restore of extended statistics,
so this keeps the code consistent across all branches.

Author: Jian He <jian.universality@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CACJufxEGah9PaiTQ=cG14GMMBsUQ3ohGct9tdSwbMQPQ0-nbbQ@mail.gmail.com
Backpatch-through: 19
src/backend/statistics/extended_stats_funcs.c
src/backend/statistics/stat_utils.c