Repository navigation
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #942.
The workspace treated the body of a
LANGUAGE sqlfunction as a single statement. A body with several statements doesn't parse as one, so it was reported as a syntax error, and none of its statements were linted or typechecked. An empty body got the same error:SqlFunctionBody::statements(inpgls_query_ext, next tosql_function_body) splits the body the way Postgres does (pg_parse_query), using the statement locations libpg_query returns. Each statement becomes a child of theCREATE FUNCTION, with its range in the document and its trailing semicolon, like top-level statements. Two cases stay as before:An empty body now has no children.
The formatter only rewrote bodies with exactly one child, and it now checks that explicitly. A body with several statements is left as written. Before this PR it was skipped because it didn't parse; without the check, the last statement would have replaced the whole body.
The regression harness and the rule specs use the same split, so they now analyse 357–373 body statements per version, up from 347–359. There are no new findings on accepted statements and no changes to rejected-statement findings, only the header counts.
Tests: unit tests for
statements()(single statement, several with and without semicolons, empty, unparsable), document tests for a body with several statements (no syntax error, function context, document ranges) and an empty body, and a formatter test that keeps a body with several statements as written.Not covered:
BEGIN ATOMIC,RETURN,''andE'...'bodies. #918 and #941 (on the #888 stack) extract those, and they conflict with this stack in the body extraction (document.rs,sql_function.rs). Whichever lands second should split string bodies withSqlFunctionBody::statements.