Re: Regular expressions and arrays and ANY() question

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: webb(dot)sprague(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Regular expressions and arrays and ANY() question
Date: 2007-01-23 07:41:42
Message-ID: 20070123074142.GB19527@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pascal Lequeux 2007-01-23 08:23:06 array_to_string return is different between Windows and Linux systems
Previous Message Martijn van Oosterhout 2007-01-23 07:27:28 Re: [HACKERS] Autovacuum Improvements