Andres Freund <andres@anarazel.de> writes:
> I agree that it ought to be more efficent - but also about as equally
> safe? I.e. if the previous code wasn't safe, the new code wouldn't be
> safe either? As in, we're "just" avoiding the assert, but not increasing
> safety?
Well, the point is that the old code risks performing a relcache load
without holding any lock on the relation. In practice, given that
we do hold a lock on the parent table, it's probably safe ... but
it's at best bad practice. It's not too hard to imagine future
optimizations that would allow this to result in a corrupt relcache entry.
I don't believe that there's any equivalent risk in the modified code.
regards, tom lane