You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(deparser): skip over-long SHOW segments before UTF-8 encoding - #394
#393's DP split ran TextEncoder.encode() on every candidate segment, at every dot. For "a.".repeat(100000) + ".z", that allocates gigabytes. A segment with a JS length over 63 can never fit, because UTF-8 bytes ≥ UTF-16 length, so it's now skipped before encoding. Shorter segments still get the byte check. The PR adds a pathological-input test. Raised by CodeRabbit on #393.
This PR bounds the encoding work done when deparsing a VariableShowStmt whose name contains many dot boundaries: character-length guards are now applied before entering the per-segment UTF-8 encoding loop, so an overlong identifier fails fast instead of doing quadratic encoding work. A new test in the deparser's pretty-print suite pins this behavior by asserting the bounded path completes and the unbounded path still throws.
Files
Change
packages/deparser/src/deparser.ts
Adds early character-length guards in the SHOW-name splitting path so encode calls are only made when a segment can plausibly fit the 63-byte identifier limit.
Adds a regression test asserting bounded encode work for a name with many dot boundaries and that an unbounded SHOW name still throws.
Note: two verified candidate findings (an inconsistent overlong-name fast path in deparser.ts and a time-based test assertion) fell just below the confidence threshold and are not included as formal findings.
No actionable comments were generated in the recent review.
Walkthrough
The deparser now limits SHOW name segments by both character count and UTF-8 byte length. A regression test covers deparsing a SHOW name with many dot boundaries.
The split logic checks character count and UTF-8 byte length for candidate segments. A regression test checks deparsing a name with 100,000 repeated a. segments followed by .z.
constructive-io/pgsql-parser#393: Adds dynamic-programming splitting for long VariableShowStmt names, which this change further modifies.
Suggested reviewers:luxor-code-review
Merge Risk: Minimal · up to ec41f
This change avoids large allocations when deparsing SHOW names with many dots, and accepted names keep the same behavior. No concrete merge-blocking risk was found.
Security architecture risk: Minimal · up to ec41f
The change avoids encoding identifier candidates that cannot satisfy the existing byte limit. No introduced or worsened architecture-level security risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the deparser now skips SHOW segments longer than 63 characters before UTF-8 encoding, which is a performance fix. The raw summary describes the same change in deparser…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the deparser now skips SHOW segments longer than 63 characters before UTF-8 encoding, which is a performance fix. The raw summary describes the same change in deparser.ts (a 63-character check applied before the existing 63-byte check) and a pathological-input test. The objectives describe the same allocation fix. The title is specific and matches the changeset.
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
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#393's DP split ran
TextEncoder.encode()on every candidate segment, at every dot. For"a.".repeat(100000) + ".z", that allocates gigabytes. A segment with a JS length over 63 can never fit, because UTF-8 bytes ≥ UTF-16 length, so it's now skipped before encoding. Shorter segments still get the byte check. The PR adds a pathological-input test. Raised by CodeRabbit on #393.Implemented in session Triage stale open PRs and issues in parser repos
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit
SHOWnames with many segments. Each segment is now limited to 63 characters and 63 UTF-8 bytes.