Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPfVr-0002Zi-9x for pgsql-bugs@arkaria.postgresql.org; Sun, 12 May 2019 03:50:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hPfVm-0008UF-G6 for pgsql-bugs@arkaria.postgresql.org; Sun, 12 May 2019 03:50:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPfVm-0008U7-8f for pgsql-bugs@lists.postgresql.org; Sun, 12 May 2019 03:50:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPfVi-0005fr-UG for pgsql-bugs@lists.postgresql.org; Sun, 12 May 2019 03:50:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x4C3ohJH027603; Sat, 11 May 2019 23:50:43 -0400 From: Tom Lane To: Andrew Gierth cc: "Daniel Verite" , "Robert Schreiber" , pgsql-bugs@lists.postgresql.org Subject: Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug In-reply-to: <87mujsgz14.fsf@news-spur.riddles.org.uk> References: <785708a0-a64c-42ee-9173-f596c1fc92ec@manitou-mail.org> <32565.1557590361@sss.pgh.pa.us> <87mujsgz14.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Sun, 12 May 2019 04:19:23 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27601.1557633043.1@sss.pgh.pa.us> Date: Sat, 11 May 2019 23:50:43 -0400 Message-ID: <27602.1557633043@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > I looked up the spec on this point. As far as I can see, we're not > following it, but neither does the spec do what the OP wanted; in fact > the result should have included the _leading_ Q as well as the trailing > one. Huh, interesting. So we should be translating the initial substring to a non-greedy pattern. I believe Spencer's engine can handle that by sticking (?:...){1,1}? around it. Come to think of it, we probably need to be putting (?:...) around the trailing substring as well. I suspect what we're doing today produces non-spec results if "|" appears in the trailing part. regards, tom lane