Back to the month index |
Back to the list index
|
Robert N. Sum (sumrn@hippolyta.crd.ge.com)
Wed, 16 Apr 97 09:53:30 -0400
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Matt Barnicle: "[mSQL] Getting Environment variables."
- Previous message: Fernando Lozano: "[mSQL] W3-mSQL - How to determine #rows returned?"
- Next in thread: Robert N. Sum: "Re: [mSQL] Another types.c fix: TEXT matching."
- Reply: Robert N. Sum: "Re: [mSQL] Another types.c fix: TEXT matching."
From: sumrn@hippolyta.crd.ge.com (Robert N. Sum) Message-Id: <199704161353.JAA07352@hippolyta.crd.ge.com> Subject: [mSQL] Another types.c fix: TEXT matching. Date: Wed, 16 Apr 97 09:53:30 -0400
All,
For those of you who have been brave enough to try the fixes that
I sent yesterday for 2.0 B6's src/msql/types.c file, I have a patch
to apply to that file to fix some problems with TEXT field comparisons.
(I have already forwarded fixes to Barnabus Steger and (I have already forwarded fixes to Barnabus Steger and bugs@Hughes.com.au.)
Here's a summary compared to my previous fixes:
In function matchVarChar:
Fixed handling of zero length values.
The short circuit evaluation (i.e., break statements) when result was
determined have been fixed now break all the way out as needed.
A missing check for non-nul-terminated TEXT fields has been added.
But, there still seems to be some problems with comparison to NULL
data i.e., data that isn't there as opposed to strings of length zero.
This appears to need fixing elsewhere in the code.
One can apply this patch to the native 2.0 B6 types.c file because
its changes are independent of the others that I have made, but it will
take some attention on the part of the operator. The patch is not
as big as it looks because it contains quite a few lines whose modification
was solely indentation for readability.
-- Bob
===================================================================
RCS file: RCS/types.c,v
retrieving revision 1.3
diff -r1.3 types.c
1390c1390
< char *cp;
--- > char *cp; /* should be ok to assume this is nul-terminated */ 1399a1400 > decided, 1403,1415c1404,1415 < 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)--- > 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 1417c1417,1425 < while(count)--- > /* 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) 1419,1421c1427,1445 < if ((cmp = *cp1 - *cp2) != 0) < break; < if ( *cp1==0 || *cp2==0)--- > 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) 1423,1428d1446 < count--; < cp1++; < cp2++; < continue; < } < dLen -= segLen; 1430,1435c1448,1456 < if (dLen) < { < readOverflow(entry, pos, &pos, buf, < dLen>OFB_SIZE? OFB_SIZE : dLen); < cp1 = buf; < count = segLen = dLen>OFB_SIZE? OFB_SIZE : dLen;--- > 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; > } 1436a1458,1463 > /* 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; 1437a1465 >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: Matt Barnicle: "[mSQL] Getting Environment variables."
- Previous message: Fernando Lozano: "[mSQL] W3-mSQL - How to determine #rows returned?"
- Next in thread: Robert N. Sum: "Re: [mSQL] Another types.c fix: TEXT matching."
- Reply: Robert N. Sum: "Re: [mSQL] Another types.c fix: TEXT matching."