pgjdbc / r2dbc-postgresql

Postgresql R2DBC Driver

Home Page:https://r2dbc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend `PostgresqlSqlLexer` to handle PG14 SQL-standard function body syntax

mp911de opened this issue · comments

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:

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..