summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2010-12-21 14:40:23 +0300
committerSergey Petrunya <psergey@askmonty.org>2010-12-21 14:40:23 +0300
commit33e40f7d5bdffd1b394e122095a477893110e105 (patch)
treed2a1caea871ef8dcbe0b0333d01a2b1d8da11714 /sql/key.cc
parent4f28dcbe327139d9d5cb71afc9f4ce99cecec25a (diff)
parent9d480f6af36db8ba098441bd58bfd60e547c8cd2 (diff)
downloadmariadb-git-33e40f7d5bdffd1b394e122095a477893110e105.tar.gz
MWL#121-125 DS-MRR improvements
- Merge with 5.3-main
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/sql/key.cc b/sql/key.cc
index a1793e9e5f4..1d27fdcf208 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -567,3 +567,54 @@ 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++;
+ len--;
+ }
+ if ((res= part->field->key_cmp(key1, key2)))
+ return res;
+ }
+ return 0;
+}
+
+