From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: A really subtle lexer bug |
Date: | 2018-08-23 14:55:15 |
Message-ID: | 18470.1535036115@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> Andrew> I guess the fix is to extend the existing special case code
> Andrew> that checks for one character left after removing trailing [+-]
> Andrew> and also check for the two-character ops "<>" ">=" "<=" "=>"
> Andrew> "!=".
> Patch attached.
> This fixes two bugs: first the mis-lexing of two-char ops as mentioned
> originally; second, the O(N^3) lexing time of strings of - or +
> characters is reduced to O(N^2) (in practice it's better than O(N^2)
> once N gets large because the bison stack gets blown out, ending the
> loop early).
Looks reasonable offhand (didn't test). A couple of thoughts:
* Some regression tests exercising these code paths might be a good thing.
* There should likely be a comment near where EQUALS_GREATER and
friends are defined, pointing out that if we add any more multi-character
operators with special precedences, this code has to be taught about them.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-08-23 15:04:30 | Re: Getting NOT NULL constraint from pg_attribute |
Previous Message | Alvaro Herrera | 2018-08-23 14:29:53 | Re: Removing useless DISTINCT clauses |