Technical Analysis: Fix errhint Messages for REPACK (CONCURRENTLY) Restrictions
Core Problem
This patch addresses a cosmetic but user-facing consistency issue in PostgreSQL's error hint messages for the REPACK (CONCURRENTLY) command. The problem stems from commit 28d534e2ae0, which introduced restrictions for concurrent repack operations but contained two defects in the errhint() calls:
-
Syntax inconsistency: The hint messages referenced
REPACK CONCURRENTLY(without parentheses), while the actual SQL syntax and the correspondingerrmsg()text in the same file useREPACK (CONCURRENTLY). This creates confusion for users who see a hint referring to a syntactically different command form than what they actually typed or what the error message references. -
Missing trailing period: The TOAST relations hint lacked a terminating period, violating PostgreSQL's established message style guidelines (see
src/tools/pgindent/typedefs.listand the error message style guide in the documentation). PostgreSQL conventions require that hint messages end with a period.
Architectural Context
Why This Matters
While seemingly trivial, message consistency in PostgreSQL is architecturally significant for several reasons:
-
Internationalization (i18n): PostgreSQL's messages go through
gettextfor translation. The patch also switches to a%sformat pattern, which means translators handle a template without needing to embed the SQL command name directly. This reduces translation errors across the ~50+ language catalogs and ensures that if the command syntax ever changes, only the format argument needs updating rather than every translation. -
User experience consistency: PostgreSQL has strict coding standards for error messages (
src/tools/pgindent/guidelines). Error messages useerrmsg(), hints useerrhint(), and both must follow formatting rules. Inconsistency betweenerrmsganderrhintin the same error path is a violation of these standards. -
REPACK (CONCURRENTLY) is a newer feature: The parenthesized syntax
REPACK (CONCURRENTLY)follows the same pattern asVACUUM (FULL),REINDEX (CONCURRENTLY), etc. — the parenthesized options form that PostgreSQL has standardized on. Using the non-parenthesized form in hints could mislead users about the actual syntax.
The Fix
The patch is straightforward:
- Changes
"REPACK CONCURRENTLY"→"REPACK (CONCURRENTLY)"in all affectederrhint()calls - Adds missing trailing period to the TOAST relations hint
- Uses
%sformat specifier for the command name, improving translatability
Before:
errhint("REPACK CONCURRENTLY is not supported for TOAST relations")
After:
errhint("%s is not supported for TOAST relations.", "REPACK (CONCURRENTLY)")
This pattern (using %s for SQL keywords that should not be translated) is a well-established PostgreSQL convention that ensures translators don't accidentally translate or modify SQL syntax embedded in messages.
Design Decisions
The key design decision here is the use of %s formatting rather than simply hardcoding the corrected string. This is a deliberate choice that:
- Follows the PostgreSQL convention of separating translatable text from SQL syntax
- Makes future maintenance easier if the command name changes
- Prevents translation catalogs from containing SQL keywords that might be incorrectly localized
Risk Assessment
This is an extremely low-risk change — it modifies only string literals in error reporting paths, with no behavioral or logical changes. The fast turnaround from submission to commit (under 24 hours) reflects this low risk profile.