MCPcopy Create free account
hub / github.com/MariaDB/server / natsort_encode_numeric_string

Function natsort_encode_numeric_string

sql/item_strfunc.cc:5716–5730  ·  view source on GitHub ↗

Encode numeric string for natural sorting. @param[in] in - start of the numeric string skipping leading zeros @param[in] n_digits - length of the string, in characters, not counting leading zeros. @param[out] out - String to write to. The string should have enough preallocated space to fit the encoded key. @return NATSORT_ERR::SUCCESS - success NATSORT_ERR::KEY_

Source from the content-addressed store, hash-verified

5714 CONCAT(natsort_encode_length(n_digits), in)
5715*/
5716static NATSORT_ERR natsort_encode_numeric_string(const char *in,
5717 size_t n_digits,
5718 String *out)
5719{
5720 DBUG_ASSERT(in);
5721 DBUG_ASSERT(n_digits);
5722
5723 if (out->length() + natsort_encode_length_max(n_digits - 1) + n_digits >
5724 out->alloced_length())
5725 return NATSORT_ERR::KEY_TOO_LARGE;
5726
5727 natsort_encode_length(n_digits - 1, out);
5728 out->append(in, n_digits);
5729 return NATSORT_ERR::SUCCESS;
5730}
5731
5732/*
5733 Calculate max size of the natsort key.

Callers 1

to_natsort_keyFunction · 0.85

Calls 5

natsort_encode_lengthFunction · 0.85
lengthMethod · 0.45
alloced_lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected