Path: utzoo!utgpu!attcan!uunet!keysec!nancy!ivon From: ivon@nancy.UUCP (Ivon Gois) Newsgroups: comp.databases Subject: CTREE only looking at first 4 bytes? Message-ID: <180@nancy.UUCP> Date: 11 Aug 89 19:40:11 GMT Reply-To: ivon@nancy.UUCP (Ivon Gois) Distribution: na Organization: American Systems Corporation, Chantilly, VA Lines: 70 I've been tasked with writting my first module using CTREE. I had recently learned from several people on the net what a wonderful product it is so I thought it would be a piece of cake (well so it goes). In all fairness it has make my life a lot easier. The module currently has two keys, the second allows for duplicates. Each of the keys is made up of two strings concatenated together. Now the question, why is ctree only looking at the first 4 bytes of key_2 (the second key)? If I add records with the first 4 bytes of the second key field different it works fine but if the only difference between two (or more) records is from the fifth byte on it will return all the records that match the first four bytes. Help. Here is how I initiaze and call CTREE: #define MaxKey_1 10 #define MaxKey_2 10 typedef struct /* used as the "current record" in CTREE terminology */ { char key_1[MAXkey_1+1]; char key_2[MAXkey_2+1]; . . . other stuff } rec rec curr_rec; static ISEG Key_seg_1[] = { { offsetof(rec, key_1), sizeof(curr_rec.key_1), 0 } }; static ISEG Key_seg_2[] = { { offsetof(rec, key_2), sizeof(curr_rec.key_2), 0 } }; static IIDX Index[] = { #define key_1 1 { sizeof(curr_rec.key_1), 0, 0, 1, 0, sizeof(Key_seg_1)/sizeof(ISEG), Key_seg_1, "key_1" }, #define key_2 2 { sizeof(curr_rec.key_2)+4, 4, 1, 1, 0, sizeof(Key_seg_2)/sizeof(ISEG), Key_seg_2, "key_2" } }; #define ROUND_TO_BLOCK_BOUNDARY(data_size, block_size) \ ((((data_size) + (block_size) - 1) / (block_size)) * (block_size)) static IFIL Data_file = { CSFDATAPATH, 0, sizeof(rec), ROUND_TO_BLOCK_BOUNDARY(8 * sizeof(rec), BUFSIZ), (PERMANENT | SHARED | FIXED), sizeof(Index)/sizeof(IIDX), BUFSIZ, (PERMANENT | SHARED | FIXED), Index }; Here are the calls that I'm making to ctree: FRSSET(key_2,&curr_rec,sizeof(key_2)); and subsequently: NXTSET(key_2,&curr_rec); I thought some of you might have run across this problem. Any ideas/suggestions would be most helpful. Thanks in advance, -ivon #include /* of course (-:-) */