pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[sqlsmith] Failed assertion in TS_phrase_execute
4+ messages / 2 participants
[nested] [flat]

* [sqlsmith] Failed assertion in TS_phrase_execute
@ 2016-11-26 15:11 Andreas Seltenreich <seltenreich@gmx.de>
  2016-11-26 18:51 ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Andreas Seltenreich @ 2016-11-26 15:11 UTC (permalink / raw)
  To: pgsql-hackers

Hi,

the query below triggers an assertion in TS_phrase_execute.  Testing was
done on master at dbdfd11.

regards,
Andreas

-- TRAP: FailedAssertion("!(curitem->qoperator.oper == 4)", File: "tsvector_op.c", Line: 1432)

select 'moscow' @@
       ts_rewrite('moscow', 'moscow',
          ts_rewrite(
	     tsquery_phrase('moscow','moscow'),
	     'moscow',
	     $$ 'sanct' & 'peter'$$));


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [sqlsmith] Failed assertion in TS_phrase_execute
  2016-11-26 15:11 [sqlsmith] Failed assertion in TS_phrase_execute Andreas Seltenreich <seltenreich@gmx.de>
@ 2016-11-26 18:51 ` Tom Lane <tgl@sss.pgh.pa.us>
  2016-11-26 22:33   ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2016-11-26 18:51 UTC (permalink / raw)
  To: Andreas Seltenreich <seltenreich@gmx.de>; +Cc: Oleg Bartunov <obartunov@gmail.com>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-hackers

Andreas Seltenreich <seltenreich@gmx.de> writes:
> the query below triggers an assertion in TS_phrase_execute.  Testing was
> done on master at dbdfd11.

> -- TRAP: FailedAssertion("!(curitem->qoperator.oper == 4)", File: "tsvector_op.c", Line: 1432)

> select 'moscow' @@
>        ts_rewrite('moscow', 'moscow',
>           ts_rewrite(
> 	     tsquery_phrase('moscow','moscow'),
> 	     'moscow',
> 	     $$ 'sanct' & 'peter'$$));

Hmm.  If you run the ts_rewrite alone, it prints

regression=# select  ts_rewrite('moscow', 'moscow',
          ts_rewrite(
     tsquery_phrase('moscow','moscow'),
     'moscow',
     $$ 'sanct' & 'peter'$$));
                   ts_rewrite                    
-------------------------------------------------
 ( 'sanct' & 'peter' ) <-> ( 'sanct' & 'peter' )
(1 row)

and if you put that in explicitly, all's well:

regression=# select 'moscow' @@ $$( 'sanct' & 'peter' ) <-> ( 'sanct' & 'peter' )$$::tsquery;
 ?column? 
----------
 f
(1 row)

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)

so this seems to boil down to ts_rewrite failing to apply required
normalization.  Or maybe the normalization shouldn't be required.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [sqlsmith] Failed assertion in TS_phrase_execute
  2016-11-26 15:11 [sqlsmith] Failed assertion in TS_phrase_execute Andreas Seltenreich <seltenreich@gmx.de>
  2016-11-26 18:51 ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-11-26 22:33   ` Tom Lane <tgl@sss.pgh.pa.us>
  2016-12-15 23:25     ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2016-11-26 22:33 UTC (permalink / raw)
  To: Oleg Bartunov <obartunov@gmail.com>; Teodor Sigaev <teodor@sigaev.ru>; +Cc: Andreas Seltenreich <seltenreich@gmx.de>; 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.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [sqlsmith] Failed assertion in TS_phrase_execute
  2016-11-26 15:11 [sqlsmith] Failed assertion in TS_phrase_execute Andreas Seltenreich <seltenreich@gmx.de>
  2016-11-26 18:51 ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
  2016-11-26 22:33   ` Re: [sqlsmith] Failed assertion in TS_phrase_execute Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-12-15 23:25     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2016-12-15 23:25 UTC (permalink / raw)
  To: Oleg Bartunov <obartunov@gmail.com>; Teodor Sigaev <teodor@sigaev.ru>; +Cc: Andreas Seltenreich <seltenreich@gmx.de>; 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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2016-12-15 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-11-26 15:11 [sqlsmith] Failed assertion in TS_phrase_execute Andreas Seltenreich <seltenreich@gmx.de>
2016-11-26 18:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-11-26 22:33   ` Tom Lane <tgl@sss.pgh.pa.us>
2016-12-15 23:25     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox