Help! isstart() error
Posted in 1994
Topics: Stored Procedures & SPL, Data Types & Schema Design
Hi I attempted to write a C program to read a C-Isam file by one of the existing indices, but it just died at isstart() with error 103 (Bad key desc). I was unable to find out the reason. The index I chose, as shown by 'bcheck' is made up of the following fields: Field Offset Field Length Data Type 0 7 CHARTYPE 7 7 CHARTYPE I've enclosed a segment of my program and the output of 'bcheck' on the said C-Isam file. Thanks in advance. cheewai -- SW International Systems Pte Ltd | #include <disclaimer.h> 14, Science Park Drive | Singapore Science Park | Moebius strippers never Singapore 0511 | show you their backside. Tel: (65) 778-0066 | Fax: (65) 777-9401 | swispl@solomon.technet.sg [segment of my program] <--------------------------------start here---------------------------------> #include <stdio.h> #include <string.h> #include "isam.h" #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> /* field offset, length and data type in the record */ #define FLD1_POS 0 #define FLD1_LEN 7 #define FLD1_TYPE CHARTYPE #define FLD2_POS 7 #define FLD2_LEN 7 #define FLD2_TYPE CHARTYPE #define RECSIZE 211 extern char *sys_errlist[]; main() { int isfd; char fname[] = "./myisam"; char recbuf[RECSIZE]; struct dictinfo info; long recsize; struct keydesc usekey; /* * open isam file for Input & Output * Specify Automatic record locking */ if( (isfd = isopen(fname, ISINOUT+ISAUTOLOCK)) ) { if (iserrno > 100) { fprintf(stderr, "isopen error %d (%s) on %s\\n", iserrno, is_errlist[iserrno-100], fname); } else { fprintf("isopen error %d (%s) on %s\\n", iserrno, sys_errlist[iserrno], fname); } exit(1); } /* get index/file structure information */ isindexinfo(isfd, &info, 0 ); recsize = info.di_recsize; fprintf(stderr, "record size = %d\\n", recsize); fprintf(stderr, "Number of records = %d\\n", info.di_nrecords) ; fprintf(stderr, "Number of indices = %d\\n", info.di_nkeys) ; /* set up key structure for isstart */ usekey.k_flags = ISDUPS; /* duplicate allowed */ usekey.k_nparts = 2; /* 2 fields in key, 1st & 2nd field */ usekey.k_part[0].kp_start = FLD1_POS; usekey.k_part[0].kp_leng = FLD1_LEN; usekey.k_part[0].kp_type = FLD1_TYPE; usekey.k_part[1].kp_start = FLD2_POS; usekey.k_part[1].kp_leng = FLD2_LEN; usekey.k_part[1].kp_type = FLD2_TYPE; if( isstart(isfd,&usekey,0,recbuf,ISFIRST) ) { fprintf(stderr, "isstart error %d (%s) on %s\\n", iserrno, is_errlist[iserrno-100],fname); isclose(isfd); exit(1) ; } if( isread(isfd, recbuf, ISCURR) && (info.di_nrecords > 0) ) { fprintf(stderr, "isread error %d (%s) on %s\\n", iserrno, is_errlist[iserrno-100],filename) ; isclose(isfd); exit(1) ; } /* other processing follows ... */ } <--------------------------------end here---------------------------------> [bcheck output] <-------------------------------start here---------------------------------> BCHECK C-ISAM B-tree Checker version 1.07 Copyright (C) 1981-1988 Informix Software, Inc. Software Serial Number CMM#R127582 C-ISAM Files: ./myisam Checking dictionary and file sizes. index file node size = 1024 current C-ISAM index node size = 1024 Checking data file records. Checking indexes and key descriptions. Index 1 = duplicates(14,2,0) (0,7,0) (7,7,0) 1 index node(s) used --1 index b-tree level(s) used Index 2 = duplicates(0,7,0) (7,7,0) 1 index node(s) used --1 index b-tree level(s) used Index 3 = duplicates(100,11,0) (14,2,0) (18,4,0) (0,7,0) (7,7,0) 1 index node(s) used --1 index b-tree level(s) used Index 4 = duplicates(14,2,0) (18,4,0) (0,7,0) (7,7,0) 1 index node(s) used --1 index b-tree level(s) used Checking data record and index node free lists. 6 index node(s) used, 0 free --3 data record(s) used, 1 free <-------------------------------end here---------------------------------> [program output] <-------------------------------start here---------------------------------> record size = 211 Number of records = 3 Number of indices = 4 isstart error 103 (Bad key descriptor) on ./myisam <-------------------------------end here--------------------------------->