alpaylan opened a new issue, #3000:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/3000

   A chain of `BINARY` operands that ends in a syntax error doubles the parse 
time per operand in the MySQL dialect. Before #2146 added the `BINARY` cast 
(0.60.0) the same input failed in microseconds:
   
   ```
   SELECT BINARY-BINARY-BINARY-BINARY--FIELDS IN      -- n operands
           bytes   main      0.60.0
     n=16   136   129 ms    0.016 ms
     n=18   150   0.5 s     0.013 ms
     n=20   164   2.1 s     0.013 ms
   ```
   
   Any failure after the chain does it (`SELECT BINARY+BINARY+...+` too). With 
a valid ending (`...-BINARY-1`), or in GenericDialect, it is linear.
   
   ```rust
   use sqlparser::{dialect::MySqlDialect, parser::Parser};
   let sql = format!("SELECT BINARY{}--FIELDS IN", "-BINARY".repeat(20));
   let _ = Parser::parse_sql(&MySqlDialect {}, &sql); // error after ~2 s
   ```
   
   Tested on main 9429cd30 and crates.io 0.64.0, 0.63.0 and 0.61.0 (the first 
release with #2146); 0.60.0 is linear.
   
   Found with a coverage-guided performance fuzzer; I used AI assistance for 
triage and verified every case above.
   


-- 
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