Skip to content

EXPLAIN output header customization #765

Description

@apstndb

Existing behavior and remaining gap

CLI_ANALYZE_COLUMNS already customizes names for analyze-only statistic columns (<name>:<template>[:alignment]). The base Operator header already shortens to Operator when effective WIDTH is nonzero and below the existing threshold; wide/unlimited output keeps Operator <execution_method> (metadata, ...). Preserve both features.

The remaining gap is explicit control over the Operator presentation label independently of wrap width. For example, a user cannot select Op or always use Operator while keeping WIDTH unlimited.

Accepted implementation

Add one session string variable, CLI_EXPLAIN_OPERATOR_HEADER, default empty. Empty or whitespace-only preserves the existing WIDTH-based behavior. Trim surrounding whitespace on assignment and use a nonempty result as a literal label at every width. Ordinary Unicode labels are supported; reject embedded control characters before changing state. Reuse existing string-variable validation and Display configuration patterns.

  • Keep ID and custom analyze-column names independent.
  • Use existing SET/SHOW/RESET and SET LOCAL restoration behavior.
  • Thread the value through explainBaseColumnNames / explainAnalyzeHeader, used by generateExplainResult and buildExplainAnalyzeResult; do not create another renderer.
  • Apply consistently to EXPLAIN, ANALYZE SELECT/DML, LAST QUERY and query PROFILE plan tables.
  • WIDTH continues to wrap operator cell content; a deliberately long header may widen the table. This feature does not truncate labels or redesign terminal width allocation.
  • Preserve normal query-result metadata/row values and raw plan JSON/YAML/DOT. Keep the existing table-output rules; do not redefine machine exports.

Verification and scope

Cover default wide/narrow output, explicit label at both widths, Unicode and control-character rejection with unchanged prior state, RESET and LOCAL restoration, independent analyze aliases, actual result builders and representative rendered table/CSV output. Verify raw plan formats retain their existing representation. Assert actual error causes rather than accepting any error.

Update user documentation with examples and the long-header limitation. No dependency upgrade, template/mapping grammar, metadata-notation change (#764), truncation work (#284), parallel renderer or new compatibility flag is needed because defaults remain unchanged.

Deliver one PR linked with Fixes #765. Before each push, integrate main additively and run focused tests, make check and make check-race, capturing output and checking exit codes. Keep the CI coverage floor at 80%.

Design verified against 28d9ed4047620e9df2c431f508b07aebc2830b25 on 2026-09-15 JST. This scope supersedes the earlier broad dynamic-sizing proposal. Origin: #182 remaining-work item 3; foundational header work shipped in #180.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestoutput-formattingOutput format and display improvements

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions