Andres Freund <andres@2ndquadrant.com> writes:
> On 2014-05-14 12:15:27 -0400, Tom Lane wrote:
>> And why does the header
>> comment for RelationGetIndexList make no mention of this new side-effect?
>> Somebody did a seriously poor job of adding this functionality to
>> relcache.
> It's not like it's not documented: There's a comment about it in struct
> RelationData. I must have missed that rd_oidindex has a comment abou
> it's lifetime over RelationGetIndexList().
If rd_replidindex is being managed like rd_oidindex, then it should be
managed just like rd_oidindex, including getting reset in all the places
rd_oidindex is. This might be just a matter of cleanliness but I think
it's important for readability and debuggability.
I notice also that rd_keyattr and rd_idattr have been implemented with
bad copies of the logic for rd_indexattr. This is at least leading
to a permanent memory leak in CacheMemoryContext during every relcache
flush, and maybe worse things. The bugs for rd_keyattr appear to predate
your patch though.
Working on a patch for this now. One thing I'm wondering about is
RelationSetIndexList. It's probably okay for it not to touch rd_keyattr
and rd_idattr, but I'm not too clear on what the use cases for those
attnum sets are.
regards, tom lane