Robert Haas <robertmh...@gmail.com> writes: > On Thu, Mar 14, 2019 at 3:13 AM Amit Langote > <langote_amit...@lab.ntt.co.jp> wrote: >> I'm curious why DestroyPartitionDirectory doesn't do >> hash_destroy(pdir->pdir_hash)?
> What would be the point? It's more efficient to let context teardown > take care of it. Agreed, but the comments in this area are crap. Why doesn't CreatePartitionDirectory say something like * The object lives inside the given memory context and will be * freed when that context is destroyed. Nonetheless, the caller * must *also* ensure that (unless the transaction is aborted) * DestroyPartitionDirectory is called before that happens, else * we may leak some relcache reference counts. It's completely not acceptable that every reader of this code should have to reverse-engineer these design assumptions, especially given how shaky they are. There's an independent question as to whether the planner's use of the feature is specifying a safe memory context. Has this code been exercised under GEQO? regards, tom lane