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 1hQBU2-00034E-Ur for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2019 13:59:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hQBU1-0002mP-KX for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2019 13:59:13 +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 1hQBU1-0002mH-Ch for pgsql-bugs@lists.postgresql.org; Mon, 13 May 2019 13:59:13 +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 1hQBTz-0006F8-51 for pgsql-bugs@lists.postgresql.org; Mon, 13 May 2019 13:59:12 +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 x4DDx5SY016676; Mon, 13 May 2019 09:59:05 -0400 From: Tom Lane To: Robert Schreiber cc: Andrew Gierth , Daniel Verite , pgsql-bugs@lists.postgresql.org Subject: Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug In-reply-to: <3db2d381-c94d-c6b8-10a8-7cf0ddda6c09@charter.net> References: <785708a0-a64c-42ee-9173-f596c1fc92ec@manitou-mail.org> <32565.1557590361@sss.pgh.pa.us> <87mujsgz14.fsf@news-spur.riddles.org.uk> <27602.1557633043@sss.pgh.pa.us> <87imuggwi4.fsf@news-spur.riddles.org.uk> <3db2d381-c94d-c6b8-10a8-7cf0ddda6c09@charter.net> Comments: In-reply-to Robert Schreiber message dated "Mon, 13 May 2019 05:36:30 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16674.1557755945.1@sss.pgh.pa.us> Date: Mon, 13 May 2019 09:59:05 -0400 Message-ID: <16675.1557755945@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Schreiber writes: > Just to be clear here. It seems to me that I am right in that the > leading/trailing Q should NOT be returned... Nope. The SQL spec's pretty clear that when the first and third sub-expressions of the pattern can match variable amounts of text, they're supposed to be matched to the minimum possible amount of text, which is nothing for a pattern like "Q?". It is a bug that we're not doing that as the spec says, but once we fix that, it still won't act as you're hoping. regards, tom lane