diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2025-12-30 18:26:23 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2025-12-30 18:26:23 -0500 |
| commit | bc6374cd76abb2e6a48c4b57c0b5a7baa5babd67 (patch) | |
| tree | d90c3ca10ec7cbc70d538e64a7d5205532e2ed03 /aclocal.m4 | |
| parent | 736f754eed01ca81198b6cd7421321088cbe5ded (diff) | |
Change IndexAmRoutines to be statically-allocated structs.HEADorigin/masterorigin/HEADmaster
Up to now, index amhandlers were expected to produce a new, palloc'd
struct on each call. That requires palloc/pfree overhead, and creates
a risk of memory leaks if the caller fails to pfree, and the time
taken to fill such a large structure isn't nil. Moreover, we were
storing these things in the relcache, eating several hundred bytes for
each cached index. There is not anything in these structs that needs
to vary at runtime, so let's change the definition so that an
amhandler can return a pointer to a "static const" struct of which
there's only one copy per index AM. Mark all the core code's
IndexAmRoutine pointers const so that we catch anyplace that might
still try to change or pfree one.
(This is similar to the way we were already handling TableAmRoutine
structs. This commit does fix one comment that was infelicitously
copied-and-pasted into tableamapi.c.)
This commit needs to be called out in the v19 release notes as an API
change for extension index AMs. An un-updated AM will still work
(as of now, anyway) but it risks memory leaks and will be slower than
necessary.
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAEoWx2=vApYk2LRu8R0DdahsPNEhWUxGBZ=rbZo1EXE=uA+opQ@mail.gmail.com
Diffstat (limited to 'aclocal.m4')
0 files changed, 0 insertions, 0 deletions
