Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHfOs-00067n-6u for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2016 23:25:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cHfOq-0003N2-Kt for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Dec 2016 23:25:20 +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.84_2) (envelope-from ) id 1cHfOo-0003Mk-Kl for pgsql-hackers@postgresql.org; Thu, 15 Dec 2016 23:25:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cHfOh-0001n4-U0 for pgsql-hackers@postgresql.org; Thu, 15 Dec 2016 23:25:17 +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 uBFNP3bT029508; Thu, 15 Dec 2016 18:25:03 -0500 From: Tom Lane To: Oleg Bartunov , Teodor Sigaev cc: Andreas Seltenreich , pgsql-hackers@postgresql.org Subject: Re: [sqlsmith] Failed assertion in TS_phrase_execute In-reply-to: <24331.1480199636@sss.pgh.pa.us> References: <87eg1y2s3x.fsf@credativ.de> <14732.1480186277@sss.pgh.pa.us> <24331.1480199636@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 26 Nov 2016 17:33:56 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29506.1481844303.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 15 Dec 2016 18:25:03 -0500 Message-ID: <29507.1481844303@sss.pgh.pa.us> X-Pg-Spam-Score: -5.0 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I wrote: >> but I notice that some normalization seems to be getting done by >> tsqueryin: >> regression=3D# select $$( 'sanct' & 'peter' ) <-> ( 'sanct' & 'peter' )$= $::tsquery; >> tsquery=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >> ------------------------------------------------------------------------= --------------- >> 'sanct' <-> 'sanct' & 'peter' <-> 'sanct' & 'sanct' <-> 'peter' & 'pete= r' <-> 'peter' >> (1 row) > BTW, it seems like that normalization is wrong. The transformed query > should (and does) match the string "sanct sanct peter sanct sanct peter > peter peter", since each of the <-> pairs has a match somewhere in there. > But I would expect the original query to be specifying that a match occurs > at exactly one place, which of course is unsatisfiable since 'sanct' and > 'peter' can't match the same word. After further thought, it seems like a correct transformation would be to replace & underneath a PHRASE operator with <0>, ie ('a' & 'b') ('c' & 'd') becomes ('a' <0> 'b') ('c' <0> 'd') This would have the same effect of getting rid of non-PHRASE operators underneath a PHRASE, and it would produce what seems to me much less surprising results, ie you get a match only when both sides of the & can match at the same place. Comments? regards, tom lane --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers