MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
system_variables_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef COMPONENTS_SERVICES_BITS_SYSTEM_VARIABLES_BITS_H
25#define COMPONENTS_SERVICES_BITS_SYSTEM_VARIABLES_BITS_H
26
28
29/**
30 @addtogroup group_components_services_sys_var_service_types Variable types
31
32 Possible system variable types. Use at most one of these.
33
34 @sa mysql_service_component_sys_variable_register service.
35
36 @{
37*/
38
39/** bool variable. Use @ref BOOL_CHECK_ARG */
40#define PLUGIN_VAR_BOOL 0x0001
41/** int variable. Use @ref INTEGRAL_CHECK_ARG */
42#define PLUGIN_VAR_INT 0x0002
43/** long variable Use @ref INTEGRAL_CHECK_ARG */
44#define PLUGIN_VAR_LONG 0x0003
45/** longlong variable. Use @ref INTEGRAL_CHECK_ARG */
46#define PLUGIN_VAR_LONGLONG 0x0004
47/** char * variable. Use @ref STR_CHECK_ARG */
48#define PLUGIN_VAR_STR 0x0005
49/** Enum variable. Use @ref ENUM_CHECK_ARG */
50#define PLUGIN_VAR_ENUM 0x0006
51/** A set variable. Use @ref ENUM_CHECK_ARG */
52#define PLUGIN_VAR_SET 0x0007
53/** double variable. Use @ref INTEGRAL_CHECK_ARG */
54#define PLUGIN_VAR_DOUBLE 0x0008
55/** @} */
56/**
57 @addtogroup group_components_services_sys_var_service_flags Variable flags
58
59 Flags to specify the behavior of system variables. Use multiple as needed.
60
61 @sa mysql_service_component_sys_variable_register service.
62
63 @{
64*/
65#define PLUGIN_VAR_UNSIGNED 0x0080 /**< The variable is unsigned */
66#define PLUGIN_VAR_THDLOCAL 0x0100 /**< Variable is per-connection */
67#define PLUGIN_VAR_READONLY 0x0200 /**< Server variable is read only */
68#define PLUGIN_VAR_NOSYSVAR 0x0400 /**< Not a server variable */
69#define PLUGIN_VAR_NOCMDOPT 0x0800 /**< Not a command line option */
70#define PLUGIN_VAR_NOCMDARG 0x1000 /**< No argument for cmd line */
71#define PLUGIN_VAR_RQCMDARG 0x0000 /**< Argument required for cmd line */
72#define PLUGIN_VAR_OPCMDARG 0x2000 /**< Argument optional for cmd line */
73#define PLUGIN_VAR_NODEFAULT 0x4000 /**< SET DEFAULT is prohibited */
74#define PLUGIN_VAR_MEMALLOC 0x8000 /**< String needs memory allocated */
75#define PLUGIN_VAR_NOPERSIST \
76 0x10000 /**< SET PERSIST_ONLY is prohibited for read only variables */
77#define PLUGIN_VAR_PERSIST_AS_READ_ONLY 0x20000
78#define PLUGIN_VAR_INVISIBLE 0x40000 /**< Variable should not be shown */
79#define PLUGIN_VAR_SENSITIVE 0x80000 /**< Sensitive variable */
80/** @} */
81
82/**
83 st_mysql_value struct for reading values from mysqld.
84 Used by server variables framework to parse user-provided values.
85 Will be used for arguments when implementing UDFs.
86
87 Note that val_str() returns a string in temporary memory
88 that will be freed at the end of statement. Copy the string
89 if you need it to persist.
90*/
91
92#define MYSQL_VALUE_TYPE_STRING 0
93#define MYSQL_VALUE_TYPE_REAL 1
94#define MYSQL_VALUE_TYPE_INT 2
95
97 int (*value_type)(struct st_mysql_value *);
98 const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
99 int (*val_real)(struct st_mysql_value *, double *realbuf);
100 int (*val_int)(struct st_mysql_value *, long long *intbuf);
101 int (*is_unsigned)(struct st_mysql_value *);
102};
103
104struct SYS_VAR;
105
106/*
107 SYNOPSIS
108 (*mysql_var_check_func)()
109 thd thread handle
110 var dynamic variable being altered
111 save pointer to temporary storage
112 value user provided value
113 RETURN
114 0 user provided value is OK and the update func may be called.
115 any other value indicates error.
116
117 This function should parse the user provided value and store in the
118 provided temporary storage any data as required by the update func.
119 There is sufficient space in the temporary storage to store a double.
120 Note that the update func may not be called if any other error occurs
121 so any memory allocated should be thread-local so that it may be freed
122 automatically at the end of the statement.
123*/
124
125typedef int (*mysql_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save,
126 struct st_mysql_value *value);
127
128/*
129 SYNOPSIS
130 (*mysql_var_update_func)()
131 thd thread handle
132 var dynamic variable being altered
133 var_ptr pointer to dynamic variable
134 save pointer to temporary storage
135 RETURN
136 NONE
137
138 This function should use the validated value stored in the temporary store
139 and persist it in the provided pointer to the dynamic variable.
140 For example, strings may require memory to be allocated.
141*/
142typedef void (*mysql_var_update_func)(MYSQL_THD thd, SYS_VAR *var,
143 void *var_ptr, const void *save);
144
145#define MYSQL_PLUGIN_VAR_HEADER \
146 int flags; \
147 const char *name; \
148 const char *comment; \
149 mysql_var_check_func check; \
150 mysql_var_update_func update
151
152// Definition of system vars structure for access their information
153struct SYS_VAR {
155};
156
157#endif /* COMPONENTS_SERVICES_BITS_SYSTEM_VARIABLES_BITS_H */
#define MYSQL_THD
Definition: backup_page_tracker.h:38
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Definition: system_variables_bits.h:153
MYSQL_PLUGIN_VAR_HEADER
Definition: system_variables_bits.h:154
Definition: system_variables_bits.h:96
int(* val_int)(struct st_mysql_value *, long long *intbuf)
Definition: system_variables_bits.h:100
int(* val_real)(struct st_mysql_value *, double *realbuf)
Definition: system_variables_bits.h:99
int(* is_unsigned)(struct st_mysql_value *)
Definition: system_variables_bits.h:101
int(* value_type)(struct st_mysql_value *)
Definition: system_variables_bits.h:97
int(* mysql_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)
Definition: system_variables_bits.h:125
void(* mysql_var_update_func)(MYSQL_THD thd, SYS_VAR *var, void *var_ptr, const void *save)
Definition: system_variables_bits.h:142