Re: Disabling case sensitivity

From: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Disabling case sensitivity
Date: 2002-07-10 13:33:39
Message-ID: 20020710133339.GA16235@nic.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On Wed, Jul 10, 2002 at 03:22:00PM +0200,
Michael Meskes <meskes(at)postgresql(dot)org> wrote
a message of 31 lines which said:

> Can't you use something like
>
> SELECT from table where tolower(username)='good';

If you want sometimes case-sensitive comparison and sometimes not, it
is a good solution (the PostgreSQL extension ILIKE is another). But if
you want to "disable case-sensitivity", you risk that some
applications forget the call to tolower(). Therefore, I prefer to
create a trigger which will force the field to lowercase before
INSERTing it. (The problem of my solution is that it is no longer
case-preserving.)

CREATE FUNCTION force_lower_case() RETURNS OPAQUE
AS 'BEGIN
NEW.name = lower(NEW.name);
RETURN NEW;
END;'
LANGUAGE PLPGSQL;

-- Domain names are only in US-ASCII (so no locale problems) and are
-- case-insensitive. If you want to record the original case, add a
-- new field.
CREATE TRIGGER force_lower_case
BEFORE INSERT ON Domains
FOR EACH ROW
EXECUTE PROCEDURE force_lower_case();

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Brannen 2002-07-10 14:54:06 Re: Authentication in batch processing
Previous Message Michael Meskes 2002-07-10 13:22:00 Re: Disabling case sensitivity

Browse pgsql-general by date

  From Date Subject
Next Message Adrian 'Dagurashibanipal' von Bidder 2002-07-10 13:44:56 Re: Flag for insentive use of Postgres?
Previous Message Mourad EL HADJ MIMOUNE 2002-07-10 13:28:54 Shared table across all databases