Mailing List Archive



Back to the month index Back to the list index

Brendan Quinn (brendan@nexus.sofcom.com.au)
Thu, 3 Apr 1997 18:12:38 +1000 (EST)


From: Brendan Quinn <brendan@nexus.sofcom.com.au>
Message-Id: <199704030812.SAA07637@nexus.sofcom.com.au>
Subject: Re: [mSQL] Strange mSQL behavior... bug with LIKE functionality?
Date: Thu, 3 Apr 1997 18:12:38 +1000 (EST)

> Can anyone help with this? When I perform the following select I get back a record I wouldn't expect, the Devereux name field does not have the string 'ABC' in it.

Yup, I found this a month or so ago, and supplied a patch, just after b4 came
out. I expected the patch to be included in b5, but it apparently wasn't...
Maybe Bambi forgot or lost it in his unending stream of mail?

> SELECT pin,name,address,city,state,zip FROM schools WHERE state='CA' AND
> name LIKE '%ABC%'\g
>
> Query OK. 3 row(s) modified or retrieved.
>
> | pin | name | address | city | state | zip |
> | 00079117 | DEVEREUX FOUNDATION CALIFORNIA | PO BOX 1079 |
> SANTA BARBARA | CA | 931021079 |
> | 00156353 | BABCOCK ELEMENTARY SCHOOL | 2400 CORMORANT WAY |
> SACRAMENTO | CA | 958152790 |
> | 04152763 | ABC EDUCATIONAL CENTER | 1129 COLE AVE |
> LOS ANGELES | CA | 900381501 |

Let me guess -- your 'name' field is exactly 30 characters wide? We were
finding the same problem -- a like search will always match a full field if
the last character of the like matches the last character of the field.

Here's the patch, rejigged for beta 5: (NB this is right as I remember it but
I've lost my original version and I don't have time to compile it again now,
so caveat emptor)

*** types.c.orig Thu Apr 3 18:10:21 1997
--- types.c Thu Apr 3 18:10:44 1997
***************
*** 135,141 ****
                          {
                                  if (*cp1 == *cp2)
                                  {
! if(likeTest(cp1,cp2,length-count)==1)
                                          {
                                                  return(1);
                                          }
--- 135,141 ----
                          {
                                  if (*cp1 == *cp2)
                                  {
! if(likeTest(cp1,cp2,length-count-1)==1)
                                          {
                                                  return(1);
                                          }
***************
*** 221,227 ****
                          {
                                  if (toupper(*cp1) == toupper(*cp2))
                                  {
! if(cLikeTest(cp1,cp2,length-count)==1)
                                          {
                                                  return(1);
                                          }
--- 221,227 ----
                          {
                                  if (toupper(*cp1) == toupper(*cp2))
                                  {
! if(cLikeTest(cp1,cp2,length-count-1)==1)
                                          {
                                                  return(1);
                                          }

See if that helps.

-- 
Brendan Quinn                  |  brendan@nexus.sofcom.com.au
Sofcom Distributors Pty Ltd    | 
Level 1, 399 Riversdale Rd     |    Phone:  +61 3 9882 3811
Hawthorn East 3123             |    Fax:    +61 3 9882 7619
Victoria, AUSTRALIA            |     http://www.sofcom.com
--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com.  Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!