mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Add GUC update_process_title to control whether 'ps' display is updated
for every command, default to on.
This commit is contained in:
parent
69d0a15e2a
commit
370a709c75
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.67 2006/06/27 19:07:50 momjian Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.68 2006/06/27 22:16:43 momjian Exp $ -->
|
||||
|
||||
<chapter Id="runtime-config">
|
||||
<title>Server Configuration</title>
|
||||
@ -2888,6 +2888,21 @@ SELECT * FROM parent WHERE key = 2400;
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-update-process-title" xreflabel="update_process_title">
|
||||
<term><varname>update_process_title</varname> (<type>boolean</type>)</term>
|
||||
<indexterm>
|
||||
<primary><varname>update_process_title</> configuration parameter</primary>
|
||||
</indexterm>
|
||||
<listitem>
|
||||
<para>
|
||||
Enables updating of the process title every time a new SQL command
|
||||
is received by the server. The process title is typically viewed
|
||||
by the <command>ps</> command or in Windows using the <application>Process
|
||||
Explorer</>. Only superusers can change this setting.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-stats-start-collector" xreflabel="stats_start_collector">
|
||||
<term><varname>stats_start_collector</varname> (<type>boolean</type>)</term>
|
||||
<indexterm>
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.217 2006/06/18 15:38:36 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.218 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -353,8 +353,7 @@ BootstrapMain(int argc, char *argv[])
|
||||
statmsg = "??? process";
|
||||
break;
|
||||
}
|
||||
init_ps_display(statmsg, "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display(statmsg, "", "", "");
|
||||
}
|
||||
|
||||
/* Acquire configuration parameters, unless inherited from postmaster */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.131 2006/04/25 14:11:54 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.132 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -908,7 +908,7 @@ ProcessIncomingNotify(void)
|
||||
if (Trace_notify)
|
||||
elog(DEBUG1, "ProcessIncomingNotify");
|
||||
|
||||
set_ps_display("notify interrupt");
|
||||
set_ps_display("notify interrupt", false);
|
||||
|
||||
notifyInterruptOccurred = 0;
|
||||
|
||||
@ -979,7 +979,7 @@ ProcessIncomingNotify(void)
|
||||
*/
|
||||
pq_flush();
|
||||
|
||||
set_ps_display("idle");
|
||||
set_ps_display("idle", false);
|
||||
|
||||
if (Trace_notify)
|
||||
elog(DEBUG1, "ProcessIncomingNotify: done");
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.20 2006/06/18 15:38:37 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.21 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -239,8 +239,7 @@ AutoVacMain(int argc, char *argv[])
|
||||
MyProcPid = getpid();
|
||||
|
||||
/* Identify myself via ps */
|
||||
init_ps_display("autovacuum process", "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display("autovacuum process", "", "", "");
|
||||
|
||||
SetProcessingMode(InitProcessing);
|
||||
|
||||
@ -416,7 +415,7 @@ AutoVacMain(int argc, char *argv[])
|
||||
*/
|
||||
InitPostgres(db->name, NULL);
|
||||
SetProcessingMode(NormalProcessing);
|
||||
set_ps_display(db->name);
|
||||
set_ps_display(db->name, false);
|
||||
ereport(DEBUG1,
|
||||
(errmsg("autovacuum: processing database \"%s\"", db->name)));
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.23 2006/06/18 15:38:37 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.24 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -244,8 +244,7 @@ PgArchiverMain(int argc, char *argv[])
|
||||
/*
|
||||
* Identify myself via ps
|
||||
*/
|
||||
init_ps_display("archiver process", "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display("archiver process", "", "", "");
|
||||
|
||||
pgarch_MainLoop();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.131 2006/06/27 03:45:16 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.132 2006/06/27 22:16:43 momjian Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@ -1743,8 +1743,7 @@ PgstatCollectorMain(int argc, char *argv[])
|
||||
/*
|
||||
* Identify myself via ps
|
||||
*/
|
||||
init_ps_display("stats collector process", "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display("stats collector process", "", "", "");
|
||||
|
||||
/*
|
||||
* Arrange to write the initial status file right away
|
||||
@ -1975,8 +1974,7 @@ pgstat_recvbuffer(void)
|
||||
/*
|
||||
* Identify myself via ps
|
||||
*/
|
||||
init_ps_display("stats buffer process", "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display("stats buffer process", "", "", "");
|
||||
|
||||
/*
|
||||
* We want to die if our child collector process does. There are two ways
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.488 2006/06/20 22:52:00 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.489 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -2713,9 +2713,9 @@ BackendInitialize(Port *port)
|
||||
* Now that we have the user and database name, we can set the process
|
||||
* title for ps. It's good to do this as early as possible in startup.
|
||||
*/
|
||||
init_ps_display(port->user_name, port->database_name, remote_ps_data);
|
||||
set_ps_display("authentication");
|
||||
|
||||
init_ps_display(port->user_name, port->database_name, remote_ps_data,
|
||||
update_process_title ? "authentication" : "");
|
||||
|
||||
/*
|
||||
* Now perform authentication exchange.
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.25 2006/06/18 15:38:37 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.26 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -141,8 +141,7 @@ SysLoggerMain(int argc, char *argv[])
|
||||
|
||||
am_syslogger = true;
|
||||
|
||||
init_ps_display("logger process", "", "");
|
||||
set_ps_display("");
|
||||
init_ps_display("logger process", "", "", "");
|
||||
|
||||
/*
|
||||
* If we restarted, our stderr is already redirected into our own input
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.164 2006/04/14 03:38:55 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.165 2006/06/27 22:16:43 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* A lock table is a shared memory hash table. When
|
||||
@ -1059,19 +1059,22 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
|
||||
LOCKMETHODID lockmethodid = LOCALLOCK_LOCKMETHOD(*locallock);
|
||||
LockMethod lockMethodTable = LockMethods[lockmethodid];
|
||||
const char *old_status;
|
||||
char *new_status;
|
||||
char *new_status = NULL;
|
||||
int len;
|
||||
|
||||
LOCK_PRINT("WaitOnLock: sleeping on lock",
|
||||
locallock->lock, locallock->tag.mode);
|
||||
|
||||
old_status = get_ps_display(&len);
|
||||
new_status = (char *) palloc(len + 8 + 1);
|
||||
memcpy(new_status, old_status, len);
|
||||
strcpy(new_status + len, " waiting");
|
||||
set_ps_display(new_status);
|
||||
new_status[len] = '\0'; /* truncate off " waiting" */
|
||||
|
||||
if (update_process_title)
|
||||
{
|
||||
old_status = get_ps_display(&len);
|
||||
new_status = (char *) palloc(len + 8 + 1);
|
||||
memcpy(new_status, old_status, len);
|
||||
strcpy(new_status + len, " waiting");
|
||||
set_ps_display(new_status, false);
|
||||
new_status[len] = '\0'; /* truncate off " waiting" */
|
||||
}
|
||||
|
||||
awaitedLock = locallock;
|
||||
awaitedOwner = owner;
|
||||
|
||||
@ -1108,8 +1111,11 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
|
||||
|
||||
awaitedLock = NULL;
|
||||
|
||||
set_ps_display(new_status);
|
||||
pfree(new_status);
|
||||
if (update_process_title)
|
||||
{
|
||||
set_ps_display(new_status, false);
|
||||
pfree(new_status);
|
||||
}
|
||||
|
||||
LOCK_PRINT("WaitOnLock: wakeup on lock",
|
||||
locallock->lock, locallock->tag.mode);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.489 2006/06/20 22:52:00 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.490 2006/06/27 22:16:44 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -910,7 +910,7 @@ exec_simple_query(const char *query_string)
|
||||
*/
|
||||
commandTag = CreateCommandTag(parsetree);
|
||||
|
||||
set_ps_display(commandTag);
|
||||
set_ps_display(commandTag, false);
|
||||
|
||||
BeginCommand(commandTag, dest);
|
||||
|
||||
@ -1144,7 +1144,7 @@ exec_parse_message(const char *query_string, /* string to execute */
|
||||
|
||||
pgstat_report_activity(query_string);
|
||||
|
||||
set_ps_display("PARSE");
|
||||
set_ps_display("PARSE", false);
|
||||
|
||||
if (save_log_statement_stats)
|
||||
ResetUsage();
|
||||
@ -1376,7 +1376,7 @@ exec_bind_message(StringInfo input_message)
|
||||
|
||||
pgstat_report_activity("<BIND>");
|
||||
|
||||
set_ps_display("BIND");
|
||||
set_ps_display("BIND", false);
|
||||
|
||||
/*
|
||||
* Start up a transaction command so we can call functions etc. (Note that
|
||||
@ -1711,7 +1711,7 @@ exec_execute_message(const char *portal_name, long max_rows)
|
||||
pgstat_report_activity("<EXECUTE>");
|
||||
}
|
||||
|
||||
set_ps_display(portal->commandTag);
|
||||
set_ps_display(portal->commandTag, false);
|
||||
|
||||
/*
|
||||
* We use save_log_statement_stats so ShowUsage doesn't report incorrect
|
||||
@ -2486,7 +2486,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (!IsUnderPostmaster)
|
||||
MemoryContextInit();
|
||||
|
||||
set_ps_display("startup");
|
||||
set_ps_display("startup", false);
|
||||
|
||||
SetProcessingMode(InitProcessing);
|
||||
|
||||
@ -3121,14 +3121,14 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
{
|
||||
if (IsTransactionOrTransactionBlock())
|
||||
{
|
||||
set_ps_display("idle in transaction");
|
||||
set_ps_display("idle in transaction", false);
|
||||
pgstat_report_activity("<IDLE> in transaction");
|
||||
}
|
||||
else
|
||||
{
|
||||
pgstat_report_tabstat();
|
||||
|
||||
set_ps_display("idle");
|
||||
set_ps_display("idle", false);
|
||||
pgstat_report_activity("<IDLE>");
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.323 2006/06/27 19:07:50 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.324 2006/06/27 22:16:44 momjian Exp $
|
||||
*
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,6 +64,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/pg_locale.h"
|
||||
#include "utils/ps_status.h"
|
||||
#include "pgstat.h"
|
||||
#include "access/gin.h"
|
||||
|
||||
@ -728,6 +729,16 @@ static struct config_bool ConfigureNamesBool[] =
|
||||
true, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"update_process_title", PGC_SUSET, STATS_COLLECTOR,
|
||||
gettext_noop("Updates the process title to show the active SQL command."),
|
||||
gettext_noop("Enables updating of the process title every time a new
|
||||
SQL command is received by the server.")
|
||||
},
|
||||
&update_process_title,
|
||||
true, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"autovacuum", PGC_SIGHUP, AUTOVACUUM,
|
||||
gettext_noop("Starts the autovacuum subprocess."),
|
||||
|
@ -323,11 +323,14 @@
|
||||
# - Query/Index Statistics Collector -
|
||||
|
||||
#stats_command_string = on
|
||||
#update_process_title = on
|
||||
|
||||
#stats_start_collector = on # needed for block or row stats
|
||||
#stats_block_level = off
|
||||
#stats_row_level = off
|
||||
#stats_reset_on_server_start = off
|
||||
|
||||
|
||||
# - Statistics Monitoring -
|
||||
|
||||
#log_parser_stats = off
|
||||
|
@ -5,7 +5,7 @@
|
||||
* to contain some useful information. Mechanism differs wildly across
|
||||
* platforms.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.30 2006/06/12 02:39:49 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.31 2006/06/27 22:16:44 momjian Exp $
|
||||
*
|
||||
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
|
||||
* various details abducted from various places
|
||||
@ -31,6 +31,7 @@
|
||||
#include "utils/ps_status.h"
|
||||
|
||||
extern char **environ;
|
||||
bool update_process_title = true;
|
||||
|
||||
|
||||
/*
|
||||
@ -210,7 +211,7 @@ save_ps_display_args(int argc, char **argv)
|
||||
*/
|
||||
void
|
||||
init_ps_display(const char *username, const char *dbname,
|
||||
const char *host_info)
|
||||
const char *host_info, const char *initial_str)
|
||||
{
|
||||
Assert(username);
|
||||
Assert(dbname);
|
||||
@ -270,6 +271,7 @@ init_ps_display(const char *username, const char *dbname,
|
||||
|
||||
ps_buffer_fixed_size = strlen(ps_buffer);
|
||||
|
||||
set_ps_display(initial_str, true);
|
||||
#endif /* not PS_USE_NONE */
|
||||
}
|
||||
|
||||
@ -280,8 +282,12 @@ init_ps_display(const char *username, const char *dbname,
|
||||
* indication of what you're currently doing passed in the argument.
|
||||
*/
|
||||
void
|
||||
set_ps_display(const char *activity)
|
||||
set_ps_display(const char *activity, bool force)
|
||||
{
|
||||
|
||||
if (!force && !update_process_title)
|
||||
return;
|
||||
|
||||
#ifndef PS_USE_NONE
|
||||
/* no ps display for stand-alone backend */
|
||||
if (!IsUnderPostmaster)
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Declarations for backend/utils/misc/ps_status.c
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/ps_status.h,v 1.26 2005/11/05 03:04:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/ps_status.h,v 1.27 2006/06/27 22:16:44 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -12,12 +12,14 @@
|
||||
#ifndef PS_STATUS_H
|
||||
#define PS_STATUS_H
|
||||
|
||||
extern bool update_process_title;
|
||||
|
||||
extern char **save_ps_display_args(int argc, char **argv);
|
||||
|
||||
extern void init_ps_display(const char *username, const char *dbname,
|
||||
const char *host_info);
|
||||
const char *host_info, const char *initial_str);
|
||||
|
||||
extern void set_ps_display(const char *activity);
|
||||
extern void set_ps_display(const char *activity, bool force);
|
||||
|
||||
extern const char *get_ps_display(int *displen);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user