diff -r src.orig/backend/storage/file/fd.c src/backend/storage/file/fd.c
52a53
> #include "utils/guc.h"
941c942,943
< 	Vfd		   *vfdP;
---
> 	Vfd			*vfdP;
> 	struct stat	filestats;
970a973,981
>     	if (fstat(vfdP->fd, &filestats)) {
> 			if (trace_temp_files)
> 				ereport(LOG,
> 					(errmsg("temp file: size %ld 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);
>     	}
diff -r src.orig/backend/utils/misc/guc.c src/backend/utils/misc/guc.c
183c183,184
< 
---
> bool		trace_temp_files = false;
>         
1013c1014,1024
< 
---
>                 
> 	{
> 		{"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
> 	},
>                 
1474c1485
< 
---
>                 
diff -r src.orig/backend/utils/misc/postgresql.conf.sample src/backend/utils/misc/postgresql.conf.sample
335a336
> #trace_temp_files = off			# Log usage of temporary files
diff -r src.orig/include/utils/guc.h src/include/utils/guc.h
125a126
> extern bool trace_temp_files;
