Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing SQL Feature:
- Parenthesis in a query lead to CPU burn - my example has
((( ... ))), add more parenthesis to see significant increase in the time it takes to fail
SQL Example:
- Valid PostgreSQL query (heavily reduced from a large query with many nested cases):
-- Simple query which fails fast
SELECT ('{"obj":{"field": "value"}}'::JSON -> 'obj'::TEXT ->> 'field'::TEXT)
-- Same query nested in a case statement, takes the CPU for a spin
SELECT
CASE
WHEN true
THEN (SELECT ((('{"obj":{"field": "value"}}'::JSON -> 'obj'::TEXT ->> 'field'::TEXT))))
END
My notes:
I was trying to narrow down the issue by testing the case statement query like this:
CCJSqlParserUtil.newParser(sql).withAllowComplexParsing(allowComplexParsing).statements();
| JSql |
allowComplexParsing |
outcome |
| 4.5 |
false |
Fails fast |
| 4.5 |
true |
Fails after ~10 seconds of 100% CPU |
| 4.6 |
false |
Fails after ~20 seconds of 100% CPU |
| 4.6 |
true |
Doesn't finish in 3 minutes, CPU stays at 100% |
Software Information:
- JSqlParser 4.5, 4.6
- Database PostgreSQL
Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing SQL Feature:
((( ... ))), add more parenthesis to see significant increase in the time it takes to failSQL Example:
My notes:
I was trying to narrow down the issue by testing the case statement query like this:
Software Information: