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
fix(wasm): restore the PG 18 stack depth budget - #210
libpg-query 18.2.5–18.2.6 reject nesting that 18.1.5 parsed: SELECT 1+1+… fails with "stack depth limit exceeded" at about 800 terms (18.1.5: 2000+), and nested subqueries fail at 500. The fork's stack-depth check (from upstream pganalyze/libpg_query#348) never sized max_stack_depth under Emscripten, so it stayed at the 100kB default. The fix landed in the fork in constructive-io/libpg_query#18: it reads the WASM stack bounds and caps the limit at 512kB, so the clean error fires before V8's native stack overflows.
versions/18/test/wasm-recovery.test.js: 2000 chained operators, 1000 nested subqueries and 2000 nested function calls must parse. This commit was pushed alone first and went red on the old pin on all three OSes. The existing 100k-term test still requires the clean stack depth error, not a V8 RangeError.
versions/18/package.json / Makefile (via pnpm copy:templates): pin 18-constructive at the fork PR's merge commit 7791971.
This PR adds a single new test file covering the WASM crash-recovery behavior after the v18.2.x stack-depth limit change: it reloads the WASM module, then parses 2,000-deep nested +1 expressions and a 20,000-node case to confirm no crashes and correct statement counts. No production code is changed.
Files
Change
versions/18/test/wasm-recovery.test.js
New test: loadModule() recovery after deep-nesting parse, asserting returned statement counts.
No actionable comments were generated in the recent review.
Walkthrough
The PostgreSQL 18 libpg_query commit pin is updated. New WASM tests check that 2,000 chained operators, 1,000 nested subqueries, and 2,000 nested function calls each parse as one statement.
The build and package metadata use commit 7791971be1fc169d3f1b0d1ec887dc3f134ad134. Tests check that three deeply nested SQL forms parse as one statement.
This updates the PostgreSQL 18 WASM parser to a libpg_query revision that restores the stack depth budget and adds tests for deeply nested SQL. No actionable merge-blocking risk was found in the supplied changes.
Architecture risk: Low · up to da271
The change affects 1 system.
Changed systems:versions
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — versions (service) was modified; 3 changed files map to changed impact.
Before / after behavior
observed — Modified behavior in versions/18/test/wasm-recovery.test.js: Adds a test that loads the module and confirms chained operators, nested subqueries, and nested function calls at the specified depths parse successfully as single statements.
observed — Modified behavior in versions/18/Makefile: The LIBPG_QUERY_COMMIT value changes from f75f8010a8a75fe4645db550c5f8f435dbc938a3 to 7791971be1fc169d3f1b0d1ec887dc3f134ad134.
observed — Modified behavior in versions/18/package.json: The libpgQueryCommit value changes from f75f8010a8a75fe4645db550c5f8f435dbc938a3 to 7791971be1fc169d3f1b0d1ec887dc3f134ad134.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(wasm): restore the PG 18 stack depth budget" matches the main change. The PR restores the stack depth budget for PG 18 under WASM. The objectives describe a fix for the stack depth limi…
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 "fix(wasm): restore the PG 18 stack depth budget" matches the main change. The PR restores the stack depth budget for PG 18 under WASM. The objectives describe a fix for the stack depth limit that now triggers at lower nesting levels. The changeset itself is mostly a version pin bump plus one WASM test. The title names the fix, but the diff only pins the fork commit and adds a test, so the pinned commit carries the fix. This is a reasonable match for the primary intent.
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
Reviewing files that changed from the base of the PR and between 49bdbbc and da271b1.
Files selected for processing: 2
versions/18/Makefile
versions/18/package.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
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
libpg-query 18.2.5–18.2.6 reject nesting that 18.1.5 parsed:
SELECT 1+1+…fails with "stack depth limit exceeded" at about 800 terms (18.1.5: 2000+), and nested subqueries fail at 500. The fork's stack-depth check (from upstream pganalyze/libpg_query#348) never sizedmax_stack_depthunder Emscripten, so it stayed at the 100kB default. The fix landed in the fork in constructive-io/libpg_query#18: it reads the WASM stack bounds and caps the limit at 512kB, so the clean error fires before V8's native stack overflows.versions/18/test/wasm-recovery.test.js: 2000 chained operators, 1000 nested subqueries and 2000 nested function calls must parse. This commit was pushed alone first and went red on the old pin on all three OSes. The existing 100k-term test still requires the clean stack depth error, not a V8RangeError.versions/18/package.json/Makefile(viapnpm copy:templates): pin18-constructiveat the fork PR's merge commit7791971.Implemented in session Settle the last old WASM hardening PRs
Review with Devin · Open in Devin Desktop