Re: Checking is TSearch2 query is valid

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Benjamin Arai <me(at)benjaminarai(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Checking is TSearch2 query is valid
Date: 2007-09-09 14:54:27
Message-ID: 18174.1189349667@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Benjamin Arai <me(at)benjaminarai(dot)com> writes:
> Is there a way to pass a query to PostgreSQL to check if the
> TSeasrch2 search text is valid? For example,
> SELECT to_tsquery('default', '!');
> returns an error. I want to know if there is a way get true/false
> for the '!' portion of the query?

The generic solution to this type of problem is to write a function that
tries to do whatever-it-is-that-throws-an-error inside a plpgsql
BEGIN/EXCEPTION block, and catch the errors you are expecting.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message novnov 2007-09-09 16:11:17 Re: Scalability Design Questions
Previous Message Merlin Moncure 2007-09-09 13:42:05 Re: SQL for Deleting all duplicate entries