Skip to content

Fix[2290] - Fix overeager lambda function parsing #2293

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

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

davyboyhayes
Copy link
Contributor

SELECT DATE_TRUNC('week',("schema"."tbl"."column" + INTERVAL '1 day')) FROM "schema"."tbl"; is parsing the ("schema"."tbl"."column" + INTERVAL '1 day') as a LambdaFunction incorrectly, and crashes out. Increasing the lookahead depth by 1 ensures it fails to match on the -> keyword (I believe), and falls into a simple expression instead.

Fixes #2290

JMH

jmh {
    includes = ['.*JSQLParserBenchmark.*']
    warmupIterations = 2
    fork = 5
    iterations = 5
    timeOnIteration = '5s'
}

After:

  33.970 ±(99.9%) 1.773 ms/op [Average]
  (min, avg, max) = (31.405, 33.970, 37.302), stdev = 2.367
  CI (99.9%): [32.197, 35.743] (assumes normal distribution)

Before:

  34.882 ±(99.9%) 1.923 ms/op [Average]
  (min, avg, max) = (31.191, 34.882, 37.406), stdev = 2.567
  CI (99.9%): [32.959, 36.805] (assumes normal distribution)

`SELECT DATE_TRUNC('week',("schema"."tbl"."column" + INTERVAL '1 day')) FROM "schema"."tbl";`
is parsing the `("schema"."tbl"."column" + INTERVAL '1 day')` as a LambdaFunction incorrectly, and crashes out. Increasing the lookahead depth by 1 ensures it fails to match on the `->` keyword (I believe), and falls into a simple expression instead.

JMH
```
jmh {
    includes = ['.*JSQLParserBenchmark.*']
    warmupIterations = 2
    fork = 5
    iterations = 5
    timeOnIteration = '5s'
}
```
After:
```
  33.970 ±(99.9%) 1.773 ms/op [Average]
  (min, avg, max) = (31.405, 33.970, 37.302), stdev = 2.367
  CI (99.9%): [32.197, 35.743] (assumes normal distribution)
```
Before:
```
  34.882 ±(99.9%) 1.923 ms/op [Average]
  (min, avg, max) = (31.191, 34.882, 37.406), stdev = 2.567
  CI (99.9%): [32.959, 36.805] (assumes normal distribution)
```
@manticore-projects manticore-projects merged commit 12489af into JSQLParser:master Aug 11, 2025
2 of 3 checks passed
@manticore-projects
Copy link
Contributor

Thank you much!

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

Successfully merging this pull request may close these issues.

[BUG] JSQLParser Version 5.4-Snapshot : PostgreSQL : 2nd Function Parameter with schema/table/column can't be parsed
2 participants