Back to the month index |
Back to the list index
|
Robert N. Sum (sumrn@hippolyta.crd.ge.com)
Wed, 16 Apr 97 13:47:27 -0400
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Dave McKenzie: "Re: [mSQL] Hour sheets"
- Previous message: WWW-Server MRTPATUB: "[mSQL] Large text fields via w3-msql?"
From: sumrn@hippolyta.crd.ge.com (Robert N. Sum) Message-Id: <199704161747.NAA09649@hippolyta.crd.ge.com> Subject: Re: [mSQL] Another types.c fix: TEXT matching. Date: Wed, 16 Apr 97 13:47:27 -0400All,
Oops. :( As Michael Brennen has pointed out, I forgot the context
in the patch for src/msql/types.c that I sent earlier concerning
matchVarChar (a.k.a TEXT). Here it is with the context which should
make it much easier to apply, especially if you are applying to the stock
types.c rather than to one with my previous patches.
-- Bob
===================================================================
RCS file: RCS/types.c,v
retrieving revision 1.3
diff -c -r1.3 types.c
*** types.c 1997/04/14 15:12:23 1.3
--- types.c 1997/04/16 13:03:41
***************
*** 1387,1393 ****
int matchVarChar(entry,data, cp, length, op)
cache_t *entry;
u_char *data;
! char *cp;
int length,
op;
{
--- 1387,1393 ----
int matchVarChar(entry,data, cp, length, op)
cache_t *entry;
u_char *data;
! char *cp; /* should be ok to assume this is nul-terminated */
int length,
op;
{
***************
*** 1397,1440 ****
dLen,
segLen,
cmp,
result;
u_int pos;
! bcopy(data,&dLen, sizeof(int));
! if (dLen == 0 && *cp == 0)
! return(1);
! if (dLen == 0 && *cp == 0)
! return(0);
!
! bcopy(data + sizeof(int) ,&pos, sizeof(u_int));
!
! cp1 = data + sizeof(int) + sizeof(u_int);
! cp2 = (u_char *)cp;
! segLen = count = dLen > length ? length : dLen;
! cmp = 0;
! while(dLen && *cp2)
{
! while(count)
{
! if ((cmp = *cp1 - *cp2) != 0)
! break;
! if ( *cp1==0 || *cp2==0)
break;
- count--;
- cp1++;
- cp2++;
- continue;
- }
- dLen -= segLen;
! if (dLen)
! {
! readOverflow(entry, pos, &pos, buf,
! dLen>OFB_SIZE? OFB_SIZE : dLen);
! cp1 = buf;
! count = segLen = dLen>OFB_SIZE? OFB_SIZE : dLen;
}
}
switch(op)
{
case EQ_OP:
--- 1397,1468 ----
dLen,
segLen,
cmp,
+ decided,
result;
u_int pos;
! cmp = 0; /* current value of match, initially equal */
! bcopy(data,&dLen, sizeof(int)); /* get length of TEXT data */
!
! if (*cp == 0 || dLen == 0)
! {
! /* if either or both are zero length,
! * set cmp so that inequalities work.
! * Longer string is greater.
! */
! cmp = (*cp == 0) ? dLen : -1;
! }
! else
{
! /* examine individual characters */
!
! bcopy(data + sizeof(int) ,&pos, sizeof(u_int));
!
! cp1 = data + sizeof(int) + sizeof(u_int);
! cp2 = (u_char *)cp;
! segLen = count = dLen > length ? length : dLen;
! decided = 0; /* set to 1 when final value is known */
! while(dLen && *cp2)
{
! while(count)
! {
! if ((cmp = *cp1 - *cp2) != 0)
! {
! decided = 1;
! break;
! }
! if ( *cp1==0 || *cp2==0)
! {
! decided = 1;
! break;
! }
! count--;
! cp1++;
! cp2++;
! }
!
! /* if inner loop decided the value, break this loop */
! if (decided)
break;
! dLen -= segLen;
!
! if (dLen)
! {
! readOverflow(entry, pos, &pos, buf,
! dLen>OFB_SIZE? OFB_SIZE : dLen);
! cp1 = buf;
! count = segLen = dLen>OFB_SIZE? OFB_SIZE : dLen;
! }
}
+ /* RNS:
+ * If TEXT fields are not nul-terminated, then we could run
+ * off of the end without deciding. Check here.
+ */
+ if (!decided)
+ cmp = '\0' - *cp2;
}
+
switch(op)
{
case EQ_OP:
Robert Sum Phone: +1 (518) 387-7696
G.E. Corp. R. & D. E-mail: sumrn@crd.ge.com
P.O. Box 8, Rm. KW-C279 Eng. & Manuf. WWW: http://ce-toolkit.crd.ge.com
Schenectady, NY 12301 USA GE's general WWW: http://www.ge.com
Please note that the "Standard Disclaimer" applies here.
--------------------------------------------------------------------------
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!
- Next message: Dave McKenzie: "Re: [mSQL] Hour sheets"
- Previous message: WWW-Server MRTPATUB: "[mSQL] Large text fields via w3-msql?"