Re: Redefining LIKE operator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pablo Sajn n <psajnin(at)bejerman(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Redefining LIKE operator
Date: 2003-03-14 15:44:30
Message-ID: 21385.1047656670@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pablo Sajnn <psajnin(at)bejerman(dot)com(dot)ar> writes:
> I need the LIKE operator to be case insensitive.
> What I did is to redefine the ~~ so it behaves as the ~~* operator:

> DROP OPERATOR ~~ (name, text);
> CREATE OPERATOR ~~ ( leftarg=name, rightarg=text, procedure=nameiclike,
> negator='!~~');

> The operator is created, but when I execute a query, LIKE is still being
> case-sensitive.

There are five operators named '~~'; are you sure your LIKE is invoking
the "name" variant? I'd bet against that, if your tables are declared
with MSSQL-compatible datatypes.

I'd suggest renaming the standard operators out of the way, rather than
dropping them altogether. Also your CREATE is missing the selectivity
estimators. But in general this should work if you do it right.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Randal L. Schwartz 2003-03-14 15:57:52 Re: constant scalar subselect no longer equivalent to constant?
Previous Message Doug McNaught 2003-03-14 15:24:15 Re: Is a limitation for the number of large objects that can be stored in a PostgreSQL database?