> In any case, my v3 patch seems to fix all these cases. > > (I'm not saying it's good enough to be committed as is. I think I should > at least add some comments. Anything else?)
the patch relies on looking up queryDesc->sourceText inside DropPortal, which Tom raised concerns about earlier in the thread [0] So, It seems to me we are better off just setting debug_query_string to NULL in DropPortal, or alternatively why not just log the statement automatically at the start of execution whenever we have log_temp_files > 0. That will allow us to safely capture the statement to blame for the temp files and will cover all cases? [0] https://www.postgresql.org/message-id/CAA5RZ0ssqRTz_9T0Gy74SiTViiX3V0rSFxc4N_4GNcbEBK9wow%40mail.gmail.com -- Sami Imseih Amazon Web Services (AWS)