Skip site navigation (1) Skip section navigation (2)

Re: limitation using LIKE on ANY(array)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: K C Lau <kclau60(at)netvigator(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: limitation using LIKE on ANY(array)
Date: 2006-03-24 16:25:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
K C Lau <kclau60(at)netvigator(dot)com> writes:
> Indeed, I get rejected even with:
> .. WHERE ANY(array) = 'xx'

> It would only work as documented in the manual (8.10.5):
> SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

That's not changing any time soon; the SQL spec defines only the second
syntax for ANY, and I believe there would be syntactic ambiguity if we
tried to allow the other.

> With 8.1.3, I get an error when trying to do this on a Text[] column :
> .. WHERE ANY(array) LIKE 'xx%'

If you're really intent on doing that, make an operator for "reverse
LIKE" and use it with the ANY on the right-hand side.

regression=# create function rlike(text,text) returns bool as
regression-# 'select $2 like $1' language sql strict immutable;
regression=# create operator ~~~ (procedure = rlike, leftarg = text,
regression(# rightarg = text, commutator = ~~);
regression=# select 'xx%' ~~~ any(array['aaa','bbb']);
(1 row)

regression=# select 'xx%' ~~~ any(array['aaa','xxb']);
(1 row)


			regards, tom lane

In response to


pgsql-performance by date

Next:From: Scott MarloweDate: 2006-03-24 16:42:58
Subject: Re: Postmaster using only 4-5% CPU
Previous:From: Tom LaneDate: 2006-03-24 16:02:34
Subject: Re: Performance problems with multiple layers of functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group