Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend PostgresqlSqlLexer to handle PG14 SQL-standard function body syntax #512

Closed
mp911de opened this issue May 16, 2022 · 2 comments
Closed
Labels
type: enhancement A general enhancement
Milestone

Comments

@mp911de
Copy link
Collaborator

mp911de commented May 16, 2022

PG14 added a new syntax for creating SQL functions that we should support with PostgresqlSqlLexer

CREATE OR REPLACE FUNCTION asterisks(n int)
  RETURNS SETOF text
  LANGUAGE sql IMMUTABLE STRICT PARALLEL SAFE
BEGIN ATOMIC
SELECT repeat('*', g) FROM generate_series (1, n) g; -- <-- Note this semicolon
END;

Right now, PostgresqlSqlLexer.tokenize(…) identifies this above as two statements. See also:

@mp911de mp911de added the type: enhancement A general enhancement label May 16, 2022
@mp911de
Copy link
Collaborator Author

mp911de commented May 16, 2022

/cc @toverdijk

@toverdijk
Copy link
Contributor

It does seem quite complex - I guess also the sql body needs to be parsed completely as well in order to catch commented out ENDs and such. I'll give it a shot..

@mp911de mp911de added this to the 0.9.2.RELEASE milestone May 25, 2022
mp911de pushed a commit that referenced this issue May 25, 2022
mp911de pushed a commit that referenced this issue May 25, 2022
… syntax

- Lexing/parsing is now done in two steps: first only tokenize, then parse into statements
- Added support for function bodies ("BEGIN ATOMIC")
- Added a test case for newly supported grammar

[resolves #512][#513]
mp911de added a commit that referenced this issue May 25, 2022
Reorder methods. Use CharObjectMap for operator character lookup instead of linear array iteration. Extract peek/has next token functionality into dedicated methods.

Migrate assertions to AssertJ. Add benchmark.

[#512][resolves #513]

Signed-off-by: Mark Paluch <[email protected]>
mp911de pushed a commit that referenced this issue May 25, 2022
mp911de added a commit that referenced this issue May 25, 2022
Reorder methods. Use CharObjectMap for operator character lookup instead of linear array iteration. Extract peek/has next token functionality into dedicated methods.

Migrate assertions to AssertJ. Add benchmark.

[#512][resolves #513]

Signed-off-by: Mark Paluch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants