Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsrYD-0000aB-Mk for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 15:29:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsrYB-0002ad-NZ for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 15:29:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsrYB-0002aW-DD for pgsql-hackers@lists.postgresql.org; Thu, 23 Aug 2018 15:29:31 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsrY8-00036J-7F for pgsql-hackers@postgresql.org; Thu, 23 Aug 2018 15:29:30 +0000 Received: from [192.168.127.1] (port=31094 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fsrY5-00012s-Gi; Thu, 23 Aug 2018 15:29:25 +0000 Received: from [127.0.0.1] (port=29473 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fsrY4-000L8j-Pj; Thu, 23 Aug 2018 15:29:24 +0000 From: Andrew Gierth To: Tom Lane Cc: pgsql-hackers@postgresql.org Subject: Re: A really subtle lexer bug In-Reply-To: <18470.1535036115@sss.pgh.pa.us> (Tom Lane's message of "Thu, 23 Aug 2018 10:55:15 -0400") Message-ID: <871sap1658.fsf@news-spur.riddles.org.uk> References: <87va851ppl.fsf@news-spur.riddles.org.uk> <87ftz90yma.fsf@news-spur.riddles.org.uk> <18470.1535036115@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 23 Aug 2018 16:29:23 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Tom" == Tom Lane writes: >> 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). Tom> Looks reasonable offhand (didn't test). A couple of thoughts: Tom> * Some regression tests exercising these code paths might be a Tom> good thing. Agreed. Any preferences where they should go? Tom> * There should likely be a comment near where EQUALS_GREATER and Tom> friends are defined, pointing out that if we add any more Tom> multi-character operators with special precedences, this code has Tom> to be taught about them. Agreed; will do this. -- Andrew (irc:RhodiumToad)