Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Chao Li <li.evan.chao@gmail.com>,
Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-29T19:17:25Z
Lists: pgsql-hackers
... oh, one other thought: instead of what you did in
InitIndexAmRoutine, we should probably do something like
{
MemoryContext oldcontext;
/*
* We formerly specified that the amhandler should return a
* palloc'd struct. That's now deprecated in favor of returning
* a pointer to a static struct, but to avoid completely breaking
* old external AMs, run the amhandler in the relation's rd_indexcxt.
*/
oldcontext = MemoryContextSwitchTo(relation->rd_indexcxt);
relation->rd_indam = GetIndexAmRoutine(relation->rd_amhandler);
MemoryContextSwitchTo(oldcontext);
}
regards, tom lane