![]()  | 
  
    MySQL 8.0.44
    
   Source Code Documentation 
   | 
 
Our own string classes, used pervasively throughout the executor. More...
#include <assert.h>#include <stdint.h>#include <string.h>#include <sys/types.h>#include <new>#include <string>#include <string_view>#include "lex_string.h"#include "m_ctype.h"#include "m_string.h"#include "memory_debugging.h"#include "my_alloc.h"#include "my_compiler.h"#include "my_sys.h"#include "my_inttypes.h"#include "mysql/components/services/bits/psi_bits.h"#include "mysql/mysql_lex_string.h"#include "mysql/psi/psi_memory.h"#include "mysql/service_mysql_alloc.h"Go to the source code of this file.
Classes | |
| class | Simple_cstring | 
| A wrapper class for null-terminated constant strings.  More... | |
| class | String | 
| Using this class is fraught with peril, and you need to be very careful when doing so.  More... | |
| class | StringBuffer< buff_sz > | 
| String class wrapper with a preallocated buffer of size buff_sz.  More... | |
Macros | |
| #define | STRING_PSI_MEMORY_KEY key_memory_String_value | 
Functions | |
| 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... | |
| int | sortcmp (const String *a, const String *b, const CHARSET_INFO *cs) | 
| 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 | copy_and_convert (char *to, size_t to_length, const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs, uint *errors) | 
| 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=0) | 
| 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... | |
| static void | swap (String &a, String &b) noexcept | 
| static std::string | to_string (const String &str) | 
| static bool | check_if_only_end_space (const CHARSET_INFO *cs, const char *str, const char *end) | 
| LEX_CSTRING | to_lex_cstring (const LEX_STRING &s) | 
| LEX_STRING | to_lex_string (const LEX_CSTRING &s) | 
| LEX_CSTRING | to_lex_cstring (const char *s) | 
| 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 | 
Our own string classes, used pervasively throughout the executor.
See in particular the comment on String before you use anything from here.
| #define STRING_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 | 
      
  | 
  inlinestatic | 
| 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) | 
      
  | 
  inline | 
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. | 
| int sortcmp | ( | const String * | a, | 
| const String * | b, | ||
| const CHARSET_INFO * | cs | ||
| ) | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inlinestatic | 
| 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 input is invalid. | 
| 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 | ||
| ) | 
      
  | 
  extern |