Re: tsearch2 error msg

Lists: pgsql-hackers
From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: tsearch2 error msg
Date: 2006-10-03 14:34:06
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCEA3577A@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

search=# select to_tsquery('foo bar');
ERROR: syntax error

Might want to enhance that message to include the information that it's
parsing the tsquery that's failing? I originally had it as part of a
much larger query, and it took me a while to remember that it's tsearch
that spits out that very generic error message.

//Magnus


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Magnus Hagander <mha(at)sollentuna(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch2 error msg
Date: 2006-10-03 14:44:31
Message-ID: 4522774F.2070609@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> Might want to enhance that message to include the information that it's
> parsing the tsquery that's failing? I originally had it as part of a
> much larger query, and it took me a while to remember that it's tsearch
> that spits out that very generic error message.
It possible, but not for 8.2 :(

BTW, try
# select plainto_tsquery('foo bar');
plainto_tsquery
-----------------
'foo' & 'bar'
(1 row)

It parses plain text and makes tsquery. Function exists only in 8.2 - some later
we add docs about changes in tsearch2.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Teodor Sigaev" <teodor(at)sigaev(dot)ru>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tsearch2 error msg
Date: 2006-10-03 14:45:39
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCEA3577B@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> > Might want to enhance that message to include the information
> that
> > it's parsing the tsquery that's failing? I originally had it as
> part
> > of a much larger query, and it took me a while to remember that
> it's
> > tsearch that spits out that very generic error message.
> It possible, but not for 8.2 :(

Ok :-( Might want to put on TIDI?

> BTW, try
> # select plainto_tsquery('foo bar');
> plainto_tsquery
> -----------------
> 'foo' & 'bar'
> (1 row)
>
> It parses plain text and makes tsquery. Function exists only in 8.2
> - some later we add docs about changes in tsearch2.

Ah, just what i've been looking for. The tsearch2 enhancements in 8.2
just get better and better :-)
(And I'm working on 8.2beta, so it's not a problem)

//Magnus


From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Magnus Hagander <mha(at)sollentuna(dot)net>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch2 error msg
Date: 2006-10-03 14:49:05
Message-ID: Pine.GSO.4.63.0610031848170.681@ra.sai.msu.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 3 Oct 2006, Magnus Hagander wrote:

>> BTW, try
>> # select plainto_tsquery('foo bar');
>> plainto_tsquery
>> -----------------
>> 'foo' & 'bar'
>> (1 row)
>>
>> It parses plain text and makes tsquery. Function exists only in 8.2
>> - some later we add docs about changes in tsearch2.

Current docs, covering 8.2 is available from
http://www.sai.msu.su/~megera/wiki/tsearch2slides

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83


From: AgentM <agentm(at)themactionfaction(dot)com>
To: PostgreSQL-development hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tsearch2 error msg
Date: 2006-10-03 16:55:39
Message-ID: 551DED42-1923-452E-8DFE-742CAEC740D0@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Oct 3, 2006, at 10:49 , Oleg Bartunov wrote:

> On Tue, 3 Oct 2006, Magnus Hagander wrote:
>
>>> BTW, try
>>> # select plainto_tsquery('foo bar');
>>> plainto_tsquery
>>> -----------------
>>> 'foo' & 'bar'
>>> (1 row)
>>>
>>> It parses plain text and makes tsquery. Function exists only in 8.2
>>> - some later we add docs about changes in tsearch2.
>
> Current docs, covering 8.2 is available from http://www.sai.msu.su/
> ~megera/wiki/tsearch2slides

This is great news- previously, I was using various regexes to
sanitize input into user-accessible search fields. Would it be build
in some simple query language?

"sam AND spade"
"blue OR yellow"
"(same AND spade) OR (blue AND yellow)"

Obviously, the conjunctions would need to be defined on a per-locale
basis.

-M


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: AgentM <agentm(at)themactionfaction(dot)com>
Cc: PostgreSQL-development hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tsearch2 error msg
Date: 2006-10-03 17:03:46
Message-ID: 452297F2.8050401@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> This is great news- previously, I was using various regexes to sanitize
> input into user-accessible search fields. Would it be build in some
> simple query language?
>
> "sam AND spade"
> "blue OR yellow"
> "(same AND spade) OR (blue AND yellow)"

That's exactly to_tsquery syntax, just change AND to & and OR to |. :)
So, if you can validate AND/OR then you can validate &/| syntax or validate
AND/OR and change they to tsquery's equivalents.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Magnus Hagander <mha(at)sollentuna(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch2 error msg
Date: 2006-10-03 20:59:55
Message-ID: 20061003205955.GB17658@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Oct 03, 2006 at 04:34:06PM +0200, Magnus Hagander wrote:
> search=# select to_tsquery('foo bar');
> ERROR: syntax error

Seems to me, at the very least, the message should be:

ERROR: tsearch: syntax error

Then people have an idea where it comes from.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch2 error msg
Date: 2006-10-03 22:28:14
Message-ID: 25118.1159914494@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> On Tue, Oct 03, 2006 at 04:34:06PM +0200, Magnus Hagander wrote:
>> search=3D# select to_tsquery('foo bar');
>> ERROR: syntax error

> Seems to me, at the very least, the message should be:
> ERROR: tsearch: syntax error

No, it should be something like

syntax error in tsearch query: "contents of string"

since it's not always the case that you know exactly what string got fed
to to_tsquery().

regards, tom lane


From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch2 error msg
Date: 2006-10-04 09:51:20
Message-ID: 45238418.7090501@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi, Tom,

Tom Lane wrote:

> No, it should be something like
>
> syntax error in tsearch query: "contents of string"
>
> since it's not always the case that you know exactly what string got fed
> to to_tsquery().

I agree.

It's also possible that you have more than one tsearch expression in the
query (e. G. by joining different tables), so that will help further.

HTH,
Markus

--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org