MySQL 8.4.2
Source Code Documentation
|
#include "sql_string.h"
#include "sql/sql_const.h"
#include <assert.h>
#include <algorithm>
#include <limits>
#include "dig_vec.h"
#include "my_macros.h"
#include "my_pointer_arithmetic.h"
#include "my_sys.h"
#include "mysql/strings/dtoa.h"
#include "mysql/strings/int2str.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "string_with_len.h"
#include "template_utils.h"
Functions | |
void | qs_append (const char *str_in, size_t len, String *str) |
void | qs_append (double d, size_t len, String *str) |
void | qs_append (int i, String *str) |
void | qs_append (uint i, String *str) |
int | sortcmp (const String *s, const String *t, const CHARSET_INFO *cs) |
int | stringcmp (const String *s, const String *t) |
String * | copy_if_not_alloced (String *to, String *from, size_t from_length) |
Makes a copy of a String's buffer unless it's already heap-allocated. More... | |
size_t | well_formed_copy_nchars (const CHARSET_INFO *to_cs, char *to, size_t to_length, const CHARSET_INFO *from_cs, const char *from, size_t from_length, size_t nchars, const char **well_formed_error_pos, const char **cannot_convert_error_pos, const char **from_end_pos) |
size_t | convert_to_printable (char *to, size_t to_len, const char *from, size_t from_len, const CHARSET_INFO *from_cs, size_t nbytes) |
Convert string to printable ASCII string. More... | |
size_t | bin_to_hex_str (char *to, size_t to_len, const char *from, size_t from_len) |
Convert a buffer to printable HEX encoded string For eg: ABCDEF1234. More... | |
bool | validate_string (const CHARSET_INFO *cs, const char *str, size_t length, size_t *valid_length, bool *length_error) |
Check if an input byte sequence is a valid character string of a given charset. More... | |
bool | append_escaped (String *to_str, const String *from_str) |
Appends from_str to to_str, escaping certain characters. More... | |
Variables | |
PSI_memory_key | key_memory_String_value |
Appends from_str to to_str, escaping certain characters.
[in,out] | to_str | The destination string. |
[in] | from_str | The source string. |
size_t bin_to_hex_str | ( | char * | to, |
size_t | to_len, | ||
const char * | from, | ||
size_t | from_len | ||
) |
Convert a buffer to printable HEX encoded string For eg: ABCDEF1234.
to | output buffer |
to_len | size of the output buffer (from_len*2 + 1 or greater) |
from | input buffer |
from_len | size of the input buffer |
size_t convert_to_printable | ( | char * | to, |
size_t | to_len, | ||
const char * | from, | ||
size_t | from_len, | ||
const CHARSET_INFO * | from_cs, | ||
size_t | nbytes | ||
) |
Convert string to printable ASCII string.
This function converts input string "from" replacing non-ASCII bytes with hexadecimal sequences ("\xXX") optionally appending "..." to the end of the resulting string. This function used in the ER_TRUNCATED_WRONG_VALUE_FOR_FIELD error messages, e.g. when a string cannot be converted to a result charset.
to | output buffer |
to_len | size of the output buffer (8 bytes or greater) |
from | input string |
from_len | size of the input string |
from_cs | input charset |
nbytes | maximal number of bytes to convert (from_len if 0) |
Makes a copy of a String's buffer unless it's already heap-allocated.
If the buffer ('str') of 'from' is on the heap, this function returns 'from', possibly re-allocated to be at least from_length bytes long. It is also the case if from==to or to==NULL. Otherwise, this function makes and returns a copy of "from" into "to"; the buffer of "to" is heap-allocated; a pre-condition is that from->str
and to->str
must point to non-overlapping buffers. The logic behind this complex design, is that a caller, typically a val_str() function, sometimes has an input String ('from') which buffer it wants to modify; but this String's buffer may or not be heap-allocated; if it's not heap-allocated it is possibly in static storage or belongs to an outer context, and thus should not be modified; in that case the caller wants a heap-allocated copy which it can freely modify.
to | destination string |
from | source string |
from_length | destination string will hold at least from_length bytes. |
void qs_append | ( | const char * | str_in, |
size_t | len, | ||
String * | str | ||
) |
void qs_append | ( | double | d, |
size_t | len, | ||
String * | str | ||
) |
void qs_append | ( | int | i, |
String * | str | ||
) |
void qs_append | ( | uint | i, |
String * | str | ||
) |
int sortcmp | ( | const String * | s, |
const String * | t, | ||
const CHARSET_INFO * | cs | ||
) |
bool validate_string | ( | const CHARSET_INFO * | cs, |
const char * | str, | ||
size_t | length, | ||
size_t * | valid_length, | ||
bool * | length_error | ||
) |
Check if an input byte sequence is a valid character string of a given charset.
cs | The input character set. | |
str | The input byte sequence to validate. | |
length | A byte length of the str. | |
[out] | valid_length | A byte length of a valid prefix of the str. |
[out] | length_error | True in the case of a character length error: some byte[s] in the input is not a valid prefix for a character, i.e. the byte length of that invalid character is undefined. |
true | if the whole input byte sequence is a valid character string. The length_error output parameter is undefined. |
size_t well_formed_copy_nchars | ( | const CHARSET_INFO * | to_cs, |
char * | to, | ||
size_t | to_length, | ||
const CHARSET_INFO * | from_cs, | ||
const char * | from, | ||
size_t | from_length, | ||
size_t | nchars, | ||
const char ** | well_formed_error_pos, | ||
const char ** | cannot_convert_error_pos, | ||
const char ** | from_end_pos | ||
) |
PSI_memory_key key_memory_String_value |