diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2010-11-22 19:34:03 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2010-11-22 19:34:03 +0300 |
commit | a6c1d56e083bcb8ab2c32f8d89865ef46c0eb70e (patch) | |
tree | 11082d4ca44d40446621c6ea3c4db48c4b370306 /sql/key.cc | |
parent | 2ec43747f502c0a405793d30b3aa7b1b44ccc48e (diff) | |
download | mariadb-git-a6c1d56e083bcb8ab2c32f8d89865ef46c0eb70e.tar.gz |
MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 1
- Fix buildbot failure
Diffstat (limited to 'sql/key.cc')
-rw-r--r-- | sql/key.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sql/key.cc b/sql/key.cc index 89423e5280e..708f309fbaf 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -548,3 +548,53 @@ next_loop: } while (key_info); /* no more keys to test */ DBUG_RETURN(0); } + + +/* + Compare two key tuples. + + @brief + Compare two key tuples, i.e. two key values in KeyTupleFormat. + + @param part KEY_PART_INFO with key description + @param key1 First key to compare + @param key2 Second key to compare + @param tuple_length Length of key1 (and key2, they are the same) in bytes. + + @return + @retval 0 key1 == key2 + @retval -1 key1 < key2 + @retval +1 key1 > key2 +*/ + +int key_tuple_cmp(KEY_PART_INFO *part, uchar *key1, uchar *key2, + uint tuple_length) +{ + uchar *key1_end= key1 + tuple_length; + int len; + int res; + LINT_INIT(len); + for (;key1 < key1_end; key1 += len, key2 += len, part++) + { + len= part->store_length; + if (part->null_bit) + { + if (*key1) // key1 == NULL + { + if (!*key2) // key1(NULL) < key2(notNULL) + return -1; + continue; + } + else if (*key2) // key1(notNULL) > key2 (NULL) + return 1; + /* Step over the NULL bytes for key_cmp() call */ + key1++; + key2++; + } + if ((res= part->field->key_cmp(key1, key2))) + return res; + } + return 0; +} + + |