Re: Regular expressions and arrays and ANY() question - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Regular expressions and arrays and ANY() question
Date
Msg-id 20070123074142.GB19527@svana.org
Whole thread Raw
In response to Re: Regular expressions and arrays and ANY() question  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Regular expressions and arrays and ANY() question
List pgsql-general
On Tue, Jan 23, 2007 at 12:59:38AM -0500, Tom Lane wrote:
> >  I think the problem is because the pattern expects to be on the right
> > side with the target on the left, but I want to do it reversed.
>
> Yeah, the ANY syntax only allows the array on the right.  You'd have to
> make a LIKE-ish operator that takes the pattern on the left ... it'd
> take about two minutes to do this with a SQL or plpgsql function
> underlying the operator, but such a function might not be fast enough
> for you ...

If you created such a function, and made an operator with it that was a
communtator of LIKE (call it "is liked by"), would the planner be smart
enough to split the ANY and commutate it to the normal order?

i.e. convert:

foo "is_liked_by" ANY( 'bar', 'baz')

to

'bar' like foo OR 'baz' like foo.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: [HACKERS] Autovacuum Improvements
Next
From: stevegy@126.com
Date:
Subject: Re:   The jdbc