Thanks to Simon Riggs and Bruce for input that helped me put this together.
-- Bill Moran Collaborative Fusion Inc.
diff -c -r src.orig/backend/storage/file/fd.c src/backend/storage/file/fd.c *** src.orig/backend/storage/file/fd.c Thu Dec 7 15:44:42 2006 --- src/backend/storage/file/fd.c Tue Jan 2 12:33:25 2007 *************** *** 50,55 **** --- 50,56 ---- #include "access/xact.h" #include "storage/fd.h" #include "storage/ipc.h" + #include "utils/guc.h" /* *************** *** 938,944 **** void FileClose(File file) { ! Vfd *vfdP; Assert(FileIsValid(file)); --- 939,946 ---- void FileClose(File file) { ! Vfd *vfdP; ! struct stat filestats; Assert(FileIsValid(file)); *************** *** 968,973 **** --- 970,984 ---- { /* reset flag so that die() interrupt won't cause problems */ vfdP->fdstate &= ~FD_TEMPORARY; + if (stat(vfdP->fileName, &filestats) == 0) { + if (trace_temp_files) + ereport(LOG, + (errmsg("temp file: size %lu path \"%s\"", + filestats.st_size, vfdP->fileName))); + PG_TRACE1(temp__file__cleanup, filestats.st_size); + } else { + elog(ERROR, "Could not stat \"%s\": %m", vfdP->fileName); + } if (unlink(vfdP->fileName)) elog(LOG, "failed to unlink \"%s\": %m", vfdP->fileName); diff -c -r src.orig/backend/utils/misc/guc.c src/backend/utils/misc/guc.c *** src.orig/backend/utils/misc/guc.c Wed Nov 29 09:50:07 2006 --- src/backend/utils/misc/guc.c Fri Dec 29 10:28:08 2006 *************** *** 180,186 **** int log_min_messages = NOTICE; int client_min_messages = NOTICE; int log_min_duration_statement = -1; ! int num_temp_buffers = 1000; char *ConfigFileName; --- 180,187 ---- int log_min_messages = NOTICE; int client_min_messages = NOTICE; int log_min_duration_statement = -1; ! bool trace_temp_files = false; ! int num_temp_buffers = 1000; char *ConfigFileName; *************** *** 1010,1016 **** &IgnoreSystemIndexes, false, NULL, NULL }, ! /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL --- 1011,1027 ---- &IgnoreSystemIndexes, false, NULL, NULL }, ! ! { ! {"trace_temp_files", PGC_USERSET, LOGGING_WHAT, ! gettext_noop("Enables logging the usage of temp files."), ! gettext_noop("Size and location of each temp file is reported."), ! NULL ! }, ! &trace_temp_files, ! false, NULL, NULL ! }, ! /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL *************** *** 1471,1477 **** &log_min_duration_statement, -1, -1, INT_MAX / 1000, NULL, NULL }, ! { {"bgwriter_delay", PGC_SIGHUP, RESOURCES, gettext_noop("Background writer sleep time between rounds in milliseconds"), --- 1482,1488 ---- &log_min_duration_statement, -1, -1, INT_MAX / 1000, NULL, NULL }, ! { {"bgwriter_delay", PGC_SIGHUP, RESOURCES, gettext_noop("Background writer sleep time between rounds in milliseconds"), diff -c -r src.orig/backend/utils/misc/postgresql.conf.sample src/backend/utils/misc/postgresql.conf.sample *** src.orig/backend/utils/misc/postgresql.conf.sample Mon Nov 20 20:23:37 2006 --- src/backend/utils/misc/postgresql.conf.sample Fri Dec 29 12:45:16 2006 *************** *** 333,338 **** --- 333,339 ---- #log_statement = 'none' # none, ddl, mod, all #log_hostname = off + #trace_temp_files = off # Log usage of temporary files #--------------------------------------------------------------------------- # RUNTIME STATISTICS diff -c -r src.orig/include/utils/guc.h src/include/utils/guc.h *** src.orig/include/utils/guc.h Thu Oct 19 14:32:47 2006 --- src/include/utils/guc.h Fri Dec 29 10:00:40 2006 *************** *** 123,128 **** --- 123,129 ---- extern int log_min_messages; extern int client_min_messages; extern int log_min_duration_statement; + extern bool trace_temp_files; extern int num_temp_buffers;
---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster