diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-03-10 18:12:11 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-03-10 19:22:22 +0530 |
commit | 00749980acf617fbc26b5cdaff6e256a673dab76 (patch) | |
tree | f474b10cb8787fe6d61263092cb560d280ab0c65 /sql | |
parent | 9ae015878f11be3e3033fd1b35357ea5927c6c51 (diff) | |
download | mariadb-git-00749980acf617fbc26b5cdaff6e256a673dab76.tar.gz |
Fixing a compilation failure on windows
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 56f060b8c26..73b50a30a2a 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -67,6 +67,31 @@ static Addon_fields *get_addon_fields(TABLE *table, uint sortlength, static bool check_if_pq_applicable(Sort_param *param, SORT_INFO *info, TABLE *table, ha_rows records, size_t memory_available); + +static void store_key_part_length(uint32 num, uchar *to, uint bytes) +{ + switch(bytes) { + case 1: *to= (uchar)num; break; + case 2: int2store(to, num); break; + case 3: int3store(to, num); break; + case 4: int4store(to, num); break; + default: DBUG_ASSERT(0); + } +} + + +static uint32 read_keypart_length(const uchar *from, uint bytes) +{ + switch(bytes) { + case 1: return from[0]; + case 2: return uint2korr(from); + case 3: return uint3korr(from); + case 4: return uint4korr(from); + default: DBUG_ASSERT(0); return 0; + } +} + + // @param sortlen [Maximum] length of the sort key void Sort_param::init_for_filesort(uint sortlen, TABLE *table, ha_rows maxrows, bool sort_positions) @@ -2773,8 +2798,8 @@ int SORT_FIELD_ATTR::compare_packed_varstrings(uchar *a, size_t *a_len, else *a_len= *b_len= 0; - a_length= read_lowendian(a, length_bytes); - b_length= read_lowendian(b, length_bytes); + a_length= read_keypart_length(a, length_bytes); + b_length= read_keypart_length(b, length_bytes); *a_len+= length_bytes + a_length; *b_len+= length_bytes + b_length; @@ -2921,7 +2946,7 @@ SORT_FIELD_ATTR::pack_sort_string(uchar *to, const LEX_CSTRING &str, data_length= original_length - suffix_length; // length stored in lowendian form - store_lowendian(data_length + suffix_length, to, length_bytes); + store_key_part_length(data_length + suffix_length, to, length_bytes); to+= length_bytes; // copying data length bytes to the buffer memcpy(to, (uchar*)str.str, data_length); |