Quite an interesting patch, in my opinion. I've decided to work on it a bit, did some refactoring (sorry) and add basic tests. Also, I try to take into account as much as possible notes on the patch, mentioned by Cédric Villemain.
> and maybe better to go with FlushOneBuffer() ? It's a good idea, but I'm not sure at the moment. I'll try to dig some deeper into it. At least, FlushOneBuffer does not work for a local buffers. So, we have to decide whatever pg_buffercache_invalidate should or should not work for local buffers. For now, I don't see why it should not. Maybe I miss something? -- Best regards, Maxim Orlov.
v4-0001-Invalidate-Buffer-By-Bufnum.patch
Description: Binary data