From e850690d9c7ff8382cc9bc1cbf438722870e8b8a Mon Sep 17 00:00:00 2001 From: Chengpeng Yan Date: Sat, 7 Feb 2026 19:55:40 +0800 Subject: [PATCH v4 2/2] ANALYZE: harden firstcount1 tracking in hash mode --- src/backend/commands/analyze.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index f7a5d2d46dd..3a2c6a2e155 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -2326,10 +2326,10 @@ compute_distinct_stats(VacAttrStatsP stats, } /* - * In hash mode, a promoted singleton advances the first singleton - * boundary by one slot. + * In hash mode, keep firstcount1 at the first singleton boundary. */ - if (use_hash && was_count1 && j <= firstcount1) + while (use_hash && firstcount1 < track_cnt && + track[firstcount1].count > 1) firstcount1++; /* -- 2.50.1 (Apple Git-155)