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

   The walk there decides whether a prefix `-` or `!` needs a space by 
following only unary and binary operators, so an operand that starts with an 
operator character under any other node is missed. A minus over `(-x)::INT` 
built in code prints as `--x::INT`, which the parser reads as a line comment, 
and `- @x` in MsSQL prints as `-@x`. Tools that rewrite the AST and drop 
parentheses can produce these shapes.
   
   Here the check reads the operand's rendered first character again, as #2532 
did, through a small `first_char` helper in `display_utils` that stops 
rendering once it has that character. The prefix operator is written before the 
check runs, so a check from an enclosing operator stops at it and printing 
stays linear. The rendering check from #2532 had no such stop and doubled its 
cost with every nested minus, taking 172 ms for 22 signs, and a new test that 
prints 200 nested signs under a timeout keeps that from coming back. Mea culpa. 
I will add a fuzzing harness explicitly targeting these slow downs.


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