I wrote:
> I looked at that again and realized that one of the answers I was missing
> lies in the behavior of analyze.c's compute_scalar_stats().
I updated the patch's comments based on this. I'll just attach the
selfuncs.c part of the patch, since nothing else changed.
regards, tom lane