MySQL 8.4.2
Source Code Documentation
|
Functions to handle typelib. More...
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "m_string.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_sys.h"
#include "mysql/strings/m_ctype.h"
#include "template_utils.h"
#include "typelib.h"
Macros | |
#define | is_field_separator(X) ((X) == ',' || (X) == '=') |
Functions | |
int | find_type_or_exit (const char *x, TYPELIB *typelib, const char *option) |
int | find_type (const char *x, const TYPELIB *typelib, uint flags) |
Search after a string in a list of strings. More... | |
const char * | get_type (TYPELIB *typelib, uint nr) |
Get type. More... | |
uint64_t | find_typeset (const char *x, TYPELIB *lib, int *err) |
Create an integer value to represent the supplied comma-separated string where each string in the TYPELIB denotes a bit position. More... | |
TYPELIB * | copy_typelib (MEM_ROOT *root, TYPELIB *from) |
Create a copy of a specified TYPELIB structure. More... | |
static int | parse_name (const TYPELIB *lib, const char **strpos, const char *end) |
Parse a TYPELIB name from the buffer. More... | |
uint64_t | find_set_from_flags (const TYPELIB *lib, int default_name, uint64_t cur_set, uint64_t default_set, const char *str, uint length, const char **err_pos, uint *err_len) |
Parse and apply a set of flag assingments. More... | |
Variables | |
static const char * | on_off_default_names [] = {"off", "on", "default", nullptr} |
static TYPELIB | on_off_default_typelib |
Functions to handle typelib.
Create a copy of a specified TYPELIB structure.
root | pointer to a MEM_ROOT object for allocations |
from | pointer to a source TYPELIB structure |
pointer | to the new TYPELIB structure on successful copy |
NULL | otherwise |
uint64_t find_set_from_flags | ( | const TYPELIB * | lib, |
int | default_name, | ||
uint64_t | cur_set, | ||
uint64_t | default_set, | ||
const char * | str, | ||
uint | length, | ||
const char ** | err_pos, | ||
uint * | err_len | ||
) |
Parse and apply a set of flag assingments.
lib | Flag names |
default_name | Number of "default" in the typelib |
cur_set | Current set of flags (start from this state) |
default_set | Default set of flags (use this for assign-default keyword and flag=default assignments) |
str | String to be parsed |
length | Length of the string |
err_pos | OUT If error, set to point to start of wrong set string NULL on success |
err_len | OUT If error, set to the length of wrong set string |
Parse a set of flag assignments, that is, parse a string in form:
param_name1=value1,param_name2=value2,...
where the names are specified in the TYPELIB, and each value can be either 'on','off', or 'default'. Setting the same name twice is not allowed.
Besides param=val assignments, we support the "default" keyword (keyword default_name in the typelib). It can be used one time, if specified it causes us to build the new set over the default_set rather than cur_set value.
Parsed | set value if (*errpos == NULL), otherwise undefined |
int find_type | ( | const char * | x, |
const TYPELIB * | typelib, | ||
uint | flags | ||
) |
Search after a string in a list of strings.
Endspace in x is not compared.
x | String to find |
typelib | TYPELIB (struct of pointer to values + count) |
flags | flags to tune behaviour: a combination of FIND_TYPE_NO_PREFIX FIND_TYPE_ALLOW_NUMBER FIND_TYPE_COMMA_TERM. FIND_TYPE_NO_OVERWRITE can be passed but is redundant (is always implicitly on). |
-1 | Too many matching values |
0 | No matching value |
>0 | Offset+1 in typelib for matched string |
int find_type_or_exit | ( | const char * | x, |
TYPELIB * | typelib, | ||
const char * | option | ||
) |
uint64_t find_typeset | ( | const char * | x, |
TYPELIB * | lib, | ||
int * | err | ||
) |
Create an integer value to represent the supplied comma-separated string where each string in the TYPELIB denotes a bit position.
x | string to decompose |
lib | TYPELIB (struct of pointer to values + count) |
err | index (not char position) of string element which was not found or 0 if there was no error |
a | integer representation of the supplied string |
const char * get_type | ( | TYPELIB * | typelib, |
uint | nr | ||
) |
Get type.
|
static |
Parse a TYPELIB name from the buffer.
lib | Set of names to scan for. |
strpos | INOUT Start of the buffer (updated to point to the next character after the name) |
end | End of the buffer |
-1 | Too many matching values |
0 | No matching name |
>0 | Offset+1 in typelib for matched name |
|
static |
|
static |