Обсуждение: Strange behavior on to_tsquery()

Поиск
Список
Период
Сортировка

Strange behavior on to_tsquery()

От
Rodrigo Hjort
Дата:
Hello PG hackers,<br /><br />I created a <b>custom dictionary</b> (based on dict_int) and a search configuration and a
strangebehavior happens on <b>PostgreSQL 8.4.9</b>.<br /><br />When I invoke the following instruction several
times,<b>to_tsquery()</b> returns distinct results:<br /><br /><span style="font-family: courier
new,monospace;">catalog=>SELECT to_tsquery('custom', 'pi');</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;"> to_tsquery </span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">------------</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;"> 'pi':*</span><br style="font-family: courier new,monospace;"
/><spanstyle="font-family: courier new,monospace;">(1 registro)</span><br style="font-family: courier new,monospace;"
/><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">catalog=>
SELECTto_tsquery('custom', 'pi');</span><br style="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;"> to_tsquery </span><br style="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;">------------</span><br style="font-family: courier new,monospace;" /><span style="font-family:
couriernew,monospace;"> 'pi'</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier
new,monospace;">(1registro)</span><br /><br />Therefore, when I use <b>@@ operator</b> over a <b>tsvector</b> column in
mytable the result set is not always the same.<br /><br />1) Do you have any clue on what could be happening and how to
solvethis issue, please?<br /><br />2) Sometimes the value returned by <b>to_tsquery()</b> has a ":*" suffix. What does
thatmean?<br /><br />Thanks in advance.<br /><br />Best Regards,<br /><br />-- <br />Rodrigo Hjort<br /><a
href="http://www.hjort.co"target="_blank">www.hjort.co</a><br /><br /> 

Re: Strange behavior on to_tsquery()

От
Tom Lane
Дата:
Rodrigo Hjort <rodrigo.hjort@gmail.com> writes:
> I created a *custom dictionary* (based on dict_int) and a search
> configuration and a strange behavior happens on *PostgreSQL 8.4.9*.
> ...
> Therefore, when I use *@@ operator* over a *tsvector* column in my table
> the result set is not always the same.

This almost certainly means a bug in your dictionary code.

> 2) Sometimes the value returned by *to_tsquery()* has a ":*" suffix. What
> does that mean?

Prefix search request.  Possibly you're forgetting to zero out the
prefix flag?

(Just offhand, it rather looks like dict_int and dict_xsyn are both
assuming that palloc will give back zeroed space, which is bogus...)
        regards, tom lane


Re: Strange behavior on to_tsquery()

От
Tom Lane
Дата:
I wrote:
> (Just offhand, it rather looks like dict_int and dict_xsyn are both
> assuming that palloc will give back zeroed space, which is bogus...)

Yeah, this is definitely broken.  Patches committed; thanks for the
report.
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=e3e3087d8717c26cd1c4581ba29274ac214eb816
        regards, tom lane


Re: Strange behavior on to_tsquery()

От
Rodrigo Hjort
Дата:
<div class="gmail_quote">2011/11/3 Tom Lane <br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex;
border-left:1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">I wrote:<br /> > (Just offhand, it
ratherlooks like dict_int and dict_xsyn are both<br /> > assuming that palloc will give back zeroed space, which is
bogus...)<br/><br /></div>Yeah, this is definitely broken.  Patches committed; thanks for the<br /> report.<br /><a
href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=e3e3087d8717c26cd1c4581ba29274ac214eb816"
target="_blank">http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=e3e3087d8717c26cd1c4581ba29274ac214eb816</a><br
/><br/>                        regards, tom lane<br /></blockquote></div><br />I modified my code by calling
<i>palloc0()</i>instead and that issue no longer appears. :D<br /><br />Thanks, Tom Lane!<br /><br />-- <br />Rodrigo
Hjort<br/><a href="http://www.hjort.co" target="_blank">www.hjort.co</a><br /><br />