Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit370a709

Browse files
committed
Add GUC update_process_title to control whether 'ps' display is updated
for every command, default to on.
1 parent69d0a15 commit370a709

File tree

14 files changed

+89
-52
lines changed

14 files changed

+89
-52
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.67 2006/06/2719:07:50 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.68 2006/06/2722:16:43 momjian Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -2888,6 +2888,21 @@ SELECT * FROM parent WHERE key = 2400;
28882888
</listitem>
28892889
</varlistentry>
28902890

2891+
<varlistentry id="guc-update-process-title" xreflabel="update_process_title">
2892+
<term><varname>update_process_title</varname> (<type>boolean</type>)</term>
2893+
<indexterm>
2894+
<primary><varname>update_process_title</> configuration parameter</primary>
2895+
</indexterm>
2896+
<listitem>
2897+
<para>
2898+
Enables updating of the process title every time a new SQL command
2899+
is received by the server. The process title is typically viewed
2900+
by the <command>ps</> command or in Windows using the <application>Process
2901+
Explorer</>. Only superusers can change this setting.
2902+
</para>
2903+
</listitem>
2904+
</varlistentry>
2905+
28912906
<varlistentry id="guc-stats-start-collector" xreflabel="stats_start_collector">
28922907
<term><varname>stats_start_collector</varname> (<type>boolean</type>)</term>
28932908
<indexterm>

‎src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.217 2006/06/18 15:38:36 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.218 2006/06/27 22:16:43 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -353,8 +353,7 @@ BootstrapMain(int argc, char *argv[])
353353
statmsg="??? process";
354354
break;
355355
}
356-
init_ps_display(statmsg,"","");
357-
set_ps_display("");
356+
init_ps_display(statmsg,"","","");
358357
}
359358

360359
/* Acquire configuration parameters, unless inherited from postmaster */

‎src/backend/commands/async.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.131 2006/04/25 14:11:54 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.132 2006/06/27 22:16:43 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -908,7 +908,7 @@ ProcessIncomingNotify(void)
908908
if (Trace_notify)
909909
elog(DEBUG1,"ProcessIncomingNotify");
910910

911-
set_ps_display("notify interrupt");
911+
set_ps_display("notify interrupt", false);
912912

913913
notifyInterruptOccurred=0;
914914

@@ -979,7 +979,7 @@ ProcessIncomingNotify(void)
979979
*/
980980
pq_flush();
981981

982-
set_ps_display("idle");
982+
set_ps_display("idle", false);
983983

984984
if (Trace_notify)
985985
elog(DEBUG1,"ProcessIncomingNotify: done");

‎src/backend/postmaster/autovacuum.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.20 2006/06/18 15:38:37 petere Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.21 2006/06/27 22:16:43 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -239,8 +239,7 @@ AutoVacMain(int argc, char *argv[])
239239
MyProcPid=getpid();
240240

241241
/* Identify myself via ps */
242-
init_ps_display("autovacuum process","","");
243-
set_ps_display("");
242+
init_ps_display("autovacuum process","","","");
244243

245244
SetProcessingMode(InitProcessing);
246245

@@ -416,7 +415,7 @@ AutoVacMain(int argc, char *argv[])
416415
*/
417416
InitPostgres(db->name,NULL);
418417
SetProcessingMode(NormalProcessing);
419-
set_ps_display(db->name);
418+
set_ps_display(db->name, false);
420419
ereport(DEBUG1,
421420
(errmsg("autovacuum: processing database \"%s\"",db->name)));
422421

‎src/backend/postmaster/pgarch.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.23 2006/06/18 15:38:37 petere Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.24 2006/06/27 22:16:43 momjian Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -244,8 +244,7 @@ PgArchiverMain(int argc, char *argv[])
244244
/*
245245
* Identify myself via ps
246246
*/
247-
init_ps_display("archiver process","","");
248-
set_ps_display("");
247+
init_ps_display("archiver process","","","");
249248

250249
pgarch_MainLoop();
251250

‎src/backend/postmaster/pgstat.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2006, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.131 2006/06/2703:45:16 alvherre Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.132 2006/06/2722:16:43 momjian Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -1743,8 +1743,7 @@ PgstatCollectorMain(int argc, char *argv[])
17431743
/*
17441744
* Identify myself via ps
17451745
*/
1746-
init_ps_display("stats collector process","","");
1747-
set_ps_display("");
1746+
init_ps_display("stats collector process","","","");
17481747

17491748
/*
17501749
* Arrange to write the initial status file right away
@@ -1975,8 +1974,7 @@ pgstat_recvbuffer(void)
19751974
/*
19761975
* Identify myself via ps
19771976
*/
1978-
init_ps_display("stats buffer process","","");
1979-
set_ps_display("");
1977+
init_ps_display("stats buffer process","","","");
19801978

19811979
/*
19821980
* We want to die if our child collector process does.There are two ways

‎src/backend/postmaster/postmaster.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.488 2006/06/20 22:52:00 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.489 2006/06/27 22:16:43 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -2713,9 +2713,9 @@ BackendInitialize(Port *port)
27132713
* Now that we have the user and database name, we can set the process
27142714
* title for ps. It's good to do this as early as possible in startup.
27152715
*/
2716-
init_ps_display(port->user_name,port->database_name,remote_ps_data);
2717-
set_ps_display("authentication");
2718-
2716+
init_ps_display(port->user_name,port->database_name,remote_ps_data,
2717+
update_process_title ?"authentication" :"");
2718+
27192719
/*
27202720
* Now perform authentication exchange.
27212721
*/

‎src/backend/postmaster/syslogger.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.25 2006/06/18 15:38:37 petere Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.26 2006/06/27 22:16:43 momjian Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -141,8 +141,7 @@ SysLoggerMain(int argc, char *argv[])
141141

142142
am_syslogger= true;
143143

144-
init_ps_display("logger process","","");
145-
set_ps_display("");
144+
init_ps_display("logger process","","","");
146145

147146
/*
148147
* If we restarted, our stderr is already redirected into our own input

‎src/backend/storage/lmgr/lock.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.164 2006/04/14 03:38:55 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.165 2006/06/27 22:16:43 momjian Exp $
1212
*
1313
* NOTES
1414
* A lock table is a shared memory hash table. When
@@ -1059,19 +1059,22 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
10591059
LOCKMETHODIDlockmethodid=LOCALLOCK_LOCKMETHOD(*locallock);
10601060
LockMethodlockMethodTable=LockMethods[lockmethodid];
10611061
constchar*old_status;
1062-
char*new_status;
1062+
char*new_status=NULL;
10631063
intlen;
10641064

10651065
LOCK_PRINT("WaitOnLock: sleeping on lock",
10661066
locallock->lock,locallock->tag.mode);
10671067

1068-
old_status=get_ps_display(&len);
1069-
new_status= (char*)palloc(len+8+1);
1070-
memcpy(new_status,old_status,len);
1071-
strcpy(new_status+len," waiting");
1072-
set_ps_display(new_status);
1073-
new_status[len]='\0';/* truncate off " waiting" */
1074-
1068+
if (update_process_title)
1069+
{
1070+
old_status=get_ps_display(&len);
1071+
new_status= (char*)palloc(len+8+1);
1072+
memcpy(new_status,old_status,len);
1073+
strcpy(new_status+len," waiting");
1074+
set_ps_display(new_status, false);
1075+
new_status[len]='\0';/* truncate off " waiting" */
1076+
}
1077+
10751078
awaitedLock=locallock;
10761079
awaitedOwner=owner;
10771080

@@ -1108,8 +1111,11 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
11081111

11091112
awaitedLock=NULL;
11101113

1111-
set_ps_display(new_status);
1112-
pfree(new_status);
1114+
if (update_process_title)
1115+
{
1116+
set_ps_display(new_status, false);
1117+
pfree(new_status);
1118+
}
11131119

11141120
LOCK_PRINT("WaitOnLock: wakeup on lock",
11151121
locallock->lock,locallock->tag.mode);

‎src/backend/tcop/postgres.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.489 2006/06/20 22:52:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.490 2006/06/27 22:16:44 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -910,7 +910,7 @@ exec_simple_query(const char *query_string)
910910
*/
911911
commandTag=CreateCommandTag(parsetree);
912912

913-
set_ps_display(commandTag);
913+
set_ps_display(commandTag, false);
914914

915915
BeginCommand(commandTag,dest);
916916

@@ -1144,7 +1144,7 @@ exec_parse_message(const char *query_string,/* string to execute */
11441144

11451145
pgstat_report_activity(query_string);
11461146

1147-
set_ps_display("PARSE");
1147+
set_ps_display("PARSE", false);
11481148

11491149
if (save_log_statement_stats)
11501150
ResetUsage();
@@ -1376,7 +1376,7 @@ exec_bind_message(StringInfo input_message)
13761376

13771377
pgstat_report_activity("<BIND>");
13781378

1379-
set_ps_display("BIND");
1379+
set_ps_display("BIND", false);
13801380

13811381
/*
13821382
* 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)
17111711
pgstat_report_activity("<EXECUTE>");
17121712
}
17131713

1714-
set_ps_display(portal->commandTag);
1714+
set_ps_display(portal->commandTag, false);
17151715

17161716
/*
17171717
* We use save_log_statement_stats so ShowUsage doesn't report incorrect
@@ -2486,7 +2486,7 @@ PostgresMain(int argc, char *argv[], const char *username)
24862486
if (!IsUnderPostmaster)
24872487
MemoryContextInit();
24882488

2489-
set_ps_display("startup");
2489+
set_ps_display("startup", false);
24902490

24912491
SetProcessingMode(InitProcessing);
24922492

@@ -3121,14 +3121,14 @@ PostgresMain(int argc, char *argv[], const char *username)
31213121
{
31223122
if (IsTransactionOrTransactionBlock())
31233123
{
3124-
set_ps_display("idle in transaction");
3124+
set_ps_display("idle in transaction", false);
31253125
pgstat_report_activity("<IDLE> in transaction");
31263126
}
31273127
else
31283128
{
31293129
pgstat_report_tabstat();
31303130

3131-
set_ps_display("idle");
3131+
set_ps_display("idle", false);
31323132
pgstat_report_activity("<IDLE>");
31333133
}
31343134

‎src/backend/utils/misc/guc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.323 2006/06/2719:07:50 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.324 2006/06/2722:16:44 momjian Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -64,6 +64,7 @@
6464
#include"utils/builtins.h"
6565
#include"utils/memutils.h"
6666
#include"utils/pg_locale.h"
67+
#include"utils/ps_status.h"
6768
#include"pgstat.h"
6869
#include"access/gin.h"
6970

@@ -728,6 +729,16 @@ static struct config_bool ConfigureNamesBool[] =
728729
true,NULL,NULL
729730
},
730731

732+
{
733+
{"update_process_title",PGC_SUSET,STATS_COLLECTOR,
734+
gettext_noop("Updates the process title to show the active SQL command."),
735+
gettext_noop("Enables updating of the process title every time a new
736+
SQLcommandisreceivedbytheserver.")
737+
},
738+
&update_process_title,
739+
true,NULL,NULL
740+
},
741+
731742
{
732743
{"autovacuum",PGC_SIGHUP,AUTOVACUUM,
733744
gettext_noop("Starts the autovacuum subprocess."),

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,14 @@
323323
# - Query/Index Statistics Collector -
324324

325325
#stats_command_string = on
326+
#update_process_title = on
327+
326328
#stats_start_collector = on# needed for block or row stats
327329
#stats_block_level = off
328330
#stats_row_level = off
329331
#stats_reset_on_server_start = off
330332

333+
331334
# - Statistics Monitoring -
332335

333336
#log_parser_stats = off

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp