Re: [PATCHES] Patch to log usage of temporary files

2007-01-02 Thread Alvaro Herrera
Bill Moran wrote:
 
 Thanks to Simon Riggs and Bruce for input that helped me put this together.

Please change things to save the stat() syscall when the feature is not
in use.

Nitpick: also note our brace placement convention (though this would be
fixed by pgindent, but still).

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [PATCHES] Patch to log usage of temporary files

2007-01-02 Thread Andrew Dunstan

Bill Moran wrote:

+   if (stat(vfdP-fileName, filestats) == 0) {
+   if (trace_temp_files)
  

Shouldn't these tests be the other way around?

cheers

andrew

---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

   http://www.postgresql.org/about/donate


Re: [PATCHES] Patch to log usage of temporary files

2007-01-02 Thread Bill Moran
In response to Alvaro Herrera [EMAIL PROTECTED]:

 Bill Moran wrote:
  
  Thanks to Simon Riggs and Bruce for input that helped me put this together.
 
 Please change things to save the stat() syscall when the feature is not
 in use.

Do you have a suggestion on how to do that and still have the PG_TRACE1()
work?  That was specifically requested by Simon Riggs.

I'm not at all familiar with how the PG_TRACE probes work, so I'd be
interested to hear suggestions on how to wrap that in an if.  If I remove
the PG_TRACE, it becomes a simple matter to skip the stat() if the feature
is disabled.

 Nitpick: also note our brace placement convention (though this would be
 fixed by pgindent, but still).

Sorry, I thought I _was_ following the convention.  Must have missed
something.  Is there a written style guide somewhere?  Might drive things
home a little better than just looking at other folks code.

-- 
Bill Moran
Collaborative Fusion Inc.

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [PATCHES] Patch to log usage of temporary files

2007-01-02 Thread Tom Lane
Bill Moran [EMAIL PROTECTED] writes:
 In response to Alvaro Herrera [EMAIL PROTECTED]:
 Please change things to save the stat() syscall when the feature is not
 in use.

 Do you have a suggestion on how to do that and still have the PG_TRACE1()
 work?  That was specifically requested by Simon Riggs.

Well, we are NOT paying a stat() call on every single file close,
whether Simon wants it or not.  PG_TRACE1 doesn't even do anything
on non-Solaris platforms, for pete's sake.

Perhaps it would be reasonable to define trace_temp_files as the minimum
file size to log; then you could do something like

if (trace_temp_files  0)
{
if (stat(vfdP-fileName, filestats)  0)
elog(LOG, ...);
else
{
if (filestats.st_size / BLCKSZ = trace_temp_files)
ereport(LOG, ...);
PG_TRACE1(temp__file__cleanup, filestats.st_size);
}
}

Note that elog(ERROR) is quite inappropriate here.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster