Replies: 7 comments 14 replies
|
Greetings. While I am a big fan of PostgreSQL, I do not like this particular syntax at all :( a) is it strictly It should be possible to check for |
|
Another idea was, to implement a special method |
|
Good Morning. As promised, I drafted something: https://github.com/manticore-projects/JSqlParser/tree/PostgresDoBlock |
|
Also. The Language tag seems to allow for different languages aside pl sql.So I would implement one grammar as per language. Sent from my Galaxy
-------- Original message --------From: rrrship ***@***.***> Date: 10/06/2022 15:05 (GMT+01:00) To: JSQLParser/JSqlParser ***@***.***> Cc: manticore-projects ***@***.***>, Comment ***@***.***> Subject: Re: [JSQLParser/JSqlParser] Postgres dollar quotes and function
definition conflict (Discussion #1561)
By an independent parser, do you mean something with a separate grammar?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
|
This seems to be a good illustration: https://github.com/jOOQ/sakila/blob/main/postgres-sakila-db/postgres-sakila-schema.sql |
|
@rrrship @manticore-projects JSqlParsers function body parsing seems to be exactly what you are looking for. Look into CreateFunctionalStatementTest. The function body between those $$ is parsed as a quoted identifier. |
|
Yes. Exactly. A separate grammar for pl sql and a separate parser class.Helps to keep the grammar simple and avoid too many look aheads.Sent from my Galaxy
-------- Original message --------From: rrrship ***@***.***> Date: 10/06/2022 15:05 (GMT+01:00) To: JSQLParser/JSqlParser ***@***.***> Cc: manticore-projects ***@***.***>, Comment ***@***.***> Subject: Re: [JSQLParser/JSqlParser] Postgres dollar quotes and function
definition conflict (Discussion #1561)
By an independent parser, do you mean something with a separate grammar?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Uh oh!
There was an error while loading. Please reload this page.
Hey
When trying to see how hard or easy it would be to add support for PostgreSQL's DO block (docs) I stumbled upon this issue with <S_QUOTED_IDENTIFIER> consuming the function's declaration parts. The issue is that in PostgreSQL the function body (or the body of DO block, which is basically an anonymous function) has to be defined as a string constant. Since this is cumbersome (with the need to escape some chars) dollar quotes (
$$) are used when defining functions. But since <S_QUOTED_IDENTIFIER> consumes everything between$$ $$the parser obviously throws an exception.I actually found this thread under JavaCC project started by @wumpz : link to thread. The issue is kind of similar and I see that allowSquareBracketQuotation feature tag was introduced, but the difference here is that this is actually not a conflict between different SQL flavors - it's valid PostgreSQL. Maybe someone has any ideas how to do some context based switching cleanly. I looked into lexical states, but I'm not sure if this would solve this issue. What I would like to achieve is something like the Block() class - everything between DO
$$ ['function body here'] $$would be parsed as a statement.Best
All reactions