YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
/* Test av isam-databas: stor test */
#include"heapdef.h"/* Because of hp_find_block */ #include"my_compare.h" #include <signal.h>
if (dupp_keys > 3)
{ if (!silent)
printf("- Read first key - next - delete - next -> last\n");
DBUG_PRINT("progpos",("first - next - delete - next -> last"));
if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) goto err; if (heap_rnext(file,record3)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) record+keyinfo[2].seg[0].start)]=0;
opt_delete++;
ant=2; while ((error=heap_rnext(file,record3)) == 0 ||
error == HA_ERR_RECORD_DELETED) if (! error)
ant++; if (ant != dupp_keys)
{
printf("next: I can only find: %d records of %d\n",
ant,dupp_keys); goto end;
}
dupp_keys--; if (heap_check_heap(file,0))
{
puts("Heap keys crashed"); goto err;
}
if (!silent)
printf("- Read last key - delete - prev - prev - opt_delete - prev -> first\n");
if (heap_rprev(file,record)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) record+keyinfo[2].seg[0].start)]=0;
opt_delete++; if (heap_rprev(file,record3) || heap_rprev(file,record3)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) record+keyinfo[2].seg[0].start)]=0;
opt_delete++;
ant=3; while ((error=heap_rprev(file,record3)) == 0 ||
error == HA_ERR_RECORD_DELETED)
{ if (! error)
ant++;
} if (ant != dupp_keys)
{
printf("next: I can only find: %d records of %d\n",
ant,dupp_keys); goto end;
}
dupp_keys-=2; if (heap_check_heap(file,0))
{
puts("Heap keys crashed"); goto err;
}
} else
puts("Warning: Not enough duplicated keys: Skipping delete key check");
if (!silent)
printf("- Read (first) - next - delete - next -> last\n");
DBUG_PRINT("progpos",("first - next - delete - next -> last"));
if (heap_scan_init(file)) goto err; while ((error=heap_scan(file,record3) == HA_ERR_RECORD_DELETED)) ; if (error) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi((char*) record3);
opt_delete++;
key1[atoi((char*) record+keyinfo[0].seg[0].start)]--;
key3[atoi((char*) record+keyinfo[2].seg[0].start)]=0;
ant=0; while ((error=heap_scan(file,record3)) == 0 ||
error == HA_ERR_RECORD_DELETED) if (! error)
ant++; if (ant != write_count-opt_delete)
{
printf("next: Found: %d records of %d\n",ant,write_count-opt_delete); goto end;
} if (heap_check_heap(file,0))
{
puts("Heap keys crashed"); goto err;
}
puts("- Test if: Read rrnd - same - rkey - same");
DBUG_PRINT("progpos",("Read rrnd - same"));
pos=rnd(write_count-opt_delete-5)+5;
heap_scan_init(file);
i=5; while ((error=heap_scan(file,record)) == HA_ERR_RECORD_DELETED ||
(error == 0 && pos))
{ if (!error)
pos--; if (i-- == 0)
{
bmove(record3,record,reclength);
position=heap_position(file);
}
} if (error) goto err;
bmove(record2,record,reclength); if (heap_rsame(file,record,-1) || heap_rsame(file,record2,2)) goto err; if (memcmp(record2,record,reclength))
{
puts("heap_rsame didn't find right record"); goto end;
}
puts("- Test of read through position"); if (heap_rrnd(file,record,position)) goto err; if (memcmp(record3,record,reclength))
{
puts("heap_frnd didn't find right record"); goto end;
}
printf("- heap_info\n");
{
HEAPINFO info;
heap_info(file,&info,0); /* We have to test with opt_delete +1 as this may be the case if the last
inserted row was a duplicate key */ if (info.records != write_count-opt_delete ||
(info.deleted != opt_delete && info.deleted != opt_delete+1))
{
puts("Wrong info from heap_info");
printf("Got: records: %ld(%d) deleted: %ld(%d)\n",
info.records,write_count-opt_delete,info.deleted,opt_delete);
}
}
printf("- Read through all records with scan\n"); if (heap_reset(file) || heap_extra(file,HA_EXTRA_CACHE))
{
puts("got error from heap_extra"); goto end;
}
ant=check2=0;
heap_scan_init(file); while ((error=heap_scan(file,record)) != HA_ERR_END_OF_FILE &&
ant < write_count + 10)
{ if (!error)
{
ant++;
check2+=calc_check(record,reclength);
}
} if (ant != write_count-opt_delete)
{
printf("scan: I can only find: %d records of %d\n", ant,
write_count-opt_delete); goto end;
}
if (heap_extra(file,HA_EXTRA_NO_CACHE))
{
puts("got error from heap_extra(HA_EXTRA_NO_CACHE)"); goto end;
}
for (i=999, dupp_keys=found_key=0 ; i>0 ; i--)
{ if (key1[i] > dupp_keys) { dupp_keys=key1[i]; found_key=i; }
snprintf((char*) key, sizeof(key), "%6d",found_key);
}
printf("- Read through all keys with first-next-last-prev\n");
ant=0; for (error=heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT);
! error ;
error=heap_rnext(file,record))
ant++; if (ant != dupp_keys)
{
printf("first-next: I can only find: %d records of %d\n", ant,
dupp_keys); goto end;
}
ant=0; for (error=heap_rprev(file,record) ;
! error ;
error=heap_rprev(file,record))
{
ant++;
check2+=calc_check(record,reclength);
} if (ant != dupp_keys)
{
printf("last-prev: I can only find: %d records of %d\n", ant,
dupp_keys); goto end;
}
if (testflag == 4) goto end;
printf("- Reading through all rows through keys\n"); if (!(file2=heap_open(filename, 2))) goto err; if (heap_scan_init(file)) goto err; while ((error=heap_scan(file,record)) != HA_ERR_END_OF_FILE)
{ if (error == 0)
{ if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,
HA_READ_KEY_EXACT))
{
printf("can't find key3: \"%.8s\"\n",
record+keyinfo[2].seg[0].start); goto err;
}
}
}
heap_close(file2);
printf("- Copying and removing records\n"); if (heap_scan_init(file)) goto err; while ((error=heap_scan(file,record)) != HA_ERR_END_OF_FILE)
{ if (error == 0)
{ if (heap_write(file2,record)) goto err;
key_check-=atoi((char*) record);
write_count++; if (heap_delete(file,record)) goto err;
opt_delete++;
}
pos++;
}
printf("- Checking heap tables\n"); if (heap_check_heap(file,1) || heap_check_heap(file2,1))
{
puts("Heap keys crashed"); goto err;
}
if (my_errno != HA_ERR_END_OF_FILE)
printf("error: %d from heap_rrnd\n",my_errno); if (key_check)
printf("error: Some read got wrong: check is %ld\n",(long) key_check);
end:
printf("\nFollowing test have been made:\n");
printf("Write records: %d\nUpdate records: %d\nDelete records: %d\n", write_count,update,opt_delete);
heap_clear(file); if (heap_close(file) || (file2 && heap_close(file2))) goto err;
heap_delete_table(filename2);
hp_panic(HA_PANIC_CLOSE);
my_end(MY_GIVE_INFO); return(0);
err:
printf("Got error: %d when using heap-database\n",my_errno);
(void) heap_close(file); return(1);
} /* main */
staticint calc_check(uchar *buf, uint length)
{ int check=0; while (length--)
check+= (int) (uchar) *(buf++); return check;
}
staticvoid make_record(uchar *record, uint n1, uint n2, uint n3, constchar *mark, uint count)
{
bfill(record,reclength,' ');
snprintf((char*) record, reclength, "%6d:%4d:%8d:%3.3s: %4d",
n1,n2,n3,mark,count);
record[37]='A'; /* Store A in null key */
record[38]=1; /* set as null */
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.2Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.