for every command, default to on.
-<!-- $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>
</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>
* 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 $
*
*-------------------------------------------------------------------------
*/
statmsg = "??? process";
break;
}
- init_ps_display(statmsg, "", "");
- set_ps_display("");
+ init_ps_display(statmsg, "", "", "");
}
/* Acquire configuration parameters, unless inherited from postmaster */
* 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 $
*
*-------------------------------------------------------------------------
*/
if (Trace_notify)
elog(DEBUG1, "ProcessIncomingNotify");
- set_ps_display("notify interrupt");
+ set_ps_display("notify interrupt", false);
notifyInterruptOccurred = 0;
*/
pq_flush();
- set_ps_display("idle");
+ set_ps_display("idle", false);
if (Trace_notify)
elog(DEBUG1, "ProcessIncomingNotify: done");
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
MyProcPid = getpid();
/* Identify myself via ps */
- init_ps_display("autovacuum process", "", "");
- set_ps_display("");
+ init_ps_display("autovacuum process", "", "", "");
SetProcessingMode(InitProcessing);
*/
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)));
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* Identify myself via ps
*/
- init_ps_display("archiver process", "", "");
- set_ps_display("");
+ init_ps_display("archiver process", "", "", "");
pgarch_MainLoop();
*
* 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"
/*
* 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
/*
* 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
*
*
* 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
*
* 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.
*/
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
*
*
* 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
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;
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);
*
*
* 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
*/
commandTag = CreateCommandTag(parsetree);
- set_ps_display(commandTag);
+ set_ps_display(commandTag, false);
BeginCommand(commandTag, dest);
pgstat_report_activity(query_string);
- set_ps_display("PARSE");
+ set_ps_display("PARSE", false);
if (save_log_statement_stats)
ResetUsage();
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
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
if (!IsUnderPostmaster)
MemoryContextInit();
- set_ps_display("startup");
+ set_ps_display("startup", false);
SetProcessingMode(InitProcessing);
{
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>");
}
* 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 $
*
*--------------------------------------------------------------------
*/
#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"
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."),
# - 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
* 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
#include "utils/ps_status.h"
extern char **environ;
+bool update_process_title = true;
/*
*/
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);
ps_buffer_fixed_size = strlen(ps_buffer);
+ set_ps_display(initial_str, true);
#endif /* not PS_USE_NONE */
}
* 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)
*
* 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 $
*
*-------------------------------------------------------------------------
*/
#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);