[plainto_tsquery] using OR

From: "Sven R(dot) Kunze" <srkunze(at)tbz-pariv(dot)de>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: [plainto_tsquery] using OR
Date: 2015-05-27 11:09:51
Message-ID: 5565A5FF.5010701@tbz-pariv.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everybody,

I struggle to find a clean solution in an application to safely parse
the query input string of a user.

Currently, I am inclined to split the string with some magic regex and
build it safely together using ' | '. That solution, however, is
error-prone and hides the powerful features of tsquery that PostgreSQL
could provide from the user.

Is there a way to safely create a tsquery out of user's input?
Optionally, when the user types '&', '|', '!' '(' and ')' it could be
interpreted like typical tsquery syntax BUT still creates valid tsquery.

Regards,

--
Sven R. Kunze
TBZ-PARIV GmbH, Bernsdorfer Str. 210-212, 09126 Chemnitz
Tel: +49 (0)371 33714721, Fax: +49 (0)371 5347920
e-mail: srkunze(at)tbz-pariv(dot)de
web: www.tbz-pariv.de

Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz
Registergericht: Chemnitz HRB 8543

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2015-05-27 13:05:57 Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
Previous Message Albe Laurenz 2015-05-27 10:07:47 Re: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"