Fix memqcache_stats_start_time shown in "show pool_status". master
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 2 Dec 2025 10:26:55 +0000 (19:26 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 2 Dec 2025 10:26:55 +0000 (19:26 +0900)
get_config() uses ctime() to generate printable form of
memqcache_stats_start_time. But it did not take into account that
ctime() adds newline at the end of result. As a result, not only the
output of memqcache_stats_start_time was with unnecessary newline but
next row printed empty items.

Author: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://www.postgresql.org/message-id/20251130.102712.131456481338876013.ishii%40postgresql.org
Backpatch-through: v4.3

src/utils/pool_process_reporting.c

index e4fcf4457e20bc0a6c09f55e8b9c5105e83ae93e..9e677d95e279aad229066654dc6c2351936597cf 100644 (file)
@@ -1117,6 +1117,8 @@ get_config(int *nrows)
 
        StrNCpy(status[i].name, "memqcache_stats_start_time", POOLCONFIG_MAXNAMELEN);
        snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", ctime(&pool_get_memqcache_stats()->start_time));
+       /* remove a newline added by ctime() */
+       *(strchrnul(status[i].value, '\n')) = '\0';
        StrNCpy(status[i].desc, "Start time of query cache stats", POOLCONFIG_MAXDESCLEN);
        i++;