diff options
Diffstat (limited to 'myisam/rt_test.c')
-rw-r--r-- | myisam/rt_test.c | 79 |
1 files changed, 29 insertions, 50 deletions
diff --git a/myisam/rt_test.c b/myisam/rt_test.c index bbeb8fce2d1..c1126c1939a 100644 --- a/myisam/rt_test.c +++ b/myisam/rt_test.c @@ -39,7 +39,6 @@ int main(int argc __attribute__((unused)),char *argv[] __attribute__((unused))) } - int run_test(const char *filename) { MI_INFO *file; @@ -48,6 +47,7 @@ int run_test(const char *filename) MI_COLUMNDEF recinfo[20]; MI_KEYDEF keyinfo[20]; HA_KEYSEG keyseg[20]; + key_range range; int silent=0; int opt_unique=0; @@ -66,15 +66,12 @@ int run_test(const char *filename) int upd= 10; ha_rows hrows; - - /* Define a column for NULLs and DEL markers*/ recinfo[0].type=FIELD_NORMAL; recinfo[0].length=1; /* For NULL bits */ rec_length=1; - /* Define 2*ndims columns for coordinates*/ for (i=1; i<=2*ndims ;i++){ @@ -83,7 +80,6 @@ int run_test(const char *filename) rec_length+=key_length; } - /* Define a key with 2*ndims segments */ keyinfo[0].seg=keyseg; @@ -101,8 +97,7 @@ int run_test(const char *filename) keyinfo[0].seg[i].language=default_charset_info->number; } - - if(!silent) + if (!silent) printf("- Creating isam-file\n"); bzero((char*) &create_info,sizeof(create_info)); @@ -115,15 +110,11 @@ int run_test(const char *filename) recinfo,uniques,&uniquedef,&create_info,create_flag)) goto err; - - - - if(!silent) + if (!silent) printf("- Open isam-file\n"); if (!(file=mi_open(filename,2,HA_OPEN_ABORT_IF_LOCKED))) goto err; - if (!silent) printf("- Writing key:s\n"); @@ -144,11 +135,9 @@ int run_test(const char *filename) } } - - if((error=read_with_pos(file,silent))) + if ((error=read_with_pos(file,silent))) goto err; - if (!silent) printf("- Reading rows with key\n"); @@ -160,12 +149,12 @@ int run_test(const char *filename) bzero((char*) read_record,MAX_REC_LENGTH); error=mi_rkey(file,read_record,0,record+1,0,HA_READ_MBR_EQUAL); - if(error && error!=HA_ERR_KEY_NOT_FOUND) + if (error && error!=HA_ERR_KEY_NOT_FOUND) { printf(" mi_rkey: %3d errno: %3d\n",error,my_errno); goto err; } - if(error == HA_ERR_KEY_NOT_FOUND) + if (error == HA_ERR_KEY_NOT_FOUND) { print_record(record,mi_position(file)," NOT FOUND\n"); continue; @@ -173,10 +162,6 @@ int run_test(const char *filename) print_record(read_record,mi_position(file),"\n"); } - - - - if (!silent) printf("- Deleting rows\n"); for (i=0; i < nrecords/4; i++) @@ -184,7 +169,7 @@ int run_test(const char *filename) my_errno=0; bzero((char*) read_record,MAX_REC_LENGTH); error=mi_rrnd(file,read_record,i == 0 ? 0L : HA_OFFSET_ERROR); - if(error) + if (error) { printf("pos: %2d mi_rrnd: %3d errno: %3d\n",i,error,my_errno); goto err; @@ -192,14 +177,13 @@ int run_test(const char *filename) print_record(read_record,mi_position(file),"\n"); error=mi_delete(file,read_record); - if(error) + if (error) { printf("pos: %2d mi_delete: %3d errno: %3d\n",i,error,my_errno); goto err; } } - if (!silent) printf("- Updating rows with position\n"); for (i=0; i < (nrecords - nrecords/4) ; i++) @@ -207,9 +191,9 @@ int run_test(const char *filename) my_errno=0; bzero((char*) read_record,MAX_REC_LENGTH); error=mi_rrnd(file,read_record,i == 0 ? 0L : HA_OFFSET_ERROR); - if(error) + if (error) { - if(error==HA_ERR_RECORD_DELETED) + if (error==HA_ERR_RECORD_DELETED) continue; printf("pos: %2d mi_rrnd: %3d errno: %3d\n",i,error,my_errno); goto err; @@ -219,19 +203,16 @@ int run_test(const char *filename) printf("\t-> "); print_record(record,mi_position(file),"\n"); error=mi_update(file,read_record,record); - if(error) + if (error) { printf("pos: %2d mi_update: %3d errno: %3d\n",i,error,my_errno); goto err; } } - - if((error=read_with_pos(file,silent))) + if ((error=read_with_pos(file,silent))) goto err; - - if (!silent) printf("- Test mi_rkey then a sequence of mi_rnext_same\n"); @@ -246,25 +227,20 @@ int run_test(const char *filename) print_record(read_record,mi_position(file)," mi_rkey\n"); row_count=1; - - do { - if((error=mi_rnext_same(file,read_record))) + for (;;) + { + if ((error=mi_rnext_same(file,read_record))) { - if(error==HA_ERR_END_OF_FILE) + if (error==HA_ERR_END_OF_FILE) break; printf("mi_next: %3d errno: %3d\n",error,my_errno); goto err; } print_record(read_record,mi_position(file)," mi_rnext_same\n"); row_count++; - }while(1); + } printf(" %d rows\n",row_count); - - - - - if (!silent) printf("- Test mi_rfirst then a sequence of mi_rnext\n"); @@ -277,10 +253,11 @@ int run_test(const char *filename) row_count=1; print_record(read_record,mi_position(file)," mi_frirst\n"); - for(i=0;i<nrecords;i++) { - if((error=mi_rnext(file,read_record,0))) + for (i=0;i<nrecords;i++) + { + if ((error=mi_rnext(file,read_record,0))) { - if(error==HA_ERR_END_OF_FILE) + if (error==HA_ERR_END_OF_FILE) break; printf("mi_next: %3d errno: %3d\n",error,my_errno); goto err; @@ -290,16 +267,18 @@ int run_test(const char *filename) } printf(" %d rows\n",row_count); - if (!silent) printf("- Test mi_records_in_range()\n"); create_record1(record, nrecords*4/5); print_record(record,0,"\n"); - hrows=mi_records_in_range(file,0,record+1,0,HA_READ_MBR_INTERSECT,record+1,0,0); + + range.key= record+1; + range.length= 1000; /* Big enough */ + range.flag= HA_READ_MBR_INTERSECT; + hrows= mi_records_in_range(file,0, &range, (key_range*) 0); printf(" %ld rows\n", (long) hrows); - if (mi_close(file)) goto err; my_end(MY_CHECK_ERROR); @@ -325,11 +304,11 @@ static int read_with_pos (MI_INFO * file,int silent) my_errno=0; bzero((char*) read_record,MAX_REC_LENGTH); error=mi_rrnd(file,read_record,i == 0 ? 0L : HA_OFFSET_ERROR); - if(error) + if (error) { - if(error==HA_ERR_END_OF_FILE) + if (error==HA_ERR_END_OF_FILE) break; - if(error==HA_ERR_RECORD_DELETED) + if (error==HA_ERR_RECORD_DELETED) continue; printf("pos: %2d mi_rrnd: %3d errno: %3d\n",i,error,my_errno); return error; |