Skip to content

fix(deparser): quote SHOW variable names - #387

Merged
pyramation merged 4 commits into
mainfrom
fix/deparser-show-quoting
Nov 21, 2026
Merged

pyramation merged 4 commits into
mainfrom
fix/deparser-show-quoting

Conversation

@pyramation

@pyramation pyramation commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

VariableShowStmt emitted node.name raw and compared it against 'ALL', but the parser lowercases unquoted names. As a result:

SHOW "ALL"       -> SHOW ALL        (now means every setting)
SHOW "TimeZone"  -> SHOW TimeZone   (name case lost)
SHOW ALL         -> SHOW all

Now: name === 'all' → SHOW ALL; otherwise the name is emitted with QuoteUtils.quoteDottedName(name.split('.')). Fixtures added.

This is a fresh version of one of the 7 fixes bundled in #368, part of constructive-io/constructive-planning#2555.


libpg-query and parser opened this PR for Dan
Implemented in session Triage stale open PRs and issues in parser repos
Review with Devin · Open in Devin Desktop


Summary by CodeRabbit

  • Bug Fixes
    • SHOW statements now preserve appropriate quoting for quoted, unquoted, and qualified names, including multiword settings.
    • Lowercase all is recognized as SHOW ALL, matching uppercase ALL.
    • Long identifiers are split at a valid dot when possible; identifiers that exceed the 63-byte limit without a valid split produce an error.

@luxor-code-review

luxor-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR teaches the deparser to emit SHOW statements, choosing between the bare SHOW ALL form for the lowercase all sentinel and quoted identifier output (via QuoteUtils.quoteDottedName) for regular parameter names, including dotted GUC names. Fixtures and snapshot tests cover the quoting cases.

Files Change
packages/deparser/src/deparser.ts Adds the VariableShowStmt handler emitting SHOW ALL or quoted/dotted identifier form
__fixtures__/kitchen-sink/misc/show-quoting.sql, __fixtures__/generated/generated.json New SHOW-quoting fixture inputs and regenerated AST fixture data
packages/deparser/__tests__/pretty/show-quoting.test.ts, __snapshots__/show-quoting.test.ts.snap, __tests__/kitchen-sink/misc-show-quoting.test.ts New pretty-print and kitchen-sink tests locking in SHOW quoting output

Reviewed commit: bb654fb

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The deparser recognizes lowercase all in SHOW statements. It quotes dotted setting names and splits overlength names at eligible dots. Sixteen SQL fixtures and a pretty-print test cover the formatting and the error for an unsplittable overlength name.

Changes: SHOW identifier quoting

Layer / File(s) Summary
SHOW formatting and fixture coverage
packages/deparser/src/deparser.ts, __fixtures__/kitchen-sink/misc/show-quoting.sql, packages/deparser/__tests__/kitchen-sink/misc-show-quoting.test.ts, packages/deparser/__tests__/pretty/show-quoting.test.ts
VariableShowStmt recognizes lowercase all and quotes dotted-name segments. It splits overlength names at eligible dots and throws an error when no eligible dot exists. Sixteen SQL fixtures and a pretty-print test cover these cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to ebbcd

This change quotes SHOW setting names so case and special characters survive a parse and deparse round trip. No outstanding merge-blocking issues were found.

Security architecture risk: Minimal · up to ebbcd

The change affects SHOW statement rendering and a narrow error case. No introduced or worsened risk to privileges, persistent state, or failure containment was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is caller-provided AST data reaching generated SHOW text through existing APIs. The inspected change adds neither a database execution sink nor identity, credential, or persistent-state operations; downstream execution remains outside the inspected scope.

Trust Boundaries and Controls

  • observed — At the name-to-SQL boundary, emitted components now pass through identifier quoting rather than raw interpolation. The helper permits only restricted identifier characters without quotes and doubles embedded double quotes when quoting is required.

Resilience and Maintainability Implications

  • observed — The new splitting transition uses local variables and either returns a completed SHOW string or throws. The enclosing deparse path propagates the error, and deparseQuery assembles its return value only after node processing completes, so this failure does not return a partial SQL batch.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(deparser): quote SHOW variable names" matches the main change. The deparser now emits SHOW ALL only for the lowercase name all, and it quotes other SHOW names, including dotted names,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(deparser): quote SHOW variable names" matches the main change. The deparser now emits SHOW ALL only for the lowercase name all, and it quotes other SHOW names, including dotted names, instead of emitting them unchanged. The change also splits names longer than 63 UTF-8 bytes at a dot, and the title does not mention that part. That omission is acceptable because the title does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6003e4e and ebbcdbe.

Files ignored due to path filters: 2

  • __fixtures__/generated/generated.json is excluded by !**/generated/**, !__fixtures__/generated/**
  • packages/deparser/__tests__/pretty/__snapshots__/show-quoting.test.ts.snap is excluded by !**/*.snap, !**/__snapshots__/**
Files selected for processing: 4

  • __fixtures__/kitchen-sink/misc/show-quoting.sql
  • packages/deparser/__tests__/kitchen-sink/misc-show-quoting.test.ts
  • packages/deparser/__tests__/pretty/show-quoting.test.ts
  • packages/deparser/src/deparser.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@pyramation
pyramation merged commit 365fce1 into main Nov 21, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant