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

Error parsing $N args within parens #608

Open
kwesterfeld2 opened this issue Sep 11, 2024 · 0 comments
Open

Error parsing $N args within parens #608

kwesterfeld2 opened this issue Sep 11, 2024 · 0 comments

Comments

@kwesterfeld2
Copy link
Contributor

Simple repro

PREPARE test_plan AS SELECT hashtext($1)

This is legal PSQL, libpq, etc. all allow it. pgjdbc-ng throws this error:

Error parsing SQL at position 40 (PREPARE test_plan AS SELECT hashtext($1)): Error near:

Interestingly, pgjdbc-ng does not throw on this similar query:

PREPARE test_plan AS SELECT $1

My company came across this after we introduced a new grammar for shredding JSON, which is biased towards $ expressions without quoting, embracing JSON Path, etc. The syntax we have looks like this:

select * from flatten('{"a":1,"b":2}', $ as root) as f

We are very keen to support this feature of our own in our product, which includes a query editor that uses pgdjbc-ng. Unfortunately our own product can't execute its native JSON grammar without a fix here.

kwesterfeld2 added a commit to kwesterfeld2/pgjdbc-ng that referenced this issue Sep 11, 2024
- when a $1 or $$foo$$ is within () expression, like a function
  invocation, parse the $ as plain grammar piece
- add a test for this situation which does not parse otherwise
  and throws ParseException
kwesterfeld2 added a commit to kwesterfeld2/pgjdbc-ng that referenced this issue Sep 11, 2024
- when a $1 or $$foo$$ is within () expression, like a function
  invocation, parse the $ as plain grammar piece
- add a test for this situation which does not parse otherwise
  and throws ParseException
kwesterfeld2 added a commit to kwesterfeld2/pgjdbc-ng that referenced this issue Sep 23, 2024
- when a $1 or $$foo$$ is within () expression, like a function
  invocation, parse the $ as plain grammar piece
- add a test for this situation which does not parse otherwise
  and throws ParseException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant