Re: [sqlsmith] Failed assertion in TS_phrase_execute

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oleg Bartunov <obartunov(at)gmail(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Andreas Seltenreich <seltenreich(at)gmx(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [sqlsmith] Failed assertion in TS_phrase_execute
Date: 2016-12-15 23:25:03
Message-ID: 29507.1481844303@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
>> but I notice that some normalization seems to be getting done by
>> tsqueryin:

>> regression=# select $$( 'sanct' & 'peter' ) <-> ( 'sanct' & 'peter' )$$::tsquery;
>> tsquery
>> ---------------------------------------------------------------------------------------
>> 'sanct' <-> 'sanct' & 'peter' <-> 'sanct' & 'sanct' <-> 'peter' & 'peter' <-> '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') <N> ('c' & 'd')

becomes

('a' <0> 'b') <N> ('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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2016-12-16 00:16:36 Re: Proposal for changes to recovery.conf API
Previous Message Tom Lane 2016-12-15 20:54:31 Re: Proposal for changes to recovery.conf API