summaryrefslogtreecommitdiff
path: root/src/backend/storage/file/fd.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2007-01-09 21:31:17 +0000
committerBruce Momjian <bruce@momjian.us>2007-01-09 21:31:17 +0000
commitbe8a4318815640ff57afc775f118367c9a1241a8 (patch)
treeb3340d1b7d871383c9b3bd68f6fcb8d3dc33d84f /src/backend/storage/file/fd.c
parent1e0bf9041ebb5cf80e83c48fd06214c5d6e22c17 (diff)
downloadpostgresql-be8a4318815640ff57afc775f118367c9a1241a8.tar.gz
Add GUC log_temp_files to log the use of temporary files.
Bill Moran
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r--src/backend/storage/file/fd.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 693c2e8014..a485189f1e 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.132 2007/01/05 22:19:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.133 2007/01/09 21:31:14 momjian Exp $
*
* NOTES:
*
@@ -50,6 +50,7 @@
#include "access/xact.h"
#include "storage/fd.h"
#include "storage/ipc.h"
+#include "utils/guc.h"
/*
@@ -938,7 +939,8 @@ OpenTemporaryFile(bool interXact)
void
FileClose(File file)
{
- Vfd *vfdP;
+ Vfd *vfdP;
+ struct stat filestats;
Assert(FileIsValid(file));
@@ -968,6 +970,19 @@ FileClose(File file)
{
/* reset flag so that die() interrupt won't cause problems */
vfdP->fdstate &= ~FD_TEMPORARY;
+ PG_TRACE1(temp__file__cleanup, vfdP->fileName);
+ if (log_temp_files >= 0)
+ {
+ if (stat(vfdP->fileName, &filestats) == 0)
+ {
+ if (filestats.st_size >= log_temp_files)
+ ereport(LOG,
+ (errmsg("temp file: path \"%s\" size %lu",
+ vfdP->fileName, (unsigned long)filestats.st_size)));
+ }
+ else
+ elog(LOG, "Could not stat \"%s\": %m", vfdP->fileName);
+ }
if (unlink(vfdP->fileName))
elog(LOG, "failed to unlink \"%s\": %m",
vfdP->fileName);