However, by that argument we should change all 3 of these functions to set up the data. If we're eating the layering violation to the extent of letting OpenTemporaryFile call into commands/tablespace, then there's little reason for the other 2 not to do likewise.
I agree to that point, same logic should be used for all three calls irrespective of the approach we pick.
I still remain concerned that invoking catalog lookups from fd.c is a darn bad idea, even if we have a fallback for it to work (for some value of "work") in non-transactional states. It's not really hard to envision that kind of thing leading to infinite recursion. I think it's safe right now, because catalog fetches shouldn't lead to any temp-file access, but that's sort of a rickety assumption isn't it?
Is there (easy) way to assert for that assumption? If yes, then can add the same and make it not rickety.
Though I agree any exceptions/violations coded generally bites in long run somewhere later.