Hi Manu,
Thanks for the repros. I can confirm both on 18.6.
As for pinning the VACUUM case, I agree with your lean: an IMMUTABLE
function doing DML from an index expression during ANALYZE is likely
to put a committer off, and an injection point seems like too much for
a bug fix. So let's keep the VACUUM case best-effort, as it is in v2.
As for P1 and P2, would you like to take them to a separate thread
yourself? You found them and have already narrowed down where the fix
probably belongs. If you'd rather not, I'm happy to work on them, just
let me know.
--
Ilya Staroverov