summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/key.cc b/sql/key.cc
index f2cebfe6d82..ef1af849391 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -573,6 +573,9 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec)
/* loop over every key part */
do
{
+ const int GREATER= key_part->key_part_flag & HA_REVERSE_SORT ? -1 : +1;
+ const int LESS= -GREATER;
+
field= key_part->field;
if (key_part->null_bit)
@@ -593,12 +596,12 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec)
; /* Fall through, no NULL fields */
else
{
- DBUG_RETURN(+1);
+ DBUG_RETURN(GREATER);
}
}
else if (!sec_is_null)
{
- DBUG_RETURN(-1);
+ DBUG_RETURN(LESS);
}
else
goto next_loop; /* Both were NULL */
@@ -612,7 +615,7 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec)
*/
if ((result= field->cmp_prefix(field->ptr+first_diff, field->ptr+sec_diff,
key_part->length)))
- DBUG_RETURN(result);
+ DBUG_RETURN(result * GREATER);
next_loop:
key_part++;
key_part_num++;