summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authormonty@mysql.com/nosik.monty.fi <>2006-11-21 22:32:58 +0200
committermonty@mysql.com/nosik.monty.fi <>2006-11-21 22:32:58 +0200
commitf6682e2743d6b3cff53a6e6b1499b28f10fb3b92 (patch)
tree7976fdc96a4eb6af989b3c9caa89d1e2cb5729d5 /sql/key.cc
parent959e90676848a34ee7b6d66653a1d66c8a351c13 (diff)
downloadmariadb-git-f6682e2743d6b3cff53a6e6b1499b28f10fb3b92.tar.gz
Added --debug-info to most clients to detect memory leaks in mysql-test-run
Moved .progress files into the log directory Moved 'cluster' database tables into the MySQL database, to not have 'cluster' beeing a reserved database name Fixed bug where mysqld got a core dump when trying to use a table created by MySQL 3.23 Fixed some compiler warnings Fixed small memory leak in libmysql Note that this doesn't changeset doesn't include the new mysqldump.c code required to run some tests. This will be added when I merge 5.0 to 5.1
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc51
1 files changed, 34 insertions, 17 deletions
diff --git a/sql/key.cc b/sql/key.cc
index be21bf11c3c..dceeab1c011 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -19,37 +19,54 @@
#include "mysql_priv.h"
- /*
- ** Search after with key field is. If no key starts with field test
- ** if field is part of some key.
- **
- ** returns number of key. keylength is set to length of key before
- ** (not including) field
- ** Used when calculating key for NEXT_NUMBER
- */
-
-int find_ref_key(KEY *key, uint key_count, Field *field, uint *key_length)
+/*
+ Search after a key that starts with 'field'
+
+ SYNOPSIS
+ find_ref_key()
+ key First key to check
+ key_count How many keys to check
+ record Start of record
+ field Field to search after
+ key_length On partial match, contains length of fields before
+ field
+
+ NOTES
+ Used when calculating key for NEXT_NUMBER
+
+ IMPLEMENTATION
+ If no key starts with field test if field is part of some key. If we find
+ one, then return first key and set key_length to the number of bytes
+ preceding 'field'.
+
+ RETURN
+ -1 field is not part of the key
+ # Key part for key matching key.
+ key_length is set to length of key before (not including) field
+*/
+
+int find_ref_key(KEY *key, uint key_count, byte *record, Field *field,
+ uint *key_length)
{
reg2 int i;
reg3 KEY *key_info;
uint fieldpos;
- fieldpos= field->offset();
-
- /* Test if some key starts as fieldpos */
+ fieldpos= field->offset(record);
+ /* Test if some key starts as fieldpos */
for (i= 0, key_info= key ;
i < (int) key_count ;
i++, key_info++)
{
if (key_info->key_part[0].offset == fieldpos)
- { /* Found key. Calc keylength */
+ { /* Found key. Calc keylength */
*key_length=0;
- return(i); /* Use this key */
+ return(i); /* Use this key */
}
}
- /* Test if some key contains fieldpos */
+ /* Test if some key contains fieldpos */
for (i= 0, key_info= key;
i < (int) key_count ;
i++, key_info++)
@@ -62,7 +79,7 @@ int find_ref_key(KEY *key, uint key_count, Field *field, uint *key_length)
j++, key_part++)
{
if (key_part->offset == fieldpos)
- return(i); /* Use this key */
+ return(i); /* Use this key */
*key_length+=key_part->store_length;
}
}