Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()
Date: 2025-12-29 19:17:25
Message-ID: 2992607.1767035845@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-12-29 19:17:47 Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist
Previous Message Tom Lane 2025-12-29 19:01:03 Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()