Amit Langote <langote_amit...@lab.ntt.co.jp> writes: > Maybe, we don't need to spoil the interface of index_beginscan with the > new memory context argument like my patch does if the simple following of > its contract by amendscan would suffice.
Yeah, I'm not enamored of changing the API of index_beginscan for this; the existing convention that it should allocate in CurrentMemoryContext seems perfectly suitable. And changing it would create a lot of code churn, not only for us but for externally-maintained AMs. What is at stake is changing the API of amendscan, to specify that it need not release memory because the current context is expected to be destroyed or reset shortly after ending the scan. Then, for the small number of call sites where that wouldn't be true, it's on those callers to set up a suitable context and switch into it. Note this is actually forwards compatible, in that an AM that's still following the convention of releasing stuff manually would not be broken. regards, tom lane