Re: pg_stat_statements temporary file - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: pg_stat_statements temporary file
Date
Msg-id CAEYLb_W8KX8O=_e5cL6w4hSTVbDPL=64dufUERje2eY3-zy9jw@mail.gmail.com
Whole thread Raw
In response to Re: pg_stat_statements temporary file  (Magnus Hagander <magnus@hagander.net>)
Responses Re: pg_stat_statements temporary file
Re: pg_stat_statements temporary file
Re: pg_stat_statements temporary file
List pgsql-hackers
On 25 May 2012 14:13, Magnus Hagander <magnus@hagander.net> wrote:
> Here's a patch that does the two easy fixes:
> 1) writes the file to a temp file and rename()s it over the main file
> as it writes down. This removes the (small) risk of corruption because
> of a crash during write
>
> 2) unlinks the file after reading it. this makes sure it's not
> included in online backups.

Seems reasonable. It might be better to consistently concatenate the
string literals PGSS_DUMP_FILE and ".tmp" statically. Also, I'd have
updated the string in the errmsg callsite after the "error" tag too,
to refer to the tmp file rather than the file proper. Forgive the
pedantry, but I should mention that I believe that it is project
policy to not use squiggly parenthesis following an if expression when
that is unnecessary due to there only being a single statement.

> I still think we should consider the placement of this file to not be
> in the global/ directory, but this is a quick (back-patchable) fix...

Where do you suggest the file be written to?

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] Make skipped sort explicit in EXPLAIN ANALYZE
Next
From: Andres Freund
Date:
Subject: Re: pg_stat_statements temporary file