From cb78130dd3d6eebe00142657878803fc00d4e5a8 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Fri, 3 Jul 2026 17:12:29 +0200 Subject: [PATCH] Clean up get_histogram_bucket() In commit b2e5c69c2c1421e13ee7207201136e3a4ed3370d I accidentally pushed the wrong thing plus a typo in a comment. While at it also remove a pointless lower range check because we already know that as we loop from low to high. --- src/pg_stat_monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pg_stat_monitor.c b/src/pg_stat_monitor.c index 154799a1..e56c07ed 100644 --- a/src/pg_stat_monitor.c +++ b/src/pg_stat_monitor.c @@ -3099,13 +3099,13 @@ histogram_bucket_timings(int index, double *b_start, double *b_end) static int get_histogram_bucket(double q_time) { - for (int index = 0; index < hist_bucket_count_total - 1; index++) + for (int index = 0; index < hist_bucket_count_total; index++) { - if (q_time >= hist_bucket_timings[index].start && q_time <= hist_bucket_timings[index].end) + if (q_time <= hist_bucket_timings[index].end) return index; } - /* Given the uppermost bound is inifity we should never reach this */ + /* Given the uppermost bound is infinity we should never reach this */ return hist_bucket_count_total - 1; }