Re: A really subtle lexer bug

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: A really subtle lexer bug
Date: 2018-08-20 16:58:49
Message-ID: 87ftz90yma.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:

Andrew> select f(a =>-1); -- ERROR: column "a" does not exist

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

--
Andrew (irc:RhodiumToad)

Attachment Content-Type Size
lex.patch text/x-patch 2.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Travers 2018-08-20 17:14:10 Re: Two proposed modifications to the PostgreSQL FDW
Previous Message Chris Travers 2018-08-20 16:46:32 Re: Two proposed modifications to the PostgreSQL FDW