LucaCappelletti94 opened a new pull request, #2344:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2344

   `parse_compound_expr` recursed into `parse_subexpr` after every `.`, which 
re-walks the rest of the chain inside a rollback boundary. On inputs like `IF 
a.b.c...x.#` the work doubled per chain element, giving 2^N parse times. 
Switching the inner call to `parse_prefix` removes the redundant traversal: the 
outer loop already walks the chain, so the resulting AST is identical on valid 
SQL.
   
   Measured on `PostgreSqlDialect` with three inputs from a libFuzzer corpus, 
release build:
   
   | Input                                    | Before  | After  |
   |------------------------------------------|---------|--------|
   | `iF i.D.i.:Fi....` (65 B)                | 419 ms  | 87 us  |
   | `iF i.D.i.i. ... .*~` (58 B)             | 893 ms  | 69 us  |
   | `if-stf-localtclocal33alt....` (306 B)   | >35 s   | 98 us  |
   
   Regression test in `tests/sqlparser_postgres.rs` runs a 30-element chain 
with a 5 s timeout. Pre-fix it hits the timeout, post-fix it finishes in well 
under a millisecond.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to