Hello, Álvaro!
Fixes are in attachment. I think the comment message and comments are good enough to explain the changes.
Also, the second commit adds syscache for pg_inherites. I am not very confident with it, but it feels correct to me.
Another approach - put information about parents into - I can rebuild the patch that way.
Also, for the first commit it is possible to create a batched version of get_partition_ancestors (with the same snapshot for multiple indexes).
Best regards,
Mikhail.