aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/ps_status.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2020-03-11 16:36:40 +0100
committerPeter Eisentraut <peter@eisentraut.org>2020-03-11 16:38:31 +0100
commitbf68b79e50e3359accc85c94fa23cc03abb9350a (patch)
tree0b09b97eec0aa5978ab073e580cf97a51014dd66 /src/backend/utils/misc/ps_status.c
parent899a04f5ed61c3db7a2bd84957ecf530c09fd05a (diff)
downloadpostgresql-bf68b79e50e3359accc85c94fa23cc03abb9350a.tar.gz
postgresql-bf68b79e50e3359accc85c94fa23cc03abb9350a.zip
Refactor ps_status.c API
The init_ps_display() arguments were mostly lies by now, so to match typical usage, just use one argument and let the caller assemble it from multiple sources if necessary. The only user of the additional arguments is BackendInitialize(), which was already doing string assembly on the caller side anyway. Remove the second argument of set_ps_display() ("force") and just handle that in init_ps_display() internally. BackendInitialize() also used to set the initial status as "authentication", but that was very far from where authentication actually happened. So now it's set to "initializing" and then "authentication" just before the actual call to ClientAuthentication(). Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com
Diffstat (limited to 'src/backend/utils/misc/ps_status.c')
-rw-r--r--src/backend/utils/misc/ps_status.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index ed23c840e95..8b160c0b405 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -250,12 +250,11 @@ save_ps_display_args(int argc, char **argv)
* values. At this point, the original argv[] array may be overwritten.
*/
void
-init_ps_display(const char *username, const char *dbname,
- const char *host_info, const char *initial_str)
+init_ps_display(const char *fixed_part)
{
- Assert(username);
- Assert(dbname);
- Assert(host_info);
+ bool save_update_process_title;
+
+ Assert(fixed_part);
#ifndef PS_USE_NONE
/* no ps display for stand-alone backend */
@@ -309,19 +308,25 @@ init_ps_display(const char *username, const char *dbname,
if (*cluster_name == '\0')
{
snprintf(ps_buffer, ps_buffer_size,
- PROGRAM_NAME_PREFIX "%s %s %s ",
- username, dbname, host_info);
+ PROGRAM_NAME_PREFIX "%s ",
+ fixed_part);
}
else
{
snprintf(ps_buffer, ps_buffer_size,
- PROGRAM_NAME_PREFIX "%s: %s %s %s ",
- cluster_name, username, dbname, host_info);
+ PROGRAM_NAME_PREFIX "%s: %s ",
+ cluster_name, fixed_part);
}
ps_buffer_cur_len = ps_buffer_fixed_size = strlen(ps_buffer);
- set_ps_display(initial_str, true);
+ /*
+ * On the first run, force the update.
+ */
+ save_update_process_title = update_process_title;
+ update_process_title = true;
+ set_ps_display("");
+ update_process_title = save_update_process_title;
#endif /* not PS_USE_NONE */
}
@@ -332,11 +337,11 @@ 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, bool force)
+set_ps_display(const char *activity)
{
#ifndef PS_USE_NONE
- /* update_process_title=off disables updates, unless force = true */
- if (!force && !update_process_title)
+ /* update_process_title=off disables updates */
+ if (!update_process_title)
return;
/* no ps display for stand-alone backend */