Sender: owner-postgres95@postgres.Berkeley.EDU
X-Return-Path: andrew_yu
Received: from huginn.CS.Berkeley.EDU (huginn.CS.Berkeley.EDU [128.32.35.5]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with ESMTP id OAA06190 for <postgres95@nobozo.cs.berkeley.edu>; Tue, 7 Nov 1995 14:14:26 -0800
Received: from mail-d.bcc.ac.uk (mail-d.bcc.ac.uk [144.82.100.24]) by huginn.CS.Berkeley.EDU (8.6.11/8.7.0.Beta0) with SMTP id OAA27187 for <postgres95@nobozo.cs.berkeley.edu>; Tue, 7 Nov 1995 14:10:04 -0800
Received: from bsm.biochemistry.ucl.ac.uk (actually bsmcha1.biochem.ucl.ac.uk) 
          by mail-d.bcc.ac.uk with SMTP (PP); Tue, 7 Nov 1995 09:55:26 +0000
Received: from bsmir06 (bsmir06 [128.40.46.43]) 
          by bsm.biochemistry.ucl.ac.uk (950215.SGI.8.6.10/8.6.6) with ESMTP 
          id JAA22081 for <postgres95@nobozo.cs.berkeley.edu>;
          Tue, 7 Nov 1995 09:32:03 GMT
From: Andrew Martin <martin@bsm.biochemistry.ucl.ac.uk>
Received: (martin@localhost) by bsmir06 (950215.SGI.8.6.10/8.6.6) id JAA26262 
          for postgres95@nobozo.cs.berkeley.edu; Tue, 7 Nov 1995 09:32:02 GMT
Date: Tue, 7 Nov 1995 09:32:02 GMT
Message-Id: <199511070932.JAA26262@bsmir06>
To: postgres95@postgres.Berkeley.EDU
Subject: Re: Is this OK to do for case-insensitive like matching?
Reply-To: martin@bsm.biochemistry.ucl.ac.uk
Resent-To: postgres95-redist
Resent-Date: Tue, 07 Nov 95 14:14:27 -0800
Resent-From: pglite
Resent-XMts: smtp

> 
> Well, I'm new to Postgres95 and this list but it seems that everyone 
> wants to do case-insensitive (CI) searches.  And so do I!  I've implemented 
> an email database on the WWW using Postgres95 and pg95perl5 and wanted to 
> do to CI searches on the name, department, and email address columns.  
> These fields are of the type 'text'.  What I've done is modify the 
> function DoMatch( ) in src/backend/utils/adt/like.c and changed the default 
> section of the case to:  
> 
> if (tolower(*text) != tolower(*p))  
One small point here, the standard definition for tolower(), toupper(), etc.
says that the behaviour is undefined if the character is already in the
required case. This broke some code of mine on an Evans & Sutherland Unix
workstation. So, you should probably define a macro like safetolower() as

#define safetolower(x) (islower(x)?(x):tolower(x))

and use that in your comparison.


> 
> So now all of my like searches are CI (which I can live with since 
> most of my searches are substring searches).  Is this kosher?  Everything 
> seems to be working great so far...  I didn't want to do the messy regexp 
> scene as I thought this would slow me down quite a bit.
> 
> +----------------------------------------------------------------------------+
> Alvis Harding Jr.                                 Arkansas Children's Hospital
> Systems Analyst                                         Cardiac Imaging Center
> (501) 320-3613                                           Little Rock, AR 72202
> adh@george.ach.uams.edu                           http://www.ach.uams.edu/~adh

Andrew

****************************************************************************
Dr. Andrew C.R. Martin,         University College London & SciTech Software
EMAIL: martin@biochem.ucl.ac.uk                Tel:(Work) +44(0)171 419 3284
URL: http://www.biochem.ucl.ac.uk/~martin          (Home) +44(0)1372 275775
****************************************************************************

===============================================================================
  To unsubscribe from the Postgres95 mailing list, send mail with the subject
  line "DEL" to "postgres95-request@postgres.Berkeley.EDU". 
============  URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres95/  ===========
