I did a quick review and the patch seems fine to me. Let's wait for a bit and see if there are any objections - if not, I'll get it committed in the next CF.
Tomas, thanks for your review.
One thing I'm not sure about is whether we should have the GUC as proposed, or have a negative "keep_temp_files_after_restart" defaulting to false. But I don't have a very good justification for the alternative other than vague personal preference.
I thought about not providing a GUC at all or provide it in the developer section. I've never heard someone saying that they use those temporary files to investigate an issue. Regarding a crash, all information is already available and temporary files don't provide extra details. This new GUC is just to keep the previous behavior. I'm fine without the GUC, though.