From a7908de4a2f181f3f2646d55f31969748d951362 Mon Sep 17 00:00:00 2001 From: Zsolt Parragi Date: Fri, 20 Jun 2025 08:10:03 +0100 Subject: [PATCH] PG-1674: Fix query hash calculation comment removal logic The previous conditions only removed the first few starting characters of the comment, and leaved everything else there. This modification fixes this and correctly removes everything. --- pg_stat_monitor.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 75ca49e..b2f87a5 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -2715,12 +2715,19 @@ get_pgsm_query_id_hash(const char *norm_query, int norm_len) */ if (*norm_q_iter == '/' && *(norm_q_iter + 1) == '*') { - while (*norm_q_iter && *norm_q_iter != '*' && *(norm_q_iter + 1) != '/') + while (*norm_q_iter && *(norm_q_iter + 1) && (*norm_q_iter != '*' || *(norm_q_iter + 1) != '/')) norm_q_iter++; - /* Skip the '/' if the current character is valid. */ + /* + * Skip the end if the current character is valid. norm_q_iter + * points to the *, we have to skip 2 characters + */ if (*norm_q_iter) norm_q_iter++; + if (*norm_q_iter) + norm_q_iter++; + + continue; } /*