feat(plpgsql-parser): automatically compute return info for correct RETURN handling #273
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
The plpgsql-parser now automatically extracts return type information from
CreateFunctionStmtand passes it to the PL/pgSQL deparser. This ensures correct RETURN statement handling without users needing to manually provide return context.Behavior:
RETURN;stays asRETURN;RETURN;becomesRETURN NULL;RETURN;stays asRETURN;RETURN;stays asRETURN;Updates since last revision
Documentation updates to clarify the separation between packages:
plpgsql-parserfor full SQL + PL/pgSQL deparsingCREATE FUNCTIONstatementsPrevious updates:
round-trip.test.ts: New test file that runs all 190 generated fixtures through the fullplpgsql-parser.parse()→plpgsql-parser.deparseSync()→ reparse → compare AST pipelineReview & Testing Checklist for Human
if (plpgsqlFunc)guard indeparse.tsdoesn't silently skip function body stitching - ifdehydrated.plpgsql_funcs?.[0]?.PLpgSQL_functionis undefined when it shouldn't be, the function body won't be updatedRETURN NULLcleanSqlTreefunction in round-trip tests strips only location metadata and doesn't mask real AST differencesRecommended test plan: Run
pnpm testinpackages/plpgsql-parserto verify all 92 tests pass (including the new round-trip tests that exercise all 190 fixtures).Notes
ReturnInfoparameter an internal implementation detail - users ofplpgsql-parserno longer need to know about it