A trivial fix on a comment in pgstat_assoc_relation()

First seen: 2026-05-15 06:09:41+00:00 · Messages: 1 · Participants: 1

Latest Update

2026-05-18 · claude-opus-4-6

Analysis: Trivial Comment Fix in pgstat_assoc_relation()

Core Problem

This is a minor code hygiene issue in PostgreSQL's statistics subsystem. The function pgstat_assoc_relation() contains a comment that begins with "Else find or make the PgStat_TableStatus entry, and update link". The word "Else" is a vestigial artifact from when this code was part of a larger function (pgstat_init_relation()), where the comment made sense as part of an if/else control flow narrative. After commit 5891c7a8ed8f refactored the code by splitting pgstat_assoc_relation() out as its own function, the "Else" prefix no longer has any logical antecedent within the function's scope and is misleading to readers.

Technical Context

The pgstat Subsystem

PostgreSQL's pgstat (statistics collector) subsystem tracks per-relation activity statistics (tuples inserted, updated, deleted, sequential/index scans, etc.). These statistics are critical for the autovacuum launcher and for the query planner's cost estimation.

Key structures involved:

The Refactoring (Commit 5891c7a8ed8f)

The original pgstat_init_relation() likely had a structure like:

if (some_condition) {
    /* Handle case where relation already has stats entry */
    ...
} else {
    /* Else find or make the PgStat_TableStatus entry, and update link */
    ...
}

When the "else" branch was extracted into pgstat_assoc_relation(), the comment was copied verbatim without updating it to reflect its new standalone context. The fix is trivially removing the word "Else" from the comment.

Proposed Solution

Remove the word "Else" from the comment, changing:

/* Else find or make the PgStat_TableStatus entry, and update link */

to:

/* Find or make the PgStat_TableStatus entry, and update link */

Significance

While the fix itself is trivial (a single-word deletion), it represents good code maintenance practice:

  1. Readability: Comments that reference non-existent control flow confuse new contributors trying to understand the code.
  2. Refactoring hygiene: When code is moved between functions, comments should be updated to match the new context.
  3. Low risk: This change has zero functional impact, making it a safe cleanup.

Assessment

This is a straightforward cosmetic fix that would typically be applied by a committer as a trivial patch without requiring formal review or a commitfest entry. It requires no testing beyond compilation verification. The patch is uncontroversial and likely to be committed quickly, possibly as part of a batch of small cleanups.