From: Tom Lane <tgl@sss.pgh.pa.us>
To: rodgerd@diaspora.gen.nz
Cc: pgsql-sql@postgresql.org
Subject: Re: Regular expression query
Date: Fri, 25 Aug 2000 00:22:35 -0400
Message-ID: <825.967177355@sss.pgh.pa.us> (raw)
In-Reply-To: <20000825151333.A26833@diaspora.gen.nz>
References: <20000825151333.A26833@diaspora.gen.nz>
Rodger Donaldson <rodgerd@diaspora.gen.nz> writes:
> SELECT url
> FROM sites
> WHERE url ~ url || '\\s+'
> While this concatenation works with the LIKE directive (ie LIKE url || '%'),
> postgresql barfs on it in a regexp with the error:
> ERROR: Unable to identify an operator '||' for types 'bool' and 'unknown'
> You will have to retype this query using an explicit cast
LIKE and ~ do not have the same precedence. See
http://www.postgresql.org/docs/postgres/operators.htm.
~ and || actually fall in the same category ("all other") and therefore
are grouped left-to-right; so you're getting (url ~ url) || '...'.
> The other aspect of this is that it seems that postgresql's regexp engine
> doesn't understand some expected regexps; I've tried both escaped and
> unescaped versions of, eg \w, \s, \n and so on a pg seems to ignore them.
The regexp package we currently use implements POSIX 1003.2 regexps
(see src/backend/regex/re_format.7). I believe there is an item on the
TODO list about upgrading the regexp parser to something more modern
... feel free to hop on that project if it's bugging you ...
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, rodgerd@diaspora.gen.nz
Subject: Re: Regular expression query
In-Reply-To: <825.967177355@sss.pgh.pa.us>
References: <20000825151333.A26833@diaspora.gen.nz> <825.967177355@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox