Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe8a431

Browse files
committed
Add GUC log_temp_files to log the use of temporary files.
Bill Moran
1 parent1e0bf90 commitbe8a431

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.99 2006/12/12 21:30:33 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.100 2007/01/09 21:31:14 momjian Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -2920,6 +2920,23 @@ SELECT * FROM parent WHERE key = 2400;
29202920
</listitem>
29212921
</varlistentry>
29222922

2923+
<varlistentry id="guc-log-temp-files" xreflabel="log_temp_files">
2924+
<term><varname>log_temp_files</varname> (<type>integer</type>)</term>
2925+
<indexterm>
2926+
<primary><varname>log_temp_files</> configuration parameter</primary>
2927+
</indexterm>
2928+
<listitem>
2929+
<para>
2930+
Controls whether temporary files are logged when deleted.
2931+
A value of zero logs all temporary files, and positive
2932+
values log only files whose size is equal or greater than
2933+
the specified number of bytes. Temporary files can be
2934+
created for sorts, hashes, and temporary results. The
2935+
default is <literal>-1</> (off).
2936+
</para>
2937+
</listitem>
2938+
</varlistentry>
2939+
29232940
</variablelist>
29242941
</sect2>
29252942
</sect1>

‎src/backend/storage/file/fd.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.132 2007/01/05 22:19:37 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.133 2007/01/09 21:31:14 momjian Exp $
1111
*
1212
* NOTES:
1313
*
@@ -50,6 +50,7 @@
5050
#include"access/xact.h"
5151
#include"storage/fd.h"
5252
#include"storage/ipc.h"
53+
#include"utils/guc.h"
5354

5455

5556
/*
@@ -938,7 +939,8 @@ OpenTemporaryFile(bool interXact)
938939
void
939940
FileClose(Filefile)
940941
{
941-
Vfd*vfdP;
942+
Vfd*vfdP;
943+
structstatfilestats;
942944

943945
Assert(FileIsValid(file));
944946

@@ -968,6 +970,19 @@ FileClose(File file)
968970
{
969971
/* reset flag so that die() interrupt won't cause problems */
970972
vfdP->fdstate &= ~FD_TEMPORARY;
973+
PG_TRACE1(temp__file__cleanup,vfdP->fileName);
974+
if (log_temp_files >=0)
975+
{
976+
if (stat(vfdP->fileName,&filestats)==0)
977+
{
978+
if (filestats.st_size >=log_temp_files)
979+
ereport(LOG,
980+
(errmsg("temp file: path \"%s\" size %lu",
981+
vfdP->fileName, (unsigned long)filestats.st_size)));
982+
}
983+
else
984+
elog(LOG,"Could not stat \"%s\": %m",vfdP->fileName);
985+
}
971986
if (unlink(vfdP->fileName))
972987
elog(LOG,"failed to unlink \"%s\": %m",
973988
vfdP->fileName);

‎src/backend/utils/misc/guc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.365 2007/01/05 22:19:46 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.366 2007/01/09 21:31:14 momjian Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -182,6 +182,7 @@ intlog_min_error_statement = ERROR;
182182
intlog_min_messages=NOTICE;
183183
intclient_min_messages=NOTICE;
184184
intlog_min_duration_statement=-1;
185+
intlog_temp_files=-1;
185186

186187
intnum_temp_buffers=1000;
187188

@@ -1660,6 +1661,16 @@ static struct config_int ConfigureNamesInt[] =
16601661
&server_version_num,
16611662
PG_VERSION_NUM,PG_VERSION_NUM,PG_VERSION_NUM,NULL,NULL
16621663
},
1664+
1665+
{
1666+
{"log_temp_files",PGC_USERSET,LOGGING_WHAT,
1667+
gettext_noop("Log the use of temporary files larger than this size."),
1668+
gettext_noop("Zero logs all files. The default is -1 (turning this feature off)."),
1669+
NULL
1670+
},
1671+
&log_temp_files,
1672+
-1,-1,INT_MAX,NULL,NULL
1673+
},
16631674

16641675
/* End-of-list marker */
16651676
{

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@
333333
#log_statement = 'none'# none, ddl, mod, all
334334
#log_hostname = off
335335

336+
#log_temp_files = -1# Log temporary files equal or larger
337+
# than the specified number of bytes.
338+
# -1 disables; 0 logs all temp files
336339

337340
#---------------------------------------------------------------------------
338341
# RUNTIME STATISTICS

‎src/include/utils/guc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
88
* Written by Peter Eisentraut <peter_e@gmx.net>.
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.77 2007/01/05 22:19:59 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.78 2007/01/09 21:31:17 momjian Exp $
1111
*--------------------------------------------------------------------
1212
*/
1313
#ifndefGUC_H
@@ -123,6 +123,7 @@ extern intlog_min_error_statement;
123123
externintlog_min_messages;
124124
externintclient_min_messages;
125125
externintlog_min_duration_statement;
126+
externintlog_temp_files;
126127

127128
externintnum_temp_buffers;
128129

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp