Fix missing temporary files query reports in some conditions. Thanks to Guillaume Lelarge and Thomas Reiss for the report.