pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodger Donaldson <rodgerd@diaspora.gen.nz>
To: pgsql-sql@postgresql.org
Subject: Regular expression query
Date: Fri, 25 Aug 2000 15:13:34 +1200
Message-ID: <20000825151333.A26833@diaspora.gen.nz> (raw)


I have a large group of records which were entered with trailing garbage, in
the form of superfluous \n.

The main problem this has caused, other than the obvious one, is that the
record in question is being used as a primary key, so some duplicates have
slipped through.  I assumed a simple statement like:

SELECT url 
FROM sites
WHERE url ~ url || '\\s+'

...would allow me to find all the duplicate-but-not-quite records.

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

Encapsulating the concatenation in brackets leads the query parser to stop
bleating.  I presume this is simply a limitation in the parser's ability to
make inferences about regexps vs. LIKEs.

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.
Am I exceeding the capabilities of the regexp parser?

-- 
Rodger Donaldson		rodgerd@diaspora.gen.nz
I just had this vision of a young boy cowering in terror, whispering:
"I see dumb people"
		-- Steve VanDevender 



view thread (4+ messages)  latest in thread

Message-ID: <20000825151333.A26833@diaspora.gen.nz>
Permalink:  ../20000825151333.A26833@diaspora.gen.nz/
Also on:    postgresql.org/message-id/20000825151333.A26833@diaspora.gen.nz

 · 

reply

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: rodgerd@diaspora.gen.nz
  Subject: Re: Regular expression query
  In-Reply-To: <20000825151333.A26833@diaspora.gen.nz>
  References: <20000825151333.A26833@diaspora.gen.nz>

* 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