Re: Strange behavior on to_tsquery()

Lists: pgsql-hackers
From: Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Strange behavior on to_tsquery()
Date: 2011-11-03 21:11:35
Message-ID: CAAjEfRz+TCTWX=cG6gPx+sDpsa9QN16s9X6+4F1RkyR6vUBWsg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello PG hackers,

I created a *custom dictionary* (based on dict_int) and a search
configuration and a strange behavior happens on *PostgreSQL 8.4.9*.

When I invoke the following instruction several times,*
to_tsquery()*returns distinct results:

catalog=> SELECT to_tsquery('custom', 'pi');
to_tsquery
------------
'pi':*
(1 registro)

catalog=> SELECT to_tsquery('custom', 'pi');
to_tsquery
------------
'pi'
(1 registro)

Therefore, when I use *@@ operator* over a *tsvector* column in my table
the result set is not always the same.

1) Do you have any clue on what could be happening and how to solve this
issue, please?

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

Thanks in advance.

Best Regards,

--
Rodrigo Hjort
www.hjort.co


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange behavior on to_tsquery()
Date: 2011-11-03 22:21:42
Message-ID: 17700.1320358902@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange behavior on to_tsquery()
Date: 2011-11-03 23:20:40
Message-ID: 19292.1320362440@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange behavior on to_tsquery()
Date: 2011-11-04 19:35:47
Message-ID: CAAjEfRy55gNd66eAD8FZ6_hHDwGKsJwshSnQqMmc3hrDdaLAiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2011/11/3 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
>

I modified my code by calling *palloc0()* instead and that issue no longer
appears. :D

Thanks, Tom Lane!

--
Rodrigo Hjort
www.hjort.co