diff options
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 43bc43ab10f..673b25db347 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -1088,6 +1088,9 @@ FileClose(File file) */ if (vfdP->fdstate & FD_TEMPORARY) { + struct stat filestats; + int stat_errno; + /* * If we get an error, as could happen within the ereport/elog calls, * we'll come right back here during transaction abort. Reset the @@ -1101,23 +1104,22 @@ FileClose(File file) temporary_files_size -= vfdP->fileSize; vfdP->fileSize = 0; - if (log_temp_files >= 0) - { - struct stat filestats; - int stat_errno; + /* first try the stat() */ + if (stat(vfdP->fileName, &filestats)) + stat_errno = errno; + else + stat_errno = 0; - /* first try the stat() */ - if (stat(vfdP->fileName, &filestats)) - stat_errno = errno; - else - stat_errno = 0; + /* in any case do the unlink */ + if (unlink(vfdP->fileName)) + elog(LOG, "could not unlink file \"%s\": %m", vfdP->fileName); - /* in any case do the unlink */ - if (unlink(vfdP->fileName)) - elog(LOG, "could not unlink file \"%s\": %m", vfdP->fileName); + /* and last report the stat results */ + if (stat_errno == 0) + { + pgstat_report_tempfile(filestats.st_size); - /* and last report the stat results */ - if (stat_errno == 0) + if (log_temp_files >= 0) { if ((filestats.st_size / 1024) >= log_temp_files) ereport(LOG, @@ -1131,12 +1133,6 @@ FileClose(File file) elog(LOG, "could not stat file \"%s\": %m", vfdP->fileName); } } - else - { - /* easy case, just do the unlink */ - if (unlink(vfdP->fileName)) - elog(LOG, "could not unlink file \"%s\": %m", vfdP->fileName); - } } /* Unregister it from the resource owner */ |