On Thu Feb 6 22:10:35 2025 +0000, Gabriel Ivăncescu wrote:
That actually looks cleaner than what I had in mind (rename to temporary, then rename to destination), but there is still the same problem that we need temporary filename. Not sure how to do that in a good/clean way? Also to alleviate possible worries, even though this complicates the code a bit, it's a path that won't be taken except when renaming files to themselves, but in different casing, so it won't slow down the most general path. And even in this case, it was currently broken, so IMO correctness is more important than performance when the latter means it isn't even working (treated as no-op).
Temporary file name can be allocated in a similar manner to mkstemp(3) or make_temp_file() in server/mapping.c. I don't think we have "the clean way" to do this, just compromising between various alternatives with different tradeoffs. Note that, as you said, the code was already incorrect.