fix(plpgsql): sync generator with committed grammar#30
Conversation
Update the PL/pgSQL grammar generator so it matches the committed plpgsql/grammar.js for drift-sensitive rules. - emit alias declarations before variable declarations - emit FETCH as optional FROM plus required cursor name - add a lightweight generator drift test for decl_statement and stmt_fetch This prevents future regeneration from undoing the current committed grammar shape.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes drift between the PL/pgSQL grammar generator and the committed grammar by updating ChangesGrammar Generator Drift Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@gmr Hello, found small drift between generator and grammar. |
Update the PL/pgSQL grammar generator so it matches the committed plpgsql/grammar.js for drift-sensitive rules.
This prevents future regeneration from undoing the current committed grammar shape.
Summary
This PR fixes drift between the committed
plpgsql/grammar.jsand its generator template inscript/generate-plpgsql-grammar.js.The committed grammar already has the intended behavior. This PR moves that behavior back into the generator so future regeneration does not undo it.
Changes
Declaration ordering
Updated
decl_statementgeneration so alias declarations are emitted before variable declarations.This preserves the existing intended behavior where:
is parsed as an alias declaration rather than being confused with a variable declaration whose type name starts with ALIAS.
FETCH statement shape
Updated generated stmt_fetch from:
to:
This matches the committed grammar and supports both:
FETCH curs INTO x; FETCH NEXT FROM curs INTO x;Testing
Ran lightweight generator drift tests:
node --test script/*.test.jsResult:
Ran PL/pgSQL corpus tests:
Result:
Full PostgreSQL parser regeneration was not run because this PR only updates the PL/pgSQL generator template and does not change the committed generated PL/pgSQL grammar.
It does not change the broader PL/pgSQL scanner architecture or the _sql_body handling discussed separately.
Closes #29
Summary by CodeRabbit
Tests
Chores