diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index 1ce49b0bdfa..62dafd55b57 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1029,6 +1029,61 @@ void Field::make_sort_key(uchar *buff,uint length) } +/* + @brief + Create a packed sort key + + @param buff buffer where values are written + @param sort_field sort column structure + + @retval + length of the bytes written, does not include the NULL bytes +*/ +uint +Field::make_packed_sort_key(uchar *buff, const SORT_FIELD_ATTR *sort_field) +{ + if (maybe_null()) + { + if (is_null()) + { + *buff++= 0; + return 0; // For NULL values don't write any data + } + *buff++=1; + } + sort_string(buff, sort_field->original_length); + return sort_field->original_length; +} + + +uint +Field_longstr::make_packed_sort_key(uchar *buff, + const SORT_FIELD_ATTR *sort_field) +{ + if (maybe_null()) + { + if (is_null()) + { + *buff++= 0; + return 0; // For NULL values don't write any data + } + *buff++=1; + } + uchar *end= pack_sort_string(buff, sort_field); + return static_cast<int>(end-buff); +} + + +uchar* +Field_longstr::pack_sort_string(uchar *to, const SORT_FIELD_ATTR *sort_field) +{ + String buf; + val_str(&buf, &buf); + return to + sort_field->pack_sort_string(to, buf.lex_cstring(), + field_charset()); +} + + /** @brief Determine the relative position of the field value in a numeric interval @@ -8531,6 +8586,12 @@ uint32 Field_blob::sort_length() const } +uint32 Field_blob::sort_suffix_length() const +{ + return field_charset() == &my_charset_bin ? packlength : 0; +} + + void Field_blob::sort_string(uchar *to,uint length) { String buf; |