summaryrefslogtreecommitdiff
path: root/heap
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-12-29 16:06:10 +0200
committerunknown <monty@donna.mysql.com>2000-12-29 16:06:10 +0200
commit29fa72526a22c31a79c73a00bf7b1974c44ff9d2 (patch)
tree53ef6da34dcfaf79e0e133177cccfb9bb63a9637 /heap
parentccf4b2829882f566d5665e4ddf7eabcd6d197872 (diff)
downloadmariadb-git-29fa72526a22c31a79c73a00bf7b1974c44ff9d2.tar.gz
Fixed --no-defaults in mysqltest
BUILD/compile-pentium-debug: Use /usr/local/BerkeleyDB-dbug/ if available BUILD/compile-pentium: Use /usr/local/BerkeleyDB-opt/ if available Docs/internals.texi: Added 'unedited' documentation for mysys functions Docs/manual.texi: Cleanups client/mysql.cc: Added client language to status client/mysqltest.c: Fixed bug with --no-defaults heap/_check.c: Added option to print status. heap/hp_close.c: Update to use new status interface heap/hp_hash.c: Clean up hash function and add new experimental hash heap/hp_test1.c: Update to use new status interface heap/hp_test2.c: Update to use new status interface include/heap.h: Update to use new status interface mysql-test/r/key_diff.result: Cleanup tests that may give rows in random order mysql-test/r/type_blob.result: Removed \r from output as this confused bk mysql-test/t/key_diff.test: Cleanup tests that may give rows in random order BitKeeper/etc/ignore: Added Docs/my_sys.doc to the ignore list mysql-test/t/type_blob.test: Removed \r from output as this confused bk mysys/hash.c: Add new experimental hash function scripts/safe_mysqld.sh: Added --mysqld option sql/ha_innobase.cc: Fixed store_locking sql/mysqld.cc: Cleaned up warning messages
Diffstat (limited to 'heap')
-rw-r--r--heap/_check.c16
-rw-r--r--heap/hp_close.c2
-rw-r--r--heap/hp_hash.c93
-rw-r--r--heap/hp_test1.c4
-rw-r--r--heap/hp_test2.c21
5 files changed, 112 insertions, 24 deletions
diff --git a/heap/_check.c b/heap/_check.c
index 77fa0262732..e22eb5e7e4a 100644
--- a/heap/_check.c
+++ b/heap/_check.c
@@ -18,11 +18,12 @@
#include "heapdef.h"
-static int check_one_key(HP_KEYDEF *keydef,ulong records,ulong blength);
+static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
+ ulong blength, my_bool print_status);
/* Returns 0 if the HEAP is ok */
-int heap_check_heap(HP_INFO *info)
+int heap_check_heap(HP_INFO *info,my_bool print_status)
{
int error;
uint key;
@@ -30,13 +31,15 @@ int heap_check_heap(HP_INFO *info)
DBUG_ENTER("heap_check_keys");
for (error=key=0 ; key < share->keys ; key++)
- error|=check_one_key(share->keydef+key,share->records,share->blength);
+ error|=check_one_key(share->keydef+key,key, share->records,share->blength,
+ print_status);
DBUG_RETURN(error);
}
-static int check_one_key(HP_KEYDEF *keydef, ulong records, ulong blength)
+static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records,
+ ulong blength, my_bool print_status)
{
int error;
uint i,found,max_links,seek,links;
@@ -76,6 +79,9 @@ static int check_one_key(HP_KEYDEF *keydef, ulong records, ulong blength)
}
DBUG_PRINT("info",
("records: %ld seeks: %d max links: %d hitrate: %.2f",
- records,seek,max_links,(float) seek / (float) records));
+ records,seek,max_links,(float) seek / (float) (records ? records : 1)));
+ if (print_status)
+ printf("Key: %d records: %ld seeks: %d max links: %d hitrate: %.2f\n",
+ keynr, records, seek, max_links, (float) seek / (float) records);
return error;
}
diff --git a/heap/hp_close.c b/heap/hp_close.c
index b1797d2e92f..583602e98cb 100644
--- a/heap/hp_close.c
+++ b/heap/hp_close.c
@@ -37,7 +37,7 @@ int _hp_close(register HP_INFO *info)
int error=0;
DBUG_ENTER("_hp_close");
#ifndef DBUG_OFF
- if (info->s->changed && heap_check_heap(info))
+ if (info->s->changed && heap_check_heap(info,0))
{
error=my_errno=HA_ERR_CRASHED;
}
diff --git a/heap/hp_hash.c b/heap/hp_hash.c
index 28647ab7c94..eb35b947871 100644
--- a/heap/hp_hash.c
+++ b/heap/hp_hash.c
@@ -145,6 +145,7 @@ void _hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink)
return;
}
+#ifndef NEW_HASH_FUNCTION
/* Calc hashvalue for a key */
@@ -152,13 +153,14 @@ ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
{
register ulong nr=1, nr2=4;
HP_KEYSEG *seg,*endseg;
- uchar *pos;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
{
+ uchar *pos=(uchar*) key;
+ key+=seg->length;
if (seg->type == HA_KEYTYPE_TEXT)
{
- for (pos=(uchar*) key,key+=seg->length ; pos < (uchar*) key ; pos++)
+ for (; pos < (uchar*) key ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) my_sort_order[(uint) *pos]))+ (nr << 8);
nr2+=3;
@@ -166,7 +168,7 @@ ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
}
else
{
- for (pos=(uchar*) key,key+=seg->length ; pos < (uchar*) key ; pos++)
+ for (; pos < (uchar*) key ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos))+ (nr << 8);
nr2+=3;
@@ -182,13 +184,13 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
{
register ulong nr=1, nr2=4;
HP_KEYSEG *seg,*endseg;
- uchar *pos,*end;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
{
+ uchar *pos=(uchar*) rec+seg->start,*end=pos+seg->length;
if (seg->type == HA_KEYTYPE_TEXT)
{
- for (pos=(uchar*) rec+seg->start,end=pos+seg->length ; pos < end ; pos++)
+ for (; pos < end ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) my_sort_order[(uint) *pos]))+ (nr << 8);
nr2+=3;
@@ -196,7 +198,7 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
}
else
{
- for (pos=(uchar*) rec+seg->start,end=pos+seg->length ; pos < end ; pos++)
+ for (; pos < end ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos))+ (nr << 8);
nr2+=3;
@@ -206,6 +208,85 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
return((ulong) nr);
}
+#else
+
+/*
+ * Fowler/Noll/Vo hash
+ *
+ * The basis of the hash algorithm was taken from an idea sent by email to the
+ * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
+ * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
+ * later improved on their algorithm.
+ *
+ * The magic is in the interesting relationship between the special prime
+ * 16777619 (2^24 + 403) and 2^32 and 2^8.
+ *
+ * This hash produces the fewest collisions of any function that we've seen so
+ * far, and works well on both numbers and strings.
+ */
+
+ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
+{
+ register ulong nr=0;
+ HP_KEYSEG *seg,*endseg;
+
+ for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
+ {
+ uchar *pos=(uchar*) key;
+ key+=seg->length;
+ if (seg->type == HA_KEYTYPE_TEXT)
+ {
+ for (; pos < (uchar*) key ; pos++)
+ {
+ nr *=16777619;
+ nr ^=((uint) my_sort_order[(uint) *pos]);
+ }
+ }
+ else
+ {
+ for ( ; pos < (uchar*) key ; pos++)
+ {
+ nr *=16777619;
+ nr ^=(uint) *pos;
+ }
+ }
+ }
+ return((ulong) nr);
+}
+
+ /* Calc hashvalue for a key in a record */
+
+ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
+{
+ register ulong nr=0;
+ HP_KEYSEG *seg,*endseg;
+
+ for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
+ {
+ uchar *pos=(uchar*) rec+seg->start,*end=pos+seg->length;
+ if (seg->type == HA_KEYTYPE_TEXT)
+ {
+ for ( ; pos < end ; pos++)
+ {
+ nr *=16777619;
+ nr ^=(uint) my_sort_order[(uint) *pos];
+ }
+ }
+ else
+ {
+ for ( ; pos < end ; pos++)
+ {
+ nr *=16777619;
+ nr ^=(uint) *pos;
+ }
+ }
+ }
+ return((ulong) nr);
+}
+
+#endif
+
+
/* Compare keys for two records. Returns 0 if they are identical */
int _hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2)
diff --git a/heap/hp_test1.c b/heap/hp_test1.c
index 848157e831b..f44752af3bc 100644
--- a/heap/hp_test1.c
+++ b/heap/hp_test1.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
sprintf(key,"%6d",j);
bmove(record+1,key,6);
error=heap_write(file,record);
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -100,7 +100,7 @@ int main(int argc, char **argv)
if (! error)
deleted++;
}
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
diff --git a/heap/hp_test2.c b/heap/hp_test2.c
index bfb30e59622..e3ed7a90df5 100644
--- a/heap/hp_test2.c
+++ b/heap/hp_test2.c
@@ -133,7 +133,7 @@ char *argv[];
write_count++; key1[n1]++; key3[n3]=1;
key_check+=n1;
}
- if (testflag == 1 && heap_check_heap(file))
+ if (testflag == 1 && heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -141,7 +141,7 @@ char *argv[];
}
if (testflag == 1)
goto end;
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -173,7 +173,7 @@ char *argv[];
key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0;
key_check-=atoi(record);
- if (testflag == 2 && heap_check_heap(file))
+ if (testflag == 2 && heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -183,7 +183,7 @@ char *argv[];
puts("Warning: Skipping delete test because no dupplicate keys");
}
if (testflag==2) goto end;
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -239,14 +239,14 @@ char *argv[];
update++;
key_check=key_check-atoi(record)+n1;
}
- if (testflag == 3 && heap_check_heap(file))
+ if (testflag == 3 && heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
}
}
if (testflag == 3) goto end;
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -284,7 +284,7 @@ char *argv[];
goto end;
}
dupp_keys--;
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -320,7 +320,7 @@ char *argv[];
goto end;
}
dupp_keys-=2;
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -353,7 +353,7 @@ char *argv[];
printf("next: Found: %d records of %d\n",ant,write_count-delete);
goto end;
}
- if (heap_check_heap(file))
+ if (heap_check_heap(file,0))
{
puts("Heap keys crashed");
goto err;
@@ -556,7 +556,8 @@ char *argv[];
}
pos++;
}
- if (heap_check_heap(file) || heap_check_heap(file2))
+ printf("- Checking heap tables\n");
+ if (heap_check_heap(file,1) || heap_check_heap(file2,1))
{
puts("Heap keys crashed");
goto err;