1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Make the temporary directory for pgstat files configurable by the GUC

variable stats_temp_directory, instead of requiring the admin to
mount/symlink the pg_stat_tmp directory manually.

For now the config variable is PGC_POSTMASTER. Room for further improvment
that would allow it to be changed on-the-fly.
This commit is contained in:
Magnus Hagander
2008-08-15 08:37:41 +00:00
parent f24f233f6a
commit 5b8eb2b4b9
6 changed files with 71 additions and 14 deletions

View File

@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.465 2008/07/23 17:29:53 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.466 2008/08/15 08:37:40 mha Exp $
*
*--------------------------------------------------------------------
*/
@@ -164,6 +164,7 @@ static const char *show_tcp_keepalives_interval(void);
static const char *show_tcp_keepalives_count(void);
static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);
static bool assign_maxconnections(int newval, bool doit, GucSource source);
static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source);
static char *config_enum_get_options(struct config_enum *record,
const char *prefix, const char *suffix);
@@ -343,6 +344,8 @@ char *HbaFileName;
char *IdentFileName;
char *external_pid_file;
char *pgstat_temp_directory;
int tcp_keepalives_idle;
int tcp_keepalives_interval;
int tcp_keepalives_count;
@@ -2466,6 +2469,16 @@ static struct config_string ConfigureNamesString[] =
NULL, assign_canonical_path, NULL
},
{
{"stats_temp_directory", PGC_POSTMASTER, STATS_COLLECTOR,
gettext_noop("Writes temporary statistics files to the specified directory."),
NULL,
GUC_SUPERUSER_ONLY
},
&pgstat_temp_directory,
"pg_stat_tmp", assign_pgstat_temp_directory, NULL
},
{
{"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
gettext_noop("Sets default text search configuration."),
@@ -7370,4 +7383,24 @@ assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
return true;
}
static const char *
assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source)
{
if (doit)
{
if (pgstat_stat_tmpname)
free(pgstat_stat_tmpname);
if (pgstat_stat_filename)
free(pgstat_stat_filename);
pgstat_stat_tmpname = guc_malloc(FATAL, strlen(newval) + 12); /* /pgstat.tmp */
pgstat_stat_filename = guc_malloc(FATAL, strlen(newval) + 13); /* /pgstat.stat */
sprintf(pgstat_stat_tmpname, "%s/pgstat.tmp", newval);
sprintf(pgstat_stat_filename, "%s/pgstat.stat", newval);
}
return newval;
}
#include "guc-file.c"

View File

@@ -366,6 +366,7 @@
#track_functions = none # none, pl, all
#track_activity_query_size = 1024
#update_process_title = on
#stats_temp_directory = 'pg_stat_tmp'
# - Statistics Monitoring -