Can we say that pg_get_indexdef() has "side-effects" because it can error like this? Shouldn't such a function be marked *volatile*? Because if I do so by updating pg_proc, the plan changes (perhaps) to a safe one in this context:
That is another option, but by nature this function is not actually volatile, because if clause is on pg_index indexrelid then it can be pushed down.
So I think changing the view definition and calling this function on indexrelid will remove the error. So I think
correct fix is to change view definition, as I proposed in above patch.