MySQL 9.4.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
sys_vars.h
Go to the documentation of this file.
1#ifndef SYS_VARS_H_INCLUDED
2#define SYS_VARS_H_INCLUDED
3/* Copyright (c) 2002, 2025, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @file
28 "private" interface to sys_var - server configuration variables.
29
30 This header is included only by the file that contains declarations
31 of sys_var variables (sys_vars.cc).
32*/
33
34#include "my_config.h"
35
36#include <sys/types.h>
37
38#include <bit>
39#include <cstddef>
40#include <cstdlib>
41#include <cstring>
42#include <ctime>
43#include <string>
44#include <string_view>
45
46#include "keycache.h" // dflt_key_cache
47#include "lex_string.h"
48#include "my_base.h"
49#include "my_compiler.h"
50#include "my_dbug.h"
51#include "my_getopt.h"
52#include "my_inttypes.h"
53#include "mysql/plugin.h"
55#include "mysql/status_var.h"
56#include "mysql/strings/dtoa.h"
60#include "mysqld_error.h"
62#include "sql/debug_sync.h" // debug_sync_update
63#include "sql/handler.h"
64#include "sql/item.h" // Item
65#include "sql/keycaches.h" // default_key_cache_base
66#include "sql/mysqld.h" // max_system_variables
67#include "sql/rpl_gtid.h"
68#include "sql/set_var.h" // sys_var_chain
69#include "sql/sql_class.h" // THD
70#include "sql/sql_connect.h"
71#include "sql/sql_const.h"
72#include "sql/sql_error.h"
73#include "sql/sql_plugin.h" // my_plugin_lock_by_name
74#include "sql/sql_plugin_ref.h"
75#include "sql/strfunc.h" // find_type
77#include "sql/sys_vars_shared.h" // throw_bounds_warning
78#include "sql/tztime.h" // Time_zone
79#include "sql_string.h"
80#include "typelib.h"
81
82class Sys_var_bit;
83class Sys_var_bool;
84class Sys_var_charptr;
85class Sys_var_double;
87class Sys_var_enum;
88class Sys_var_flagset;
90class Sys_var_have;
93class Sys_var_plugin;
94class Sys_var_set;
95class Sys_var_tz;
96struct CMD_LINE;
97struct System_variables;
98template <typename Struct_type, typename Name_getter>
99class Sys_var_struct;
100template <typename T, ulong ARGT, enum enum_mysql_show_type SHOWT, bool SIGNED>
101class Sys_var_integer;
102
103constexpr const unsigned long TABLE_OPEN_CACHE_DEFAULT{4000};
104constexpr const unsigned long TABLE_DEF_CACHE_DEFAULT{400};
105/**
106 Maximum number of connections default value.
107 151 is larger than Apache's default max children,
108 to avoid "too many connections" error in a common setup.
109*/
110constexpr const unsigned long MAX_CONNECTIONS_DEFAULT{151};
111
112/*
113 a set of mostly trivial (as in f(X)=X) defines below to make system variable
114 declarations more readable
115*/
116#define VALID_RANGE(X, Y) X, Y
117#define DEFAULT(X) X
118#define BLOCK_SIZE(X) X
119#define GLOBAL_VAR(X) \
120 sys_var::GLOBAL, (((const char *)&(X)) - (char *)&global_system_variables), \
121 sizeof(X)
122#define SESSION_VAR(X) \
123 sys_var::SESSION, offsetof(System_variables, X), \
124 sizeof(((System_variables *)nullptr)->X)
125#define SESSION_ONLY(X) \
126 sys_var::ONLY_SESSION, offsetof(System_variables, X), \
127 sizeof(((System_variables *)nullptr)->X)
128#define NO_CMD_LINE CMD_LINE(NO_ARG, -1)
129/*
130 the define below means that there's no *second* mutex guard,
131 LOCK_global_system_variables always guards all system variables
132*/
133#define NO_MUTEX_GUARD ((PolyLock *)nullptr)
134#define IN_BINLOG sys_var::SESSION_VARIABLE_IN_BINLOG
135#define NOT_IN_BINLOG sys_var::VARIABLE_NOT_IN_BINLOG
136#define ON_READ(X) X
137#define ON_CHECK(X) X
138#define PRE_UPDATE(X) X
139#define ON_UPDATE(X) X
140#define READ_ONLY sys_var::READONLY +
141#define NOT_VISIBLE sys_var::INVISIBLE +
142#define UNTRACKED_DEFAULT sys_var::TRI_LEVEL +
143#define HINT_UPDATEABLE sys_var::HINT_UPDATEABLE +
144// this means that Sys_var_charptr initial value was malloc()ed
145#define PREALLOCATED sys_var::ALLOCATED +
146#define NON_PERSIST sys_var::NOTPERSIST +
147#define PERSIST_AS_READONLY sys_var::PERSIST_AS_READ_ONLY +
148#define SENSITIVE sys_var::SENSITIVE +
149
150/*
151 Sys_var_bit meaning is reversed, like in
152 @@foreign_key_checks <-> OPTION_NO_FOREIGN_KEY_CHECKS
153*/
154#define REVERSE(X) ~(X)
155#define DEPRECATED_VAR(X) X
156
157#define session_var(THD, TYPE) (*(TYPE *)session_var_ptr(THD))
158#define global_var(TYPE) (*(TYPE *)global_var_ptr())
159
160#define GET_HA_ROWS GET_ULL
161
163
165
166static const char *bool_values[3] = {"OFF", "ON", nullptr};
167
168const char *fixup_enforce_gtid_consistency_command_line(char *value_arg);
169
170/**
171 A small wrapper class to pass getopt arguments as a pair
172 to the Sys_var_* constructors. It improves type safety and helps
173 to catch errors in the argument order.
174*/
175struct CMD_LINE {
176 int id;
178 CMD_LINE(enum get_opt_arg_type getopt_arg_type, int getopt_id = 0)
179 : id(getopt_id), arg_type(getopt_arg_type) {}
180};
181
182/**
183 Sys_var_integer template is used to generate Sys_var_* classes
184 for variables that represent the value as a signed or unsigned integer.
185 They are Sys_var_uint, Sys_var_ulong, Sys_var_harows, Sys_var_ulonglong,
186 and Sys_var_long.
187
188 An integer variable has a minimal and maximal values, and a "block_size"
189 (any valid value of the variable must be divisible by the block_size).
190
191 Class specific constructor arguments: min, max, block_size
192 Backing store: uint, ulong, ha_rows, ulonglong, long, depending on the
193 Sys_var_*
194*/
195// clang-format off
196template <typename T, ulong ARGT, enum enum_mysql_show_type SHOWT, bool SIGNED>
197class Sys_var_integer : public sys_var {
198 public:
200 const char *name_arg, const char *comment, int flag_args,
201 ptrdiff_t off, size_t size [[maybe_unused]], CMD_LINE getopt,
202 T min_val, T max_val, T def_val, uint block_size,
203 PolyLock *lock = nullptr,
204 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
205 on_check_function on_check_func = nullptr,
206 on_update_function on_update_func = nullptr,
207 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
208 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off,
209 getopt.id, getopt.arg_type, SHOWT, def_val, lock,
210 binlog_status_arg, on_check_func, on_update_func,
211 substitute, parse_flag) {
212 option.var_type = ARGT;
213 if ((min_val % block_size) != 0)
214 min_val += block_size - (min_val % block_size);
215 option.min_value = min_val;
216 option.max_value = max_val - (max_val % block_size);
217 option.block_size = block_size;
219 if (max_var_ptr()) * max_var_ptr() = max_val;
220
221 // Do not set global_var for Sys_var_keycache objects
222 if (offset >= 0) global_var(T) = def_val;
223
224 assert(size == sizeof(T));
225 assert(min_val <= def_val);
226 assert(def_val <= max_val);
227 assert(block_size > 0);
228 assert(option.min_value % block_size == 0);
229 assert(def_val % block_size == 0);
230 assert(option.max_value % block_size == 0);
231 }
232 bool do_check(THD *thd, set_var *var) override {
233 bool fixed = false;
234 longlong v;
235 ulonglong uv;
236
237 v = var->value->val_int();
238 if (SIGNED) { /* target variable has signed type */
239 if (var->value->unsigned_flag) {
240 /*
241 Input value is such a large positive number that MySQL used
242 an unsigned item to hold it. When cast to a signed longlong,
243 if the result is negative there is "cycling" and this is
244 incorrect (large positive input value should not end up as a
245 large negative value in the session signed variable to be
246 set); instead, we need to pick the allowed number closest to
247 the positive input value, i.e. pick the biggest allowed
248 positive integer.
249 */
250 if (v < 0)
251 uv = max_of_int_range(ARGT);
252 else /* no cycling, longlong can hold true value */
253 uv = (ulonglong)v;
254 } else
255 uv = v;
256 /* This will further restrict with VALID_RANGE, BLOCK_SIZE */
258 getopt_ll_limit_value(uv, &option, &fixed);
259 } else {
260 if (var->value->unsigned_flag) {
261 /* Guaranteed positive input value, ulonglong can hold it */
262 uv = (ulonglong)v;
263 } else {
264 /*
265 Maybe negative input value; in this case, cast to ulonglong
266 makes it positive, which is wrong. Pick the closest allowed
267 value i.e. 0.
268 */
269 uv = (ulonglong)(v < 0 ? 0 : v);
270 }
272 getopt_ull_limit_value(uv, &option, &fixed);
273 }
274
275 if (max_var_ptr()) {
276 /* check constraint set with --maximum-...=X */
277 if (SIGNED) {
278 longlong max_val = *max_var_ptr();
279 if (((longlong)(var->save_result.ulonglong_value)) > max_val)
280 var->save_result.ulonglong_value = max_val;
281 /*
282 Signed variable probably has some kind of symmetry. Then
283 it's good to limit negative values just as we limit positive
284 values.
285 */
286 max_val = -max_val;
287 if (((longlong)(var->save_result.ulonglong_value)) < max_val)
288 var->save_result.ulonglong_value = max_val;
289 } else {
290 ulonglong max_val = *max_var_ptr();
291 if (var->save_result.ulonglong_value > max_val)
292 var->save_result.ulonglong_value = max_val;
293 }
294 }
295
298 var->value->unsigned_flag, v);
299 }
300 bool session_update(THD *thd, set_var *var) override {
301 session_var(thd, T) = static_cast<T>(var->save_result.ulonglong_value);
302 return false;
303 }
304 bool global_update(THD *, set_var *var) override {
305 global_var(T) = static_cast<T>(var->save_result.ulonglong_value);
306 return false;
307 }
309 return type != INT_RESULT;
310 }
311 void session_save_default(THD *thd, set_var *var) override {
312 var->save_result.ulonglong_value = static_cast<ulonglong>(
313 *pointer_cast<const T *>(global_value_ptr(thd, {})));
314 }
315 void global_save_default(THD *, set_var *var) override {
317 }
318 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
319 if (SIGNED)
321 def_val, -10);
322 else
324 def_val, 10);
325 }
326
327 private:
329 return scope() == SESSION
330 ? (T *)(((uchar *)&max_system_variables) + offset)
331 : nullptr;
332 }
333};
334// clang-format on
335
344
345/**
346 A sys_var that is an alias for another sys_var.
347
348 The two variables effectively share (almost) all members, so
349 whenever you change one of them, it affects both.
350
351 Usually you want to use Sys_var_deprecated_alias instead.
352*/
353class Sys_var_alias : public sys_var {
354 private:
356
357 protected:
358 /**
359 Special constructor used to implement Sys_var_deprecated alias.
360
361 @param name_arg The name of this sys_var.
362
363 @param base_var The "parent" sys_var that this sys_var is an alias
364 for.
365
366 @param deprecation_substitute_arg The deprecation_substitute to
367 use for this variable. While other fields in the created variable
368 are inherited from real_var, the deprecation_substitute can be set
369 using this parameter.
370
371 @param persisted_alias When this variable is persisted, it will
372 duplicate the entry in the persisted variables file: It will be
373 stored both using the variable name name_arg, and the name of
374 persisted_alias.
375
376 @param is_persisted_deprecated If true, this variable is
377 deprecated when appearing in the persisted variables file.
378 */
379 Sys_var_alias(const char *name_arg, sys_var &base_var,
380 const char *deprecation_substitute_arg,
381 sys_var *persisted_alias, bool is_persisted_deprecated)
382 : sys_var(&all_sys_vars, name_arg, base_var.option.comment,
383 base_var.flags, base_var.offset, base_var.option.id,
384 base_var.option.arg_type, base_var.show_val_type,
385 base_var.option.def_value, base_var.guard,
386 base_var.binlog_status, base_var.on_check, base_var.on_update,
387 deprecation_substitute_arg, base_var.m_parse_flag,
388 persisted_alias, is_persisted_deprecated),
389 m_base_var(base_var) {
390 option = base_var.option;
391 option.name = name_arg;
392 }
393
394 public:
395 Sys_var_alias(const char *name_arg, sys_var &base_var)
396 : Sys_var_alias(name_arg, base_var, base_var.deprecation_substitute,
397 nullptr, false) {}
398
400
401 void cleanup() override { m_base_var.cleanup(); }
403 return m_base_var.cast_pluginvar();
404 }
405 void update_default(longlong new_def_value) override {
406 m_base_var.update_default(new_def_value);
407 }
411 ulong get_var_type() override { return m_base_var.get_var_type(); }
412 void set_arg_source(get_opt_arg_source *arg_source) override {
413 m_base_var.set_arg_source(arg_source);
414 }
415 void set_is_plugin(bool is_plugin) override {
416 m_base_var.set_is_plugin(is_plugin);
417 }
418 bool is_non_persistent() override { return m_base_var.is_non_persistent(); }
419 void saved_value_to_string(THD *thd, set_var *var, char *def_val) override {
420 return m_base_var.saved_value_to_string(thd, var, def_val);
421 }
424 }
426 const char *get_source_name() override {
428 }
429 void set_source(enum_variable_source src) override {
431 }
432 bool set_source_name(const char *path) override {
434 }
435 bool set_user(const char *usr) override { return m_base_var.set_user(usr); }
436 const char *get_user() override { return m_base_var.get_user(); }
437 const char *get_host() override { return m_base_var.get_host(); }
438 bool set_host(const char *hst) override { return m_base_var.set_host(hst); }
439 ulonglong get_timestamp() const override {
440 return m_base_var.get_timestamp();
441 }
442 void set_user_host(THD *thd) override { m_base_var.set_user_host(thd); }
445
446 private:
447 bool do_check(THD *thd, set_var *var) override {
448 return m_base_var.do_check(thd, var);
449 }
450 void session_save_default(THD *thd, set_var *var) override {
451 return m_base_var.session_save_default(thd, var);
452 }
453 void global_save_default(THD *thd, set_var *var) override {
454 return m_base_var.global_save_default(thd, var);
455 }
456 bool session_update(THD *thd, set_var *var) override {
457 return m_base_var.session_update(thd, var);
458 }
459 bool global_update(THD *thd, set_var *var) override {
460 return m_base_var.global_update(thd, var);
461 }
462
463 protected:
464 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
465 std::string_view keycache_name) override {
466 return m_base_var.session_value_ptr(running_thd, target_thd, keycache_name);
467 }
469 std::string_view keycache_name) override {
470 return m_base_var.global_value_ptr(thd, keycache_name);
471 }
472};
473
474/**
475 A deprecated alias for a variable.
476
477 This tool allows us to rename system variables without breaking
478 backward compatibility.
479
480 Procedure for a developer to create a new name for a variable in
481 version X and remove the old name in version X+1:
482
483 - In version X:
484
485 - Change the string passed to the Sys_var constructor for the
486 variable the new new name. All existing code for this should
487 remain as it is.
488
489 - Create a Sys_var_deprecated_alias taking the old name as the
490 first argument and the Sys_var object having the new name as the
491 second argument.
492
493 - In version X+1:
494
495 - Remove the Sys_var_deprecated_alias.
496
497 This has the following effects in version X:
498
499 - Both variables coexist. They are both visible in
500 performance_schema tables and accessible in SET statements and
501 SELECT @@variable statements. Both variables always have the same
502 values.
503
504 - A SET statement using either the old name or the new name changes
505 the value of both variables.
506
507 - A SET statement using the old name generates a deprecation
508 warning.
509
510 - The procedure that loads persisted variables from file accepts
511 either the old name, or the new name, or both. It generates a
512 deprecation warning in case only the old name exists in the file.
513 A SET PERSIST statement writes both variables to the file.
514
515 The procedures for a user to upgrade or downgrade are:
516
517 - After upgrade from version X-1 to X, all persisted variables
518 retain their persisted values. User will see deprecation warnings
519 when loading the persisted variables file, with instructions to
520 run a SET PERSIST statement any time before the next upgrade to
521 X+1.
522
523 - While on version X, user needs to run a SET PERSIST statement any
524 time before upgrading to X+1. Due to the logic described above, it
525 will write both variables to the file.
526
527 - While on version X, user needs to change their cnf files,
528 command-line arguments, and @@variables accessed through
529 application logic, to use the new names, before upgrading to X+1.
530 The deprecation warnings will help identify the relevant places to
531 update.
532
533 - After upgrade from X to X+1, the server will read the old
534 variables from the file. Since this version does not know about
535 the old variables, it will ignore them and print a warning. The
536 user can remove the unknown variable from the persisted variable
537 file, and get rid of the warning, using RESET PERSIST
538 OLD_VARIABLE_NAME.
539
540 - After downgrade from version X+1 to version X, all persisted
541 variables retain their values. User will not see deprecation
542 warnings. If user needs to further downgrade to version X-1, user
543 needs to first run SET PERSIST for some variable in order to
544 rewrite the file so that the old variable names exist in the file.
545
546 - After downgrade from version X to version X-1, all persisted
547 variables retain their values. If the new variable names exist in
548 the persisted variables file, a warning will be printed stating
549 that the variable is not known and will be ignored. User can get
550 rid of the warning by running RESET PERSIST NEW_VARIABLE_NAME.
551*/
553 private:
554 std::string m_comment;
555
556 public:
557 Sys_var_deprecated_alias(const char *name_arg, sys_var &base_var)
558 : Sys_var_alias{name_arg, base_var, base_var.name.str, &base_var, true} {
559 m_comment = std::string("This option is deprecated. Use ") +
560 base_var.get_option()->name + " instead.";
561 option.comment = m_comment.c_str();
562 }
563};
564
565/**
566 Helper class for variables that take values from a TYPELIB
567*/
568class Sys_var_typelib : public sys_var {
569 protected:
571
572 public:
573 Sys_var_typelib(const char *name_arg, const char *comment, int flag_args,
574 ptrdiff_t off, CMD_LINE getopt, SHOW_TYPE show_val_type_arg,
575 const char *values[], ulonglong def_val, PolyLock *lock,
576 enum binlog_status_enum binlog_status_arg,
577 on_check_function on_check_func,
578 on_update_function on_update_func, const char *substitute,
579 int parse_flag = PARSE_NORMAL)
580 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
581 getopt.arg_type, show_val_type_arg, def_val, lock,
582 binlog_status_arg, on_check_func, on_update_func, substitute,
583 parse_flag) {
584 for (typelib.count = 0; values[typelib.count]; typelib.count++) /*no-op */
585 ;
586 typelib.name = "";
587 typelib.type_names = values;
588 typelib.type_lengths = nullptr; // only used by Fields_enum and Field_set
590 }
591 bool do_check(THD *, set_var *var) override // works for enums and bool
592 {
593 char buff[STRING_BUFFER_USUAL_SIZE];
594 String str(buff, sizeof(buff), system_charset_info), *res;
595
596 if (var->value->result_type() == STRING_RESULT) {
597 if (!(res = var->value->val_str(&str)))
598 return true;
599 else if (!(var->save_result.ulonglong_value =
600 find_type(&typelib, res->ptr(), res->length(), false)))
601 return true;
602 else
603 var->save_result.ulonglong_value--;
604 } else {
605 const longlong tmp = var->value->val_int();
606 if (tmp < 0 || tmp >= static_cast<longlong>(typelib.count))
607 return true;
608 else
609 var->save_result.ulonglong_value = tmp;
610 }
611
612 return false;
613 }
615 return type != INT_RESULT && type != STRING_RESULT;
616 }
617};
618
619/**
620 The class for ENUM variables - variables that take one value from a fixed
621 list of values.
622
623 Class specific constructor arguments:
624 char* values[] - 0-terminated list of strings of valid values
625
626 Backing store: uint
627
628 @note
629 Do *not* use "enum FOO" variables as a backing store, there is no
630 guarantee that sizeof(enum FOO) == sizeof(uint), there is no guarantee
631 even that sizeof(enum FOO) == sizeof(enum BAR)
632*/
634 public:
636 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
637 size_t size [[maybe_unused]], CMD_LINE getopt, const char *values[],
638 uint def_val, PolyLock *lock = nullptr,
639 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
640 on_check_function on_check_func = nullptr,
641 on_update_function on_update_func = nullptr,
642 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
643 : Sys_var_typelib(name_arg, comment, flag_args, off, getopt, SHOW_CHAR,
644 values, def_val, lock, binlog_status_arg, on_check_func,
645 on_update_func, substitute, parse_flag) {
647 global_var(ulong) = def_val;
648 assert(def_val < typelib.count);
649 assert(size == sizeof(ulong));
650 }
651 bool session_update(THD *thd, set_var *var) override {
652 session_var(thd, ulong) =
653 static_cast<ulong>(var->save_result.ulonglong_value);
654 return false;
655 }
656 bool global_update(THD *, set_var *var) override {
657 global_var(ulong) = static_cast<ulong>(var->save_result.ulonglong_value);
658 return false;
659 }
660 void session_save_default(THD *, set_var *var) override {
662 }
663 void global_save_default(THD *, set_var *var) override {
665 }
666 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
667 // Copy the symbolic name, not the numeric value.
668 strcpy(def_val, typelib.type_names[var->save_result.ulonglong_value]);
669 }
670 const uchar *session_value_ptr(THD *, THD *target_thd,
671 std::string_view) override {
672 return pointer_cast<const uchar *>(
673 typelib.type_names[session_var(target_thd, ulong)]);
674 }
675 const uchar *global_value_ptr(THD *, std::string_view) override {
676 return pointer_cast<const uchar *>(typelib.type_names[global_var(ulong)]);
677 }
678};
679
680/**
681 The class for boolean variables - a variant of ENUM variables
682 with the fixed list of values of { OFF , ON }
683
684 Backing store: bool
685*/
687 public:
689 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
690 size_t size [[maybe_unused]], CMD_LINE getopt, bool def_val,
691 PolyLock *lock = nullptr,
692 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
693 on_check_function on_check_func = nullptr,
694 on_update_function on_update_func = nullptr,
695 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
696 : Sys_var_typelib(name_arg, comment, flag_args, off, getopt, SHOW_MY_BOOL,
697 bool_values, def_val, lock, binlog_status_arg,
698 on_check_func, on_update_func, substitute, parse_flag) {
700 global_var(bool) = def_val;
701 assert(getopt.arg_type == OPT_ARG || getopt.id == -1);
702 assert(size == sizeof(bool));
703 }
704 bool session_update(THD *thd, set_var *var) override {
705 session_var(thd, bool) =
706 static_cast<bool>(var->save_result.ulonglong_value);
707 return false;
708 }
709 bool global_update(THD *, set_var *var) override {
710 global_var(bool) = static_cast<bool>(var->save_result.ulonglong_value);
711 return false;
712 }
713 void session_save_default(THD *thd, set_var *var) override {
714 var->save_result.ulonglong_value = static_cast<ulonglong>(
715 *pointer_cast<const bool *>(global_value_ptr(thd, {})));
716 }
717 void global_save_default(THD *, set_var *var) override {
719 }
720 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
722 }
723};
724
725/**
726 A variant of enum where:
727 - Each value may have multiple enum-like aliases.
728 - Instances of the class can specify different default values for
729 the cases:
730 - User specifies the command-line option without a value (i.e.,
731 --option, not --option=value).
732 - User does not specify a command-line option at all.
733
734 This exists mainly to allow extending a variable that once was
735 boolean in a GA version, into an enumeration type. Booleans accept
736 multiple aliases (0=off=false, 1=on=true), but Sys_var_enum does
737 not, so we could not use Sys_var_enum without breaking backward
738 compatibility. Moreover, booleans default to false if option is not
739 given, and true if option is given without value.
740
741 This is *incompatible* with boolean in the following sense:
742 'SELECT @@variable' returns 0 or 1 for a boolean, whereas this class
743 (similar to enum) returns the textual form. (Note that both boolean,
744 enum, and this class return the textual form in SHOW VARIABLES and
745 SELECT * FROM information_schema.variables).
746
747 See enforce_gtid_consistency for an example of how this can be used.
748*/
750 public:
751 struct ALIAS {
752 const char *alias;
753 uint number;
754 };
755
756 /**
757 Enumerated type system variable.
758
759 @param name_arg See sys_var::sys_var()
760
761 @param comment See sys_var::sys_var()
762
763 @param flag_args See sys_var::sys_var()
764
765 @param off See sys_var::sys_var()
766
767 @param size See sys_var::sys_var()
768
769 @param getopt See sys_var::sys_var()
770
771 @param aliases_arg Array of ALIASes, indicating which textual
772 values map to which number. Should be terminated with an ALIAS
773 having member variable alias set to NULL. The first
774 `value_count_arg' elements must map to 0, 1, etc; these will be
775 used when the value is displayed. Remaining elements may appear
776 in arbitrary order.
777
778 @param value_count_arg The number of allowed integer values.
779
780 @param def_val The default value if no command line option is
781 given. This must be a valid index into the aliases_arg array, but
782 it does not have to be less than value_count. The corresponding
783 alias will be used in mysqld --help to show the default value.
784
785 @param command_line_no_value_arg The default value if a command line
786 option is given without a value ('--command-line-option' without
787 '=VALUE'). This must be less than value_count_arg.
788
789 @param lock See sys_var::sys_var()
790
791 @param binlog_status_arg See sys_var::sys_var()
792
793 @param on_check_func See sys_var::sys_var()
794
795 @param on_update_func See sys_var::sys_var()
796
797 @param substitute See sys_var::sys_var()
798
799 @param parse_flag See sys_var::sys_var()
800 */
802 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
803 size_t size [[maybe_unused]], CMD_LINE getopt, const ALIAS aliases_arg[],
804 uint value_count_arg, uint def_val, uint command_line_no_value_arg,
805 PolyLock *lock = nullptr,
806 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
807 on_check_function on_check_func = nullptr,
808 on_update_function on_update_func = nullptr,
809 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
810 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
811 getopt.arg_type, SHOW_CHAR, def_val, lock, binlog_status_arg,
812 on_check_func, on_update_func, substitute, parse_flag),
813 value_count(value_count_arg),
814 aliases(aliases_arg),
815 command_line_no_value(command_line_no_value_arg) {
817 assert(aliases[alias_count].number < value_count);
818 assert(def_val < alias_count);
819
822 option.def_value = (intptr)aliases[def_val].alias;
823
824 global_var(ulong) = aliases[def_val].number;
825
826 assert(getopt.arg_type == OPT_ARG || getopt.id == -1);
827 assert(size == sizeof(ulong));
828 }
829
830 /**
831 Return the numeric value for a given alias string, or -1 if the
832 string is not a valid alias.
833 */
834 int find_value(const char *text) {
835 for (uint i = 0; aliases[i].alias != nullptr; i++)
836 if (my_strcasecmp(system_charset_info, aliases[i].alias, text) == 0)
837 return aliases[i].number;
838 return -1;
839 }
840
841 /**
842 Because of limitations in the command-line parsing library, the
843 value given on the command-line cannot be automatically copied to
844 the global value. Instead, inheritants of this class should call
845 this function from mysqld.cc:mysqld_get_one_option.
846
847 @param value_str Pointer to the value specified on the command
848 line (as in --option=VALUE).
849
850 @retval NULL Success.
851
852 @retval non-NULL Pointer to the invalid string that was used as
853 argument.
854 */
855 const char *fixup_command_line(const char *value_str) {
857 char *end = nullptr;
858 long value;
859
860 // User passed --option (not --option=value).
861 if (value_str == nullptr) {
863 goto end;
864 }
865
866 // Get textual value.
867 value = find_value(value_str);
868 if (value != -1) goto end;
869
870 // Get numeric value.
871 value = strtol(value_str, &end, 10);
872 // found a number and nothing else?
873 if (end > value_str && *end == '\0')
874 // value is in range?
875 if (value >= 0 && (longlong)value < (longlong)value_count) goto end;
876
877 // Not a valid value.
878 return value_str;
879
880 end:
881 global_var(ulong) = value;
882 return nullptr;
883 }
884
885 bool do_check(THD *, set_var *var) override {
887 char buff[STRING_BUFFER_USUAL_SIZE];
888 String str(buff, sizeof(buff), system_charset_info), *res;
889 if (var->value->result_type() == STRING_RESULT) {
890 res = var->value->val_str(&str);
891 if (!res) return true;
892
893 /* Check if the value is a valid string. */
894 size_t valid_len;
895 bool len_error;
896 if (validate_string(system_charset_info, res->ptr(), res->length(),
897 &valid_len, &len_error))
898 return true;
899
900 const int value = find_value(res->ptr());
901 if (value == -1) return true;
902 var->save_result.ulonglong_value = (uint)value;
903 } else {
904 const longlong value = var->value->val_int();
905 if (value < 0 || value >= (longlong)value_count)
906 return true;
907 else
909 }
910
911 return false;
912 }
914 return type != INT_RESULT && type != STRING_RESULT;
915 }
916 bool session_update(THD *, set_var *) override {
918 assert(0);
919 /*
920 Currently not used: uncomment if this class is used as a base for
921 a session variable.
922
923 session_var(thd, ulong)=
924 static_cast<ulong>(var->save_result.ulonglong_value);
925 */
926 return false;
927 }
928 bool global_update(THD *, set_var *) override {
930 assert(0);
931 /*
932 Currently not used: uncomment if this some inheriting class does
933 not override..
934
935 ulong val=
936 static_cast<ulong>(var->save_result.ulonglong_value);
937 global_var(ulong)= val;
938 */
939 return false;
940 }
941 void session_save_default(THD *, set_var *) override {
943 assert(0);
944 /*
945 Currently not used: uncomment if this class is used as a base for
946 a session variable.
947
948 int value= find_value((char *)option.def_value);
949 assert(value != -1);
950 var->save_result.ulonglong_value= value;
951 */
952 return;
953 }
954 void global_save_default(THD *, set_var *var) override {
956 const int value = find_value((char *)option.def_value);
957 assert(value != -1);
959 return;
960 }
961 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
963 }
964
965 const uchar *session_value_ptr(THD *, THD *, std::string_view) override {
967 assert(0);
968 /*
969 Currently not used: uncomment if this class is used as a base for
970 a session variable.
971
972 return (uchar*)aliases[session_var(target_thd, ulong)].alias;
973 */
974 return nullptr;
975 }
976 const uchar *global_value_ptr(THD *, std::string_view) override {
978 return pointer_cast<const uchar *>(aliases[global_var(ulong)].alias);
979 }
980
981 private:
982 /// The number of allowed numeric values.
983 const uint value_count;
984 /// Array of all textual aliases.
986 /// The number of elements of aliases (computed in the constructor).
988
989 /**
990 Pointer to the value set by the command line (set by the command
991 line parser, copied to the global value in fixup_command_line()).
992 */
995};
996
997/**
998 The class for string variables. The string can be in character_set_filesystem
999 or in character_set_system. The string can be allocated with my_malloc()
1000 or not. The state of the initial value is specified in the constructor,
1001 after that it's managed automatically. The value of NULL is supported.
1002
1003 Class specific constructor arguments:
1004 enum charset_enum is_os_charset_arg
1005
1006 Backing store: char*
1007
1008*/
1009class Sys_var_charptr : public sys_var {
1010 public:
1012 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1013 size_t size [[maybe_unused]], CMD_LINE getopt,
1014 enum charset_enum is_os_charset_arg, const char *def_val,
1015 PolyLock *lock = nullptr,
1016 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1017 on_check_function on_check_func = nullptr,
1018 on_update_function on_update_func = nullptr,
1019 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
1020 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
1021 getopt.arg_type, SHOW_CHAR_PTR, (intptr)def_val, lock,
1022 binlog_status_arg, on_check_func, on_update_func, substitute,
1023 parse_flag) {
1024 is_os_charset = is_os_charset_arg == IN_FS_CHARSET;
1026 global_var(const char *) = def_val;
1027 assert(size == sizeof(char *));
1028 }
1029
1030 void cleanup() override {
1031 if (flags & ALLOCATED) my_free(global_var(char *));
1032 flags &= ~ALLOCATED;
1033 }
1034
1035 bool do_check(THD *thd, set_var *var) override {
1037 String str(buff, sizeof(buff), charset(thd));
1038 String str2(buff2, sizeof(buff2), charset(thd)), *res;
1039
1040 if (!(res = var->value->val_str(&str)))
1041 var->save_result.string_value.str = nullptr;
1042 else {
1043 size_t unused;
1044 if (String::needs_conversion(res->length(), res->charset(), charset(thd),
1045 &unused)) {
1046 uint errors;
1047 str2.copy(res->ptr(), res->length(), res->charset(), charset(thd),
1048 &errors);
1049 res = &str2;
1050 }
1052 thd->strmake(res->ptr(), res->length());
1053 var->save_result.string_value.length = res->length();
1054 }
1055
1056 return false;
1057 }
1058
1059 bool session_update(THD *thd, set_var *var) override {
1060 char *new_val = var->save_result.string_value.str;
1061 size_t new_val_len = var->save_result.string_value.length;
1062 char *ptr = ((char *)&thd->variables + offset);
1063
1064 return thd->session_sysvar_res_mgr.update((char **)ptr, new_val,
1065 new_val_len);
1066 }
1067
1068 bool global_update(THD *thd, set_var *var) override;
1069
1070 void session_save_default(THD *, set_var *var) override {
1071 char *ptr = (char *)(intptr)option.def_value;
1072 var->save_result.string_value.str = ptr;
1073 var->save_result.string_value.length = ptr ? strlen(ptr) : 0;
1074 }
1075
1076 void global_save_default(THD *, set_var *var) override {
1077 char *ptr = (char *)(intptr)option.def_value;
1078 /*
1079 TODO: default values should not be null. Fix all and turn this into an
1080 assert.
1081 Do that only for NON_PERSIST READ_ONLY variables since the rest use
1082 the NULL value as a flag that SET .. = DEFAULT was issued and hence
1083 it should not be alterned.
1084 */
1088 ? ptr
1089 : const_cast<char *>("");
1090 var->save_result.string_value.length = ptr ? strlen(ptr) : 0;
1091 }
1092 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
1093 memcpy(def_val, var->save_result.string_value.str,
1095 }
1097 return type != STRING_RESULT;
1098 }
1099};
1100
1102 public:
1103 Sys_var_version(const char *name_arg, const char *comment, int flag_args,
1104 ptrdiff_t off, size_t size, CMD_LINE getopt,
1105 enum charset_enum is_os_charset_arg, const char *def_val)
1106 : Sys_var_charptr(name_arg, comment, flag_args, off, size, getopt,
1107 is_os_charset_arg, def_val) {}
1108
1109 ~Sys_var_version() override = default;
1110
1112 std::string_view keycache_name) override {
1113 const uchar *value = Sys_var_charptr::global_value_ptr(thd, keycache_name);
1114
1115 DBUG_EXECUTE_IF("alter_server_version_str", {
1116 static const char *altered_value = "some-other-version";
1117 const uchar *altered_value_ptr = pointer_cast<uchar *>(&altered_value);
1118 value = altered_value_ptr;
1119 });
1120
1121 return value;
1122 }
1123};
1124
1126 public:
1127 Sys_var_proxy_user(const char *name_arg, const char *comment,
1128 enum charset_enum is_os_charset_arg)
1129 : sys_var(&all_sys_vars, name_arg, comment,
1133 is_os_charset = is_os_charset_arg == IN_FS_CHARSET;
1135 }
1136 bool do_check(THD *, set_var *) override {
1137 assert(false);
1138 return true;
1139 }
1140 bool session_update(THD *, set_var *) override {
1141 assert(false);
1142 return true;
1143 }
1144 bool global_update(THD *, set_var *) override {
1145 assert(false);
1146 return false;
1147 }
1148 void session_save_default(THD *, set_var *) override { assert(false); }
1149 void global_save_default(THD *, set_var *) override { assert(false); }
1150 void saved_value_to_string(THD *, set_var *, char *) override {
1151 assert(false);
1152 }
1153 bool check_update_type(Item_result) override { return true; }
1154
1155 protected:
1156 const uchar *session_value_ptr(THD *, THD *target_thd,
1157 std::string_view) override {
1158 const char *proxy_user = target_thd->security_context()->proxy_user().str;
1159 return proxy_user[0] ? pointer_cast<const uchar *>(proxy_user) : nullptr;
1160 }
1161};
1162
1164 public:
1165 Sys_var_external_user(const char *name_arg, const char *comment_arg,
1166 enum charset_enum is_os_charset_arg)
1167 : Sys_var_proxy_user(name_arg, comment_arg, is_os_charset_arg) {}
1168
1169 protected:
1170 const uchar *session_value_ptr(THD *, THD *target_thd,
1171 std::string_view) override {
1172 const LEX_CSTRING external_user =
1173 target_thd->security_context()->external_user();
1174 return external_user.length ? pointer_cast<const uchar *>(external_user.str)
1175 : nullptr;
1176 }
1177};
1178
1179/**
1180 The class for string variables. Useful for strings that aren't necessarily
1181 \0-terminated. Otherwise the same as Sys_var_charptr.
1182
1183 Class specific constructor arguments:
1184 enum charset_enum is_os_charset_arg
1185
1186 Backing store: LEX_STRING
1187
1188 @note
1189 Behaves exactly as Sys_var_charptr, only the backing store is different.
1190*/
1192 public:
1194 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1195 size_t size [[maybe_unused]], CMD_LINE getopt,
1196 enum charset_enum is_os_charset_arg, const char *def_val,
1197 PolyLock *lock = nullptr,
1198 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1199 on_check_function on_check_func = nullptr,
1200 on_update_function on_update_func = nullptr,
1201 const char *substitute = nullptr)
1202 : Sys_var_charptr(name_arg, comment, flag_args, off, sizeof(char *),
1203 getopt, is_os_charset_arg, def_val, lock,
1204 binlog_status_arg, on_check_func, on_update_func,
1205 substitute) {
1206 global_var(LEX_STRING).length = strlen(def_val);
1207 assert(size == sizeof(LEX_STRING));
1208 *const_cast<SHOW_TYPE *>(&show_val_type) = SHOW_LEX_STRING;
1209 }
1210 bool global_update(THD *thd, set_var *var) override {
1211 if (Sys_var_charptr::global_update(thd, var)) return true;
1213 return false;
1214 }
1215};
1216
1217#ifndef NDEBUG
1218/**
1219 @@session.dbug and @@global.dbug variables.
1220
1221 @@dbug variable differs from other variables in one aspect:
1222 if its value is not assigned in the session, it "points" to the global
1223 value, and so when the global value is changed, the change
1224 immediately takes effect in the session.
1225
1226 This semantics is intentional, to be able to debug one session from
1227 another.
1228*/
1229class Sys_var_dbug : public sys_var {
1230 public:
1232 const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt,
1233 const char *def_val, PolyLock *lock = nullptr,
1234 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1235 on_check_function on_check_func = nullptr,
1236 on_update_function on_update_func = nullptr,
1237 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
1238 : sys_var(&all_sys_vars, name_arg, comment, flag_args, 0, getopt.id,
1239 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
1240 binlog_status_arg, on_check_func, on_update_func, substitute,
1241 parse_flag) {
1243 }
1244 bool do_check(THD *thd, set_var *var) override {
1245 char buff[STRING_BUFFER_USUAL_SIZE];
1246 String str(buff, sizeof(buff), system_charset_info), *res;
1247
1248 if (!(res = var->value->val_str(&str)))
1249 var->save_result.string_value.str = const_cast<char *>("");
1250 else
1252 thd->strmake(res->ptr(), res->length());
1253 return false;
1254 }
1255 bool session_update(THD *, set_var *var) override {
1256 const char *val = var->save_result.string_value.str;
1257 if (!var->value)
1258 DBUG_POP();
1259 else
1260 DBUG_SET(val);
1261 return false;
1262 }
1263 bool global_update(THD *, set_var *var) override {
1264 const char *val = var->save_result.string_value.str;
1265 DBUG_SET_INITIAL(val);
1266 return false;
1267 }
1268 void session_save_default(THD *, set_var *) override {}
1269 void global_save_default(THD *, set_var *var) override {
1270 char *ptr = (char *)(intptr)option.def_value;
1271 var->save_result.string_value.str = ptr;
1272 }
1273 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
1274 memcpy(def_val, var->save_result.string_value.str,
1276 }
1277 const uchar *session_value_ptr(THD *running_thd, THD *,
1278 std::string_view) override {
1279 char buf[512];
1280 DBUG_EXPLAIN(buf, sizeof(buf));
1281 return (uchar *)running_thd->mem_strdup(buf);
1282 }
1283 const uchar *global_value_ptr(THD *thd, std::string_view) override {
1284 char buf[512];
1285 DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
1286 return (uchar *)thd->mem_strdup(buf);
1287 }
1289 return type != STRING_RESULT;
1290 }
1291};
1292#endif
1293
1294#define KEYCACHE_VAR(X) \
1295 sys_var::GLOBAL, offsetof(KEY_CACHE, X), sizeof(((KEY_CACHE *)nullptr)->X)
1296#define keycache_var_ptr(KC, OFF) (((uchar *)(KC)) + (OFF))
1297#define keycache_var(KC, OFF) (*(ulonglong *)keycache_var_ptr(KC, OFF))
1298typedef bool (*keycache_update_function)(THD *, KEY_CACHE *, ptrdiff_t,
1299 ulonglong);
1300
1301/**
1302 The class for keycache_* variables. Supports structured names,
1303 keycache_name.variable_name.
1304
1305 Class specific constructor arguments:
1306 everything derived from Sys_var_ulonglong
1307
1308 Backing store: ulonglong
1309
1310 @note these variables can be only GLOBAL
1311*/
1314
1315 public:
1316 Sys_var_keycache(const char *name_arg, const char *comment, int flag_args,
1317 ptrdiff_t off, size_t size, CMD_LINE getopt,
1318 ulonglong min_val, ulonglong max_val, ulonglong def_val,
1319 uint block_size, PolyLock *lock,
1320 enum binlog_status_enum binlog_status_arg,
1321 on_check_function on_check_func,
1322 keycache_update_function on_update_func,
1323 const char *substitute = nullptr)
1325 name_arg, comment, flag_args, -1, /* offset, see base class CTOR */
1326 size, getopt, min_val, max_val, def_val, block_size, lock,
1327 binlog_status_arg, on_check_func, nullptr, substitute),
1328 keycache_update(on_update_func) {
1329 offset = off; /* Remember offset in KEY_CACHE */
1331 option.value = (uchar **)1; // crash me, please
1332 keycache_var(dflt_key_cache, off) = def_val;
1333 assert(scope() == GLOBAL);
1334 }
1335 bool global_update(THD *thd, set_var *var) override {
1336 const ulonglong new_value = var->save_result.ulonglong_value;
1337
1338 assert(var->m_var_tracker.is_keycache_var());
1339 std::string_view base_name = var->m_var_tracker.get_keycache_name();
1340
1341 /* If no basename, assume it's for the key cache named 'default' */
1342 if (!base_name.empty()) {
1344 thd, Sql_condition::SL_WARNING, ER_WARN_DEPRECATED_SYNTAX,
1345 "%.*s.%s syntax "
1346 "is deprecated and will be removed in a "
1347 "future release",
1348 static_cast<int>(base_name.size()), base_name.data(), name.str);
1349 }
1350
1351 KEY_CACHE *key_cache = get_key_cache(base_name);
1352
1353 if (!key_cache) { // Key cache didn't exists */
1354 if (!new_value) // Tried to delete cache
1355 return false; // Ok, nothing to do
1356 if (!(key_cache = create_key_cache(base_name))) return true;
1357 }
1358
1359 /**
1360 Abort if some other thread is changing the key cache
1361 @todo This should be changed so that we wait until the previous
1362 assignment is done and then do the new assign
1363 */
1364 if (key_cache->in_init) return true;
1365
1366 return keycache_update(thd, key_cache, offset, new_value);
1367 }
1369 std::string_view keycache_name) override {
1370 if (!keycache_name.empty())
1372 ER_WARN_DEPRECATED_SYNTAX,
1373 "@@global.%.*s.%s syntax "
1374 "is deprecated and will be removed in a "
1375 "future release",
1376 static_cast<int>(keycache_name.size()),
1377 keycache_name.data(), name.str);
1378
1379 KEY_CACHE *key_cache = get_key_cache(keycache_name);
1380 if (!key_cache) key_cache = &zero_key_cache;
1381 return keycache_var_ptr(key_cache, offset);
1382 }
1383};
1384
1385/**
1386 The class for floating point variables
1387
1388 Class specific constructor arguments: min, max
1389
1390 Backing store: double
1391*/
1392class Sys_var_double : public sys_var {
1393 public:
1395 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1396 size_t size [[maybe_unused]], CMD_LINE getopt, double min_val,
1397 double max_val, double def_val, PolyLock *lock = nullptr,
1398 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1399 on_check_function on_check_func = nullptr,
1400 on_update_function on_update_func = nullptr,
1401 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
1402 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
1403 getopt.arg_type, SHOW_DOUBLE,
1405 binlog_status_arg, on_check_func, on_update_func, substitute,
1406 parse_flag) {
1411 assert(min_val <= max_val);
1412 assert(min_val <= def_val);
1413 assert(max_val >= def_val);
1414 assert(size == sizeof(double));
1415 }
1416 bool do_check(THD *thd, set_var *var) override {
1417 bool fixed;
1418 const double v = var->value->val_real();
1420 getopt_double_limit_value(v, &option, &fixed);
1421
1422 return throw_bounds_warning(thd, name.str, fixed, v);
1423 }
1424 bool session_update(THD *thd, set_var *var) override {
1425 session_var(thd, double) = var->save_result.double_value;
1426 return false;
1427 }
1428 bool global_update(THD *, set_var *var) override {
1429 global_var(double) = var->save_result.double_value;
1430 return false;
1431 }
1433 return type != INT_RESULT && type != REAL_RESULT && type != DECIMAL_RESULT;
1434 }
1435 void session_save_default(THD *, set_var *var) override {
1436 var->save_result.double_value = global_var(double);
1437 }
1438 void global_save_default(THD *, set_var *var) override {
1440 }
1441 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
1442 my_fcvt(var->save_result.double_value, 6, def_val, nullptr);
1443 }
1444};
1445
1446/**
1447 The class for @c test_flags (core_file for now).
1448 It's derived from Sys_var_bool.
1449
1450 Class specific constructor arguments:
1451 Caller need not pass in a variable as we make up the value on the
1452 fly, that is, we derive it from the global test_flags bit vector.
1453
1454 Backing store: bool
1455*/
1457 private:
1460
1461 public:
1462 Sys_var_test_flag(const char *name_arg, const char *comment, uint mask)
1463 : Sys_var_bool(name_arg, comment,
1465 NO_CMD_LINE, DEFAULT(false)) {
1467 }
1468 const uchar *global_value_ptr(THD *, std::string_view) override {
1470 return (uchar *)&test_flag_value;
1471 }
1472};
1473
1474/**
1475 The class for the @c max_user_connections.
1476 It's derived from Sys_var_uint, but non-standard session value
1477 requires a new class.
1478
1479 Class specific constructor arguments:
1480 everything derived from Sys_var_uint
1481
1482 Backing store: uint
1483*/
1485 public:
1487 const char *name_arg, const char *comment, int, ptrdiff_t off,
1488 size_t size, CMD_LINE getopt, uint min_val, uint max_val, uint def_val,
1489 uint block_size, PolyLock *lock = nullptr,
1490 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1491 on_check_function on_check_func = nullptr,
1492 on_update_function on_update_func = nullptr,
1493 const char *substitute = nullptr)
1494 : Sys_var_uint(name_arg, comment, SESSION, off, size, getopt, min_val,
1495 max_val, def_val, block_size, lock, binlog_status_arg,
1496 on_check_func, on_update_func, substitute) {}
1497 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
1498 std::string_view keycache_name) override {
1499 const USER_CONN *uc = target_thd->get_user_connect();
1500 if (uc && uc->user_resources.user_conn)
1501 return pointer_cast<const uchar *>(&(uc->user_resources.user_conn));
1502 return global_value_ptr(running_thd, keycache_name);
1503 }
1504};
1505
1506// overflow-safe (1 << X)-1
1507#define MAX_SET(X) ((((1ULL << ((X)-1)) - 1) << 1) | 1)
1508
1509/**
1510 The class for flagset variables - a variant of SET that allows in-place
1511 editing (turning on/off individual bits). String representations looks like
1512 a "flag=val,flag=val,...". Example: @@optimizer_switch
1513
1514 Class specific constructor arguments:
1515 char* values[] - 0-terminated list of strings of valid values
1516
1517 Backing store: ulonglong
1518
1519 @note
1520 the last value in the values[] array should
1521 *always* be the string "default".
1522*/
1524 public:
1526 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1527 size_t size [[maybe_unused]], CMD_LINE getopt, const char *values[],
1528 ulonglong def_val, PolyLock *lock = nullptr,
1529 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1530 on_check_function on_check_func = nullptr,
1531 on_update_function on_update_func = nullptr,
1532 const char *substitute = nullptr)
1533 : Sys_var_typelib(name_arg, comment, flag_args, off, getopt, SHOW_CHAR,
1534 values, def_val, lock, binlog_status_arg, on_check_func,
1535 on_update_func, substitute) {
1537 global_var(ulonglong) = def_val;
1538 assert(typelib.count > 1);
1539 assert(typelib.count <= 65);
1540 assert(def_val < MAX_SET(typelib.count));
1541 assert(strcmp(values[typelib.count - 1], "default") == 0);
1542 assert(size == sizeof(ulonglong));
1543 }
1544 bool do_check(THD *thd, set_var *var) override {
1545 char buff[STRING_BUFFER_USUAL_SIZE];
1546 String str(buff, sizeof(buff), system_charset_info), *res;
1547 ulonglong default_value, current_value;
1548 if (var->is_global_persist() || scope() == GLOBAL) {
1549 default_value = option.def_value;
1550 current_value = global_var(ulonglong);
1551 } else {
1552 default_value = global_var(ulonglong);
1553 current_value = session_var(thd, ulonglong);
1554 }
1555
1556 if (var->value->result_type() == STRING_RESULT) {
1557 if (!(res = var->value->val_str(&str)))
1558 return true;
1559 else {
1560 const char *error;
1561 uint error_len;
1562
1564 &typelib, typelib.count, current_value, default_value, res->ptr(),
1565 static_cast<uint>(res->length()), &error, &error_len);
1566 if (error) {
1567 const ErrConvString err(error, error_len, res->charset());
1568 my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.str, err.ptr());
1569 return true;
1570 }
1571 }
1572 } else {
1573 const longlong tmp = var->value->val_int();
1574 if ((tmp < 0 && !var->value->unsigned_flag) ||
1576 return true;
1577 else
1578 var->save_result.ulonglong_value = tmp;
1579 }
1580
1581 return false;
1582 }
1583 bool session_update(THD *thd, set_var *var) override {
1585 return false;
1586 }
1587 bool global_update(THD *, set_var *var) override {
1589 return false;
1590 }
1591 void session_save_default(THD *, set_var *var) override {
1593 }
1594 void global_save_default(THD *, set_var *var) override {
1596 }
1597 void saved_value_to_string(THD *thd, set_var *var, char *def_val) override {
1598 strcpy(def_val,
1601 }
1602 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
1603 std::string_view) override {
1604 return (uchar *)flagset_to_string(running_thd, nullptr,
1605 session_var(target_thd, ulonglong),
1607 }
1608 const uchar *global_value_ptr(THD *thd, std::string_view) override {
1609 return (uchar *)flagset_to_string(thd, nullptr, global_var(ulonglong),
1611 }
1612};
1613
1614/**
1615 The class for SET variables - variables taking zero or more values
1616 from the given list. Example: @@sql_mode
1617
1618 Class specific constructor arguments:
1619 char* values[] - 0-terminated list of strings of valid values
1620
1621 Backing store: ulonglong
1622*/
1624 public:
1626 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1627 size_t size [[maybe_unused]], CMD_LINE getopt, const char *values[],
1628 ulonglong def_val, PolyLock *lock = nullptr,
1629 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1630 on_check_function on_check_func = nullptr,
1631 on_update_function on_update_func = nullptr,
1632 const char *substitute = nullptr)
1633 : Sys_var_typelib(name_arg, comment, flag_args, off, getopt, SHOW_CHAR,
1634 values, def_val, lock, binlog_status_arg, on_check_func,
1635 on_update_func, substitute) {
1637 global_var(ulonglong) = def_val;
1638 assert(typelib.count > 0);
1639 assert(typelib.count <= 64);
1640 assert(def_val < MAX_SET(typelib.count));
1641 assert(size == sizeof(ulonglong));
1642 }
1643 bool do_check(THD *, set_var *var) override {
1644 char buff[STRING_BUFFER_USUAL_SIZE];
1645 String str(buff, sizeof(buff), system_charset_info), *res;
1646
1647 if (var->value->result_type() == STRING_RESULT) {
1648 if (!(res = var->value->val_str(&str)))
1649 return true;
1650 else {
1651 const char *error;
1652 uint error_len;
1653 bool not_used;
1654
1656 find_set(&typelib, res->ptr(), static_cast<uint>(res->length()),
1657 nullptr, &error, &error_len, &not_used);
1658 /*
1659 note, we only issue an error if error_len > 0.
1660 That is even while empty (zero-length) values are considered
1661 errors by find_set(), these errors are ignored here
1662 */
1663 if (error_len) {
1664 const ErrConvString err(error, error_len, res->charset());
1665 my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name.str, err.ptr());
1666 return true;
1667 }
1668 }
1669 } else {
1670 const longlong tmp = var->value->val_int();
1671 if ((tmp < 0 && !var->value->unsigned_flag) ||
1673 return true;
1674 else
1675 var->save_result.ulonglong_value = tmp;
1676 }
1677
1678 return false;
1679 }
1680 bool session_update(THD *thd, set_var *var) override {
1682 return false;
1683 }
1684 bool global_update(THD *, set_var *var) override {
1686 return false;
1687 }
1688 void session_save_default(THD *, set_var *var) override {
1690 }
1691 void global_save_default(THD *, set_var *var) override {
1693 }
1694 void saved_value_to_string(THD *thd, set_var *var, char *def_val) override {
1695 strcpy(def_val,
1696 set_to_string(thd, nullptr, var->save_result.ulonglong_value,
1698 }
1699 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
1700 std::string_view) override {
1701 return (uchar *)set_to_string(running_thd, nullptr,
1702 session_var(target_thd, ulonglong),
1704 }
1705 const uchar *global_value_ptr(THD *thd, std::string_view) override {
1706 return (uchar *)set_to_string(thd, nullptr, global_var(ulonglong),
1708 }
1709};
1710
1711/**
1712 The class for variables which value is a plugin.
1713 Example: @@default_storage_engine
1714
1715 Class specific constructor arguments:
1716 int plugin_type_arg (for example MYSQL_STORAGE_ENGINE_PLUGIN)
1717
1718 Backing store: plugin_ref
1719
1720 @note
1721 these variables don't support command-line equivalents, any such
1722 command-line options should be added manually to my_long_options in mysqld.cc
1723*/
1724class Sys_var_plugin : public sys_var {
1727
1728 public:
1730 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1731 size_t size [[maybe_unused]], CMD_LINE getopt, int plugin_type_arg,
1732 const char **def_val, bool allow_secondary_engine,
1733 PolyLock *lock = nullptr,
1734 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1735 on_check_function on_check_func = nullptr)
1736 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
1737 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
1738 binlog_status_arg, on_check_func, nullptr, nullptr,
1739 PARSE_NORMAL),
1740 plugin_type(plugin_type_arg),
1743 assert(size == sizeof(plugin_ref));
1744 assert(getopt.id == -1); // force NO_CMD_LINE
1745 }
1746 bool do_check(THD *thd, set_var *var) override {
1747 char buff[STRING_BUFFER_USUAL_SIZE];
1748 String str(buff, sizeof(buff), system_charset_info), *res;
1749
1750 /* NULLs can't be used as a default storage engine */
1751 if (!(res = var->value->val_str(&str))) return true;
1752
1753 const LEX_CSTRING pname_cstr = res->lex_cstring();
1754 plugin_ref plugin;
1755
1756 // special code for storage engines (e.g. to handle historical aliases)
1758 plugin = ha_resolve_by_name(thd, &pname_cstr, false);
1759 else {
1760 plugin = my_plugin_lock_by_name(thd, pname_cstr, plugin_type);
1761 }
1762
1763 if (!plugin) {
1764 // historically different error code
1766 const ErrConvString err(res);
1767 my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), err.ptr());
1768 }
1769 return true;
1770 }
1771
1773 const auto *hton = plugin_data<handlerton *>(plugin);
1774 if ((hton->flags & HTON_IS_SECONDARY_ENGINE) != 0U) {
1775 const ErrConvString err(res);
1776 my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), err.ptr());
1777 return true;
1778 }
1779 }
1780
1781 var->save_result.plugin = plugin;
1782 return false;
1783 }
1784 void do_update(plugin_ref *valptr, plugin_ref newval) {
1785 plugin_ref oldval = *valptr;
1786 if (oldval != newval) {
1787 *valptr = my_plugin_lock(nullptr, &newval);
1788 plugin_unlock(nullptr, oldval);
1789 }
1790 }
1791 bool session_update(THD *thd, set_var *var) override {
1793 return false;
1794 }
1795 bool global_update(THD *, set_var *var) override {
1797 return false;
1798 }
1799 void session_save_default(THD *thd, set_var *var) override {
1801 var->save_result.plugin = my_plugin_lock(thd, &plugin);
1802 }
1803 void global_save_default(THD *thd, set_var *var) override {
1804 LEX_CSTRING pname;
1805 char **default_value = reinterpret_cast<char **>(option.def_value);
1806 pname.str = *default_value;
1807 pname.length = strlen(pname.str);
1808
1809 plugin_ref plugin;
1811 plugin = ha_resolve_by_name(thd, &pname, false);
1812 else {
1813 plugin = my_plugin_lock_by_name(thd, pname, plugin_type);
1814 }
1815 assert(plugin);
1816
1817 var->save_result.plugin = my_plugin_lock(thd, &plugin);
1818 }
1819 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
1820 strncpy(def_val, plugin_name(var->save_result.plugin)->str,
1822 }
1824 return type != STRING_RESULT;
1825 }
1826 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
1827 std::string_view) override {
1828 plugin_ref plugin = session_var(target_thd, plugin_ref);
1829 return (uchar *)(plugin ? running_thd->strmake(plugin_name(plugin)->str,
1830 plugin_name(plugin)->length)
1831 : nullptr);
1832 }
1833 const uchar *global_value_ptr(THD *thd, std::string_view) override {
1835 return (uchar *)(plugin ? thd->strmake(plugin_name(plugin)->str,
1836 plugin_name(plugin)->length)
1837 : nullptr);
1838 }
1839};
1840
1841#if defined(ENABLED_DEBUG_SYNC)
1842/**
1843 The class for @@debug_sync session-only variable
1844*/
1845class Sys_var_debug_sync : public sys_var {
1846 public:
1847 Sys_var_debug_sync(
1848 const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt,
1849 const char *def_val, PolyLock *lock = nullptr,
1850 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1851 on_check_function on_check_func = nullptr,
1852 on_update_function on_update_func = nullptr,
1853 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
1854 : sys_var(&all_sys_vars, name_arg, comment, flag_args, 0, getopt.id,
1855 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
1856 binlog_status_arg, on_check_func, on_update_func, substitute,
1857 parse_flag) {
1858 assert(scope() == ONLY_SESSION);
1859 option.var_type = GET_NO_ARG;
1860 }
1861 bool do_check(THD *thd, set_var *var) override {
1862 char buff[STRING_BUFFER_USUAL_SIZE];
1863 String str(buff, sizeof(buff), system_charset_info), *res;
1864
1865 if (!(res = var->value->val_str(&str)))
1866 var->save_result.string_value.str = const_cast<char *>("");
1867 else
1869 thd->strmake(res->ptr(), res->length());
1870 return false;
1871 }
1872 bool session_update(THD *thd, set_var *var) override {
1873 return debug_sync_update(thd, var->save_result.string_value.str);
1874 }
1875 bool global_update(THD *, set_var *) override {
1876 assert(false);
1877 return true;
1878 }
1879 void session_save_default(THD *, set_var *var) override {
1880 var->save_result.string_value.str = const_cast<char *>("");
1882 }
1883 void global_save_default(THD *, set_var *) override { assert(false); }
1884 void saved_value_to_string(THD *, set_var *, char *) override {
1885 assert(false);
1886 }
1887 const uchar *session_value_ptr(THD *running_thd, THD *,
1888 std::string_view) override {
1889 return debug_sync_value_ptr(running_thd);
1890 }
1891 const uchar *global_value_ptr(THD *, std::string_view) override {
1892 assert(false);
1893 return nullptr;
1894 }
1895 bool check_update_type(Item_result type) override {
1896 return type != STRING_RESULT;
1897 }
1898};
1899#endif /* defined(ENABLED_DEBUG_SYNC) */
1900
1901/**
1902 The class for bit variables - a variant of boolean that stores the value
1903 in a bit.
1904
1905 Class specific constructor arguments:
1906 ulonglong bitmask_arg - the mask for the bit to set in the ulonglong
1907 backing store
1908
1909 Backing store: ulonglong
1910
1911 @note
1912 This class supports the "reverse" semantics, when the value of the bit
1913 being 0 corresponds to the value of variable being set. To activate it
1914 use REVERSE(bitmask) instead of simply bitmask in the constructor.
1915
1916 @note
1917 variables of this class cannot be set from the command line as
1918 my_getopt does not support bits.
1919*/
1923 void set(uchar *ptr, ulonglong value) {
1924 if ((value != 0) ^ reverse_semantics)
1925 (*(ulonglong *)ptr) |= bitmask;
1926 else
1927 (*(ulonglong *)ptr) &= ~bitmask;
1928 }
1929
1930 public:
1932 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
1933 size_t size [[maybe_unused]], CMD_LINE getopt, ulonglong bitmask_arg,
1934 bool def_val, PolyLock *lock = nullptr,
1935 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
1936 on_check_function on_check_func = nullptr,
1937 pre_update_function pre_update_func = nullptr,
1938 on_update_function on_update_func = nullptr,
1939 const char *substitute = nullptr)
1940 : Sys_var_typelib(name_arg, comment, flag_args, off, getopt, SHOW_MY_BOOL,
1941 bool_values, def_val, lock, binlog_status_arg,
1942 on_check_func, on_update_func, substitute) {
1944 pre_update = pre_update_func;
1945 reverse_semantics = std::popcount(bitmask_arg) > 1;
1946 bitmask = reverse_semantics ? ~bitmask_arg : bitmask_arg;
1947 set(global_var_ptr(), def_val);
1948 assert(getopt.id == -1); // force NO_CMD_LINE
1949 assert(size == sizeof(ulonglong));
1950 }
1951 bool session_update(THD *thd, set_var *var) override {
1953 return false;
1954 }
1955 bool global_update(THD *, set_var *var) override {
1957 return false;
1958 }
1959 void session_save_default(THD *, set_var *var) override {
1961 }
1962 void global_save_default(THD *, set_var *var) override {
1964 }
1965 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
1967 }
1968 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
1969 std::string_view) override {
1970 running_thd->sys_var_tmp.bool_value = static_cast<bool>(
1972 ((session_var(target_thd, ulonglong) & bitmask) != 0));
1973 return (uchar *)&running_thd->sys_var_tmp.bool_value;
1974 }
1975 const uchar *global_value_ptr(THD *thd, std::string_view) override {
1976 thd->sys_var_tmp.bool_value = static_cast<bool>(
1978 return (uchar *)&thd->sys_var_tmp.bool_value;
1979 }
1980};
1981
1982/**
1983 The class for variables that have a special meaning for a session,
1984 such as @@timestamp or @@rnd_seed1, their values typically cannot be read
1985 from SV structure, and a special "read" callback is provided.
1986
1987 Class specific constructor arguments:
1988 everything derived from Sys_var_ulonglong
1989 session_special_read_function read_func_arg
1990
1991 Backing store: ulonglong
1992
1993 @note
1994 These variables are session-only, global or command-line equivalents
1995 are not supported as they're generally meaningless.
1996*/
1998 typedef bool (*session_special_update_function)(THD *thd, set_var *var);
2000
2003
2004 public:
2005 Sys_var_session_special(const char *name_arg, const char *comment,
2006 int flag_args, CMD_LINE getopt, ulonglong min_val,
2007 ulonglong max_val, uint block_size, PolyLock *lock,
2008 enum binlog_status_enum binlog_status_arg,
2009 on_check_function on_check_func,
2010 session_special_update_function update_func_arg,
2011 session_special_read_function read_func_arg,
2012 const char *substitute = nullptr)
2013 : Sys_var_ulonglong(name_arg, comment, flag_args, 0, sizeof(ulonglong),
2014 getopt, min_val, max_val, 0, block_size, lock,
2015 binlog_status_arg, on_check_func, nullptr,
2016 substitute),
2017 read_func(read_func_arg),
2018 update_func(update_func_arg) {
2019 assert(scope() == ONLY_SESSION);
2020 assert(getopt.id == -1); // NO_CMD_LINE, because the offset is fake
2021 }
2022 bool session_update(THD *thd, set_var *var) override {
2023 return update_func(thd, var);
2024 }
2025 bool global_update(THD *, set_var *) override {
2026 assert(false);
2027 return true;
2028 }
2029 void session_save_default(THD *, set_var *var) override {
2030 var->value = nullptr;
2031 }
2032 void global_save_default(THD *, set_var *) override { assert(false); }
2033 void saved_value_to_string(THD *, set_var *, char *) override {
2034 assert(false);
2035 }
2036 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
2037 std::string_view) override {
2038 running_thd->sys_var_tmp.ulonglong_value = read_func(target_thd);
2039 return (uchar *)&running_thd->sys_var_tmp.ulonglong_value;
2040 }
2041 const uchar *global_value_ptr(THD *, std::string_view) override {
2042 assert(false);
2043 return nullptr;
2044 }
2045};
2046
2047/**
2048 Similar to Sys_var_session_special, but with double storage.
2049*/
2051 typedef bool (*session_special_update_function)(THD *thd, set_var *var);
2053
2056
2057 public:
2059 const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt,
2060 double min_val, double max_val, uint, PolyLock *lock,
2061 enum binlog_status_enum binlog_status_arg,
2062 on_check_function on_check_func,
2063 session_special_update_function update_func_arg,
2065 const char *substitute = nullptr)
2066 : Sys_var_double(name_arg, comment, flag_args, 0, sizeof(double), getopt,
2067 min_val, max_val, 0.0, lock, binlog_status_arg,
2068 on_check_func, nullptr, substitute),
2069 read_func(read_func_arg),
2070 update_func(update_func_arg) {
2071 assert(scope() == ONLY_SESSION);
2072 assert(getopt.id == -1); // NO_CMD_LINE, because the offset is fake
2073 }
2074 bool session_update(THD *thd, set_var *var) override {
2075 return update_func(thd, var);
2076 }
2077 bool global_update(THD *, set_var *) override {
2078 assert(false);
2079 return true;
2080 }
2081 void session_save_default(THD *, set_var *var) override {
2082 var->value = nullptr;
2083 }
2084 void global_save_default(THD *, set_var *) override { assert(false); }
2085 void saved_value_to_string(THD *, set_var *, char *) override {
2086 assert(false);
2087 }
2088 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
2089 std::string_view) override {
2090 running_thd->sys_var_tmp.double_value = read_func(target_thd);
2091 return (uchar *)&running_thd->sys_var_tmp.double_value;
2092 }
2093 const uchar *global_value_ptr(THD *, std::string_view) override {
2094 assert(false);
2095 return nullptr;
2096 }
2097};
2098
2099/**
2100 The class for read-only variables that show whether a particular
2101 feature is supported by the server. Example: have_compression
2102
2103 Backing store: enum SHOW_COMP_OPTION
2104
2105 @note
2106 These variables are necessarily read-only, only global, and have no
2107 command-line equivalent.
2108*/
2109class Sys_var_have : public sys_var {
2110 public:
2112 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2113 size_t size [[maybe_unused]], CMD_LINE getopt, PolyLock *lock = nullptr,
2114 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2115 on_check_function on_check_func = nullptr,
2116 on_update_function on_update_func = nullptr,
2117 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
2118 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2119 getopt.arg_type, SHOW_CHAR, 0, lock, binlog_status_arg,
2120 on_check_func, on_update_func, substitute, parse_flag) {
2121 assert(scope() == GLOBAL);
2122 assert(getopt.id == -1);
2123 assert(lock == nullptr);
2124 assert(binlog_status_arg == VARIABLE_NOT_IN_BINLOG);
2125 assert(is_readonly());
2126 assert(on_update == nullptr);
2127 assert(size == sizeof(enum SHOW_COMP_OPTION));
2128 }
2129 bool do_check(THD *, set_var *) override {
2130 assert(false);
2131 return true;
2132 }
2133 bool session_update(THD *, set_var *) override {
2134 assert(false);
2135 return true;
2136 }
2137 bool global_update(THD *, set_var *) override {
2138 assert(false);
2139 return true;
2140 }
2141 void session_save_default(THD *, set_var *) override {}
2142 void global_save_default(THD *, set_var *) override {}
2143 void saved_value_to_string(THD *, set_var *, char *) override {}
2144 const uchar *session_value_ptr(THD *, THD *, std::string_view) override {
2145 assert(false);
2146 return nullptr;
2147 }
2148 const uchar *global_value_ptr(THD *, std::string_view) override {
2149 return pointer_cast<const uchar *>(
2151 }
2152 bool check_update_type(Item_result) override { return false; }
2153};
2154
2155/**
2156 A subclass of @ref Sys_var_have to return dynamic values
2157
2158 All the usual restrictions for @ref Sys_var_have apply.
2159 But instead of reading a global variable it calls a function
2160 to return the value.
2161 */
2163 public:
2164 /**
2165 Construct a new variable.
2166
2167 @param name_arg The name of the variable
2168 @param comment Explanation of what the variable does
2169 @param func The function to call when in need to read the global value
2170 @param substitute If the variable is deprecated what to use instead
2171 */
2172 Sys_var_have_func(const char *name_arg, const char *comment,
2173 enum SHOW_COMP_OPTION (*func)(THD *),
2174 const char *substitute = nullptr)
2175 /*
2176 Note: it doesn't really matter what variable we use, as long as we are
2177 using one. So we use a local static dummy
2178 */
2179 : Sys_var_have(name_arg, comment,
2182 substitute),
2183 func_(func) {}
2184
2185 const uchar *global_value_ptr(THD *thd, std::string_view) override {
2186 return pointer_cast<const uchar *>(show_comp_option_name[func_(thd)]);
2187 }
2188
2189 protected:
2190 enum SHOW_COMP_OPTION (*func_)(THD *);
2192};
2193/**
2194 Generic class for variables for storing entities that are internally
2195 represented as structures, have names, and possibly can be referred to by
2196 numbers. Examples: character sets, collations, locales,
2197
2198 Backing store: void*
2199 @tparam Struct_type type of struct being wrapped
2200 @tparam Name_getter must provide Name_getter(Struct_type*).get_name()
2201
2202 @note
2203 As every such a structure requires special treatment from my_getopt,
2204 these variables don't support command-line equivalents, any such
2205 command-line options should be added manually to my_long_options in mysqld.cc
2206*/
2207template <typename Struct_type, typename Name_getter>
2208class Sys_var_struct : public sys_var {
2209 public:
2211 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2212 size_t size [[maybe_unused]], CMD_LINE getopt, void *def_val,
2213 PolyLock *lock = nullptr,
2214 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2215 on_check_function on_check_func = nullptr,
2216 on_update_function on_update_func = nullptr,
2217 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
2218 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2219 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
2220 binlog_status_arg, on_check_func, on_update_func, substitute,
2221 parse_flag) {
2223 /*
2224 struct variables are special on the command line - often (e.g. for
2225 charsets) the name cannot be immediately resolved, but only after all
2226 options (in particular, basedir) are parsed.
2227
2228 thus all struct command-line options should be added manually
2229 to my_long_options in mysqld.cc
2230 */
2231 assert(getopt.id == -1);
2232 assert(size == sizeof(void *));
2233 }
2234 bool do_check(THD *, set_var *) override { return false; }
2235 bool session_update(THD *thd, set_var *var) override {
2236 session_var(thd, const void *) = var->save_result.ptr;
2237 return false;
2238 }
2239 bool global_update(THD *, set_var *var) override {
2240 global_var(const void *) = var->save_result.ptr;
2241 return false;
2242 }
2243 void session_save_default(THD *, set_var *var) override {
2244 var->save_result.ptr = global_var(void *);
2245 }
2246 void global_save_default(THD *, set_var *var) override {
2247 void **default_value = reinterpret_cast<void **>(option.def_value);
2248 var->save_result.ptr = *default_value;
2249 }
2250 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
2251 const Struct_type *ptr =
2252 static_cast<const Struct_type *>(var->save_result.ptr);
2253 if (ptr)
2254 strcpy(def_val, pointer_cast<const char *>(Name_getter(ptr).get_name()));
2255 }
2257 return type != INT_RESULT && type != STRING_RESULT;
2258 }
2259 const uchar *session_value_ptr(THD *, THD *target_thd,
2260 std::string_view) override {
2261 const Struct_type *ptr = session_var(target_thd, const Struct_type *);
2262 return ptr ? Name_getter(ptr).get_name() : nullptr;
2263 }
2264 const uchar *global_value_ptr(THD *, std::string_view) override {
2265 const Struct_type *ptr = global_var(const Struct_type *);
2266 return ptr ? Name_getter(ptr).get_name() : nullptr;
2267 }
2268};
2269
2270/**
2271 The class for variables that store time zones
2272
2273 Backing store: Time_zone*
2274
2275 @note
2276 Time zones cannot be supported directly by my_getopt, thus
2277 these variables don't support command-line equivalents, any such
2278 command-line options should be added manually to my_long_options in mysqld.cc
2279*/
2280class Sys_var_tz : public sys_var {
2281 public:
2282 Sys_var_tz(const char *name_arg, const char *comment, int flag_args,
2283 ptrdiff_t off, size_t size [[maybe_unused]], CMD_LINE getopt,
2284 Time_zone **def_val, PolyLock *lock = nullptr,
2285 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2286 on_check_function on_check_func = nullptr,
2287 on_update_function on_update_func = nullptr,
2288 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
2289 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2290 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
2291 binlog_status_arg, on_check_func, on_update_func, substitute,
2292 parse_flag) {
2293 assert(getopt.id == -1);
2294 assert(size == sizeof(Time_zone *));
2296 }
2297 bool do_check(THD *thd, set_var *var) override {
2298 char buff[MAX_TIME_ZONE_NAME_LENGTH];
2299 String str(buff, sizeof(buff), &my_charset_latin1);
2300 String *res = var->value->val_str(&str);
2301
2302 if (!res) return true;
2303
2304 if (!(var->save_result.time_zone = my_tz_find(thd, res))) {
2305 const ErrConvString err(res);
2306 my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), err.ptr());
2307 return true;
2308 }
2309 return false;
2310 }
2311 bool session_update(THD *thd, set_var *var) override {
2313 return false;
2314 }
2315 bool global_update(THD *, set_var *var) override {
2317 return false;
2318 }
2319 void session_save_default(THD *, set_var *var) override {
2321 }
2322 void global_save_default(THD *, set_var *var) override {
2324 }
2325 void saved_value_to_string(THD *, set_var *var, char *def_val) override {
2326 strcpy(def_val, var->save_result.time_zone->get_name()->ptr());
2327 }
2328 const uchar *session_value_ptr(THD *, THD *target_thd,
2329 std::string_view) override {
2330 /*
2331 This is an ugly fix for replication: we don't replicate properly queries
2332 invoking system variables' values to update tables; but
2333 CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
2334 replicable (i.e. we tell the binlog code to store the session
2335 timezone). If it's the global value which was used we can't replicate
2336 (binlog code stores session value only).
2337 */
2338 target_thd->time_zone_used = true;
2339 return pointer_cast<const uchar *>(
2340 session_var(target_thd, Time_zone *)->get_name()->ptr());
2341 }
2342 const uchar *global_value_ptr(THD *, std::string_view) override {
2343 return pointer_cast<const uchar *>(
2344 global_var(Time_zone *)->get_name()->ptr());
2345 }
2347 return type != STRING_RESULT;
2348 }
2349};
2350
2351/**
2352 Class representing the 'transaction_isolation' system variable. This
2353 variable can also be indirectly set using 'SET TRANSACTION ISOLATION
2354 LEVEL'.
2355*/
2356
2358 public:
2359 Sys_var_transaction_isolation(const char *name_arg, const char *comment,
2360 int flag_args, ptrdiff_t off, size_t size,
2361 CMD_LINE getopt, const char *values[],
2362 uint def_val, PolyLock *lock,
2363 enum binlog_status_enum binlog_status_arg,
2364 on_check_function on_check_func)
2365 : Sys_var_enum(name_arg, comment, flag_args, off, size, getopt, values,
2366 def_val, lock, binlog_status_arg, on_check_func) {}
2367 bool session_update(THD *thd, set_var *var) override;
2368};
2369
2370/**
2371 Class representing the tx_read_only system variable for setting
2372 default transaction access mode.
2373
2374 Note that there is a special syntax - SET TRANSACTION READ ONLY
2375 (or READ WRITE) that sets the access mode for the next transaction
2376 only.
2377*/
2378
2380 public:
2381 Sys_var_transaction_read_only(const char *name_arg, const char *comment,
2382 int flag_args, ptrdiff_t off, size_t size,
2383 CMD_LINE getopt, bool def_val, PolyLock *lock,
2384 enum binlog_status_enum binlog_status_arg,
2385 on_check_function on_check_func)
2386 : Sys_var_bool(name_arg, comment, flag_args, off, size, getopt, def_val,
2387 lock, binlog_status_arg, on_check_func) {}
2388 bool session_update(THD *thd, set_var *var) override;
2389};
2390
2391/**
2392 A class for @@global.binlog_checksum that has
2393 a specialized update method.
2394*/
2396 public:
2397 Sys_var_enum_binlog_checksum(const char *name_arg, const char *comment,
2398 int flag_args, ptrdiff_t off, size_t size,
2399 CMD_LINE getopt, const char *values[],
2400 uint def_val, PolyLock *lock,
2401 enum binlog_status_enum binlog_status_arg,
2402 on_check_function on_check_func = nullptr)
2403 : Sys_var_enum(name_arg, comment, flag_args | PERSIST_AS_READ_ONLY, off,
2404 size, getopt, values, def_val, lock, binlog_status_arg,
2405 on_check_func, nullptr) {}
2406 bool global_update(THD *thd, set_var *var) override;
2407};
2408
2409/**
2410 Class for gtid_next.
2411*/
2413 public:
2415 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2416 size_t size [[maybe_unused]], CMD_LINE getopt, const char *def_val,
2417 PolyLock *lock = nullptr,
2418 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2419 on_check_function on_check_func = nullptr,
2420 on_update_function on_update_func = nullptr,
2421 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
2422 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2423 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
2424 binlog_status_arg, on_check_func, on_update_func, substitute,
2425 parse_flag) {
2426 assert(size == sizeof(Gtid_specification));
2427 }
2428 bool session_update(THD *thd, set_var *var) override;
2429
2430 bool global_update(THD *, set_var *) override {
2431 assert(false);
2432 return true;
2433 }
2434 void session_save_default(THD *, set_var *var) override {
2435 DBUG_TRACE;
2436 char *ptr = (char *)(intptr)option.def_value;
2437 var->save_result.string_value.str = ptr;
2438 var->save_result.string_value.length = ptr ? strlen(ptr) : 0;
2439 return;
2440 }
2441 void global_save_default(THD *, set_var *) override { assert(false); }
2442 void saved_value_to_string(THD *, set_var *, char *) override {
2443 assert(false);
2444 }
2445 bool do_check(THD *, set_var *) override { return false; }
2447 return type != STRING_RESULT;
2448 }
2449 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
2450 std::string_view) override {
2451 DBUG_TRACE;
2454 ((Gtid_specification *)session_var_ptr(target_thd))
2457 char *ret = running_thd->mem_strdup(buf);
2458 return (uchar *)ret;
2459 }
2460 const uchar *global_value_ptr(THD *, std::string_view) override {
2461 assert(false);
2462 return nullptr;
2463 }
2464};
2465
2466#ifdef HAVE_GTID_NEXT_LIST
2467/**
2468 Class for variables that store values of type Gtid_set.
2469
2470 The back-end storage should be a Gtid_set_or_null, and it should be
2471 set to null by default. When the variable is set for the first
2472 time, the Gtid_set* will be allocated.
2473*/
2474class Sys_var_gtid_set : public sys_var {
2475 public:
2476 Sys_var_gtid_set(
2477 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2478 size_t size, CMD_LINE getopt, const char *def_val, PolyLock *lock = 0,
2479 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2480 on_check_function on_check_func = 0,
2481 on_update_function on_update_func = 0, const char *substitute = 0,
2482 int parse_flag = PARSE_NORMAL)
2483 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2484 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
2485 binlog_status_arg, on_check_func, on_update_func, substitute,
2486 parse_flag) {
2487 assert(size == sizeof(Gtid_set_or_null));
2488 }
2489 bool session_update(THD *thd, set_var *var);
2490
2491 bool global_update(THD *thd, set_var *var) {
2492 assert(false);
2493 return true;
2494 }
2495 void session_save_default(THD *thd, set_var *var) {
2496 DBUG_TRACE;
2498 char *ptr = (char *)(intptr)option.def_value;
2499 var->save_result.string_value.str = ptr;
2500 var->save_result.string_value.length = ptr ? strlen(ptr) : 0;
2502 return;
2503 }
2504 void global_save_default(THD *thd, set_var *var) { assert(false); }
2505 void saved_value_to_string(THD *, set_var *, char *) { assert(false); }
2506 bool do_check(THD *thd, set_var *var) {
2507 DBUG_TRACE;
2508 String str;
2509 String *res = var->value->val_str(&str);
2510 if (res == nullptr) {
2511 var->save_result.string_value.str = nullptr;
2512 return false;
2513 }
2514 assert(res->ptr() != nullptr);
2515 var->save_result.string_value.str = thd->strmake(res->ptr(), res->length());
2516 if (var->save_result.string_value.str == nullptr) {
2517 my_error(ER_OUT_OF_RESOURCES, MYF(0)); // thd->strmake failed
2518 return 1;
2519 }
2520 var->save_result.string_value.length = res->length();
2521 bool ret = !Gtid_set::is_valid(res->ptr());
2522 return ret;
2523 }
2525 uchar *session_value_ptr(THD *running_thd, THD *target_thd,
2526 const std::string &) override {
2527 DBUG_TRACE;
2529 Gtid_set *gs = gsn->get_gtid_set();
2530 if (gs == nullptr) return nullptr;
2531 char *buf;
2533 buf = (char *)running_thd->alloc(gs->get_string_length() + 1);
2534 if (buf)
2535 gs->to_string(buf);
2536 else
2537 my_error(ER_OUT_OF_RESOURCES, MYF(0)); // thd->alloc failed
2539 return (uchar *)buf;
2540 }
2541 uchar *global_value_ptr(THD *thd, const std::string &) override {
2542 assert(false);
2543 return nullptr;
2544 }
2545};
2546#endif
2547
2548/**
2549 Abstract base class for read-only variables (global or session) of
2550 string type where the value is generated by some function. This
2551 needs to be subclassed; the session_value_ptr or global_value_ptr
2552 function should be overridden. Since these variables cannot be
2553 set at command line, they cannot be persisted.
2554*/
2556 public:
2557 Sys_var_charptr_func(const char *name_arg, const char *comment,
2558 flag_enum flag_arg)
2559 : sys_var(&all_sys_vars, name_arg, comment,
2560 READ_ONLY NON_PERSIST flag_arg, 0 /*off*/, NO_CMD_LINE.id,
2561 NO_CMD_LINE.arg_type, SHOW_CHAR, (intptr)0 /*def_val*/,
2562 nullptr /*polylock*/, VARIABLE_NOT_IN_BINLOG,
2563 nullptr /*on_check_func*/, nullptr /*on_update_func*/,
2564 nullptr /*substitute*/, PARSE_NORMAL /*parse_flag*/) {
2565 assert(flag_arg == sys_var::GLOBAL || flag_arg == sys_var::SESSION ||
2566 flag_arg == sys_var::ONLY_SESSION);
2567 }
2568 bool session_update(THD *, set_var *) override {
2569 assert(false);
2570 return true;
2571 }
2572 bool global_update(THD *, set_var *) override {
2573 assert(false);
2574 return true;
2575 }
2576 void session_save_default(THD *, set_var *) override { assert(false); }
2577 void global_save_default(THD *, set_var *) override { assert(false); }
2578 void saved_value_to_string(THD *, set_var *, char *) override {
2579 assert(false);
2580 }
2581 bool do_check(THD *, set_var *) override {
2582 assert(false);
2583 return true;
2584 }
2586 assert(false);
2587 return true;
2588 }
2589 const uchar *session_value_ptr(THD *, THD *, std::string_view) override {
2590 assert(false);
2591 return nullptr;
2592 }
2593 const uchar *global_value_ptr(THD *, std::string_view) override {
2594 assert(false);
2595 return nullptr;
2596 }
2597};
2598
2599/**
2600 Class for @@global.gtid_executed.
2601*/
2603 public:
2604 Sys_var_gtid_executed(const char *name_arg, const char *comment_arg)
2605 : Sys_var_charptr_func(name_arg, comment_arg, GLOBAL) {}
2606
2607 const uchar *global_value_ptr(THD *thd, std::string_view) override {
2608 DBUG_TRACE;
2610 const Gtid_set *gs = gtid_state->get_executed_gtids();
2611 char *buf = (char *)thd->alloc(gs->get_string_length() + 1);
2612 if (buf == nullptr)
2613 my_error(ER_OUT_OF_RESOURCES, MYF(0));
2614 else
2615 gs->to_string(buf);
2617 return (uchar *)buf;
2618 }
2619};
2620
2621/**
2622 Class for @@global.system_time_zone.
2623*/
2625 public:
2626 Sys_var_system_time_zone(const char *name_arg, const char *comment_arg)
2627 : Sys_var_charptr_func(name_arg, comment_arg, GLOBAL) {
2628 is_os_charset = true;
2629 }
2630
2631 const uchar *global_value_ptr(THD *, std::string_view) override {
2632 DBUG_TRACE;
2633 time_t current_time = time(nullptr);
2634 DBUG_EXECUTE_IF("set_cet_before_dst", {
2635 // 1616893190 => Sunday March 28, 2021 01:59:50 (am) (CET)
2636 current_time = 1616893190;
2637 });
2638 DBUG_EXECUTE_IF("set_cet_after_dst", {
2639 // 1616893200 => Sunday March 28, 2021 03:00:00 (am) (CEST)
2640 current_time = 1616893200;
2641 });
2642
2643 struct tm tm_tmp;
2644 localtime_r(&current_time, &tm_tmp);
2645 return (uchar *)(tm_tmp.tm_isdst != 0 ? system_time_zone_dst_on
2647 }
2648};
2649
2650/**
2651 Class for @@session.gtid_purged.
2652*/
2654 public:
2656 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2657 size_t, CMD_LINE getopt, const char *def_val, PolyLock *lock = nullptr,
2658 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2659 on_check_function on_check_func = nullptr,
2660 on_update_function on_update_func = nullptr,
2661 const char *substitute = nullptr, int parse_flag = PARSE_NORMAL)
2662 : sys_var(&all_sys_vars, name_arg, comment, flag_args, off, getopt.id,
2663 getopt.arg_type, SHOW_CHAR, (intptr)def_val, lock,
2664 binlog_status_arg, on_check_func, on_update_func, substitute,
2665 parse_flag) {}
2666
2667 bool session_update(THD *, set_var *) override {
2668 assert(false);
2669 return true;
2670 }
2671
2672 void session_save_default(THD *, set_var *) override { assert(false); }
2673
2674 bool global_update(THD *thd, set_var *var) override;
2675
2676 void global_save_default(THD *, set_var *) override {
2677 /* gtid_purged does not have default value */
2678 my_error(ER_NO_DEFAULT, MYF(0), name.str);
2679 }
2680 void saved_value_to_string(THD *, set_var *, char *) override {
2681 my_error(ER_NO_DEFAULT, MYF(0), name.str);
2682 }
2683
2684 bool do_check(THD *thd, set_var *var) override {
2685 DBUG_TRACE;
2686 char buf[1024];
2688 String *res = var->value->val_str(&str);
2689 if (!res) return true;
2690 var->save_result.string_value.str = thd->strmake(res->ptr(), res->length());
2691 if (!var->save_result.string_value.str) {
2692 my_error(ER_OUT_OF_RESOURCES, MYF(0)); // thd->strmake failed
2693 return true;
2694 }
2695 var->save_result.string_value.length = res->length();
2696 const bool ret =
2697 Gtid_set::is_valid(var->save_result.string_value.str) ? false : true;
2698 DBUG_PRINT("info", ("ret=%d", ret));
2699 return ret;
2700 }
2701
2703 return type != STRING_RESULT;
2704 }
2705
2706 const uchar *global_value_ptr(THD *thd, std::string_view) override {
2707 DBUG_TRACE;
2708 const Gtid_set *gs;
2710 if (opt_bin_log)
2711 gs = gtid_state->get_lost_gtids();
2712 else
2713 /*
2714 When binlog is off, report @@GLOBAL.GTID_PURGED from
2715 executed_gtids, since @@GLOBAL.GTID_PURGED and
2716 @@GLOBAL.GTID_EXECUTED are always same, so we did not
2717 save gtid into lost_gtids for every transaction for
2718 improving performance.
2719 */
2721 char *buf = (char *)thd->alloc(gs->get_string_length() + 1);
2722 if (buf == nullptr)
2723 my_error(ER_OUT_OF_RESOURCES, MYF(0));
2724 else
2725 gs->to_string(buf);
2727 return (uchar *)buf;
2728 }
2729
2730 const uchar *session_value_ptr(THD *, THD *, std::string_view) override {
2731 assert(false);
2732 return nullptr;
2733 }
2734};
2735
2737 public:
2738 Sys_var_gtid_owned(const char *name_arg, const char *comment_arg)
2739 : Sys_var_charptr_func(name_arg, comment_arg, SESSION) {}
2740
2741 public:
2742 const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
2743 std::string_view) override {
2744 DBUG_TRACE;
2745 char *buf = nullptr;
2746 const bool remote = (target_thd != running_thd);
2747
2748 if (target_thd->owned_gtid.sidno == 0)
2749 return (uchar *)running_thd->mem_strdup("");
2750 else if (target_thd->owned_gtid.sidno == THD::OWNED_SIDNO_ANONYMOUS) {
2752 return (uchar *)running_thd->mem_strdup("ANONYMOUS");
2753 } else if (target_thd->owned_gtid.sidno == THD::OWNED_SIDNO_GTID_SET) {
2754#ifdef HAVE_GTID_NEXT_LIST
2755 buf = (char *)running_thd->alloc(
2756 target_thd->owned_gtid_set.get_string_length() + 1);
2757 if (buf) {
2759 target_thd->owned_gtid_set.to_string(buf);
2761 } else
2762 my_error(ER_OUT_OF_RESOURCES, MYF(0));
2763#else
2764 assert(0);
2765#endif
2766 } else {
2767 buf = (char *)running_thd->alloc(Gtid::MAX_TEXT_LENGTH + 1);
2768 if (buf) {
2769 /* Take the lock if accessing another session. */
2771 running_thd->owned_gtid.to_string(target_thd->owned_tsid, buf);
2773 } else
2774 my_error(ER_OUT_OF_RESOURCES, MYF(0));
2775 }
2776 return (uchar *)buf;
2777 }
2778
2779 const uchar *global_value_ptr(THD *thd, std::string_view) override {
2780 DBUG_TRACE;
2781 const Owned_gtids *owned_gtids = gtid_state->get_owned_gtids();
2783 char *buf = (char *)thd->alloc(owned_gtids->get_max_string_length());
2784 if (buf)
2785 owned_gtids->to_string(buf);
2786 else
2787 my_error(ER_OUT_OF_RESOURCES, MYF(0)); // thd->alloc failed
2789 return (uchar *)buf;
2790 }
2791};
2792
2794 public:
2796 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2797 size_t size, CMD_LINE getopt, const char *values[], uint def_val,
2798 PolyLock *lock = nullptr,
2799 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2800 on_check_function on_check_func = nullptr)
2801 : Sys_var_enum(name_arg, comment, flag_args, off, size, getopt, values,
2802 def_val, lock, binlog_status_arg, on_check_func) {}
2803
2804 bool global_update(THD *thd, set_var *var) override;
2805};
2806
2808 public:
2810 const char *name_arg, const char *comment, int flag_args, ptrdiff_t off,
2811 size_t size, CMD_LINE getopt, const ALIAS aliases[],
2812 const uint value_count, uint def_val, uint command_line_no_value,
2813 PolyLock *lock = nullptr,
2814 enum binlog_status_enum binlog_status_arg = VARIABLE_NOT_IN_BINLOG,
2815 on_check_function on_check_func = nullptr)
2816 : Sys_var_multi_enum(name_arg, comment, flag_args, off, size, getopt,
2818 lock, binlog_status_arg, on_check_func) {}
2819
2820 bool global_update(THD *thd, set_var *var) override;
2821};
2822
2824 public:
2825 Sys_var_binlog_encryption(const char *name_arg, const char *comment,
2826 int flag_args, ptrdiff_t off, size_t size,
2827 CMD_LINE getopt, bool def_val, PolyLock *lock,
2828 enum binlog_status_enum binlog_status_arg,
2829 on_check_function on_check_func)
2830 : Sys_var_bool(name_arg, comment, flag_args | PERSIST_AS_READ_ONLY, off,
2831 size, getopt, def_val, lock, binlog_status_arg,
2832 on_check_func) {}
2833 bool global_update(THD *thd, set_var *var) override;
2834};
2835
2839
2840#endif /* SYS_VARS_H_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
void rdlock()
Acquire the read lock.
Definition: rpl_gtid.h:486
void wrlock()
Acquire the write lock.
Definition: rpl_gtid.h:495
void unlock()
Release the lock (whether it is a write or read lock).
Definition: rpl_gtid.h:506
Definition: sql_error.h:226
Represents a set of GTIDs.
Definition: rpl_gtid.h:1557
static bool is_valid(const char *text)
Returns true if the given string is a valid specification of a Gtid_set, false otherwise.
Definition: rpl_gtid_set.cc:607
size_t get_string_length(const String_format *string_format=nullptr) const
Returns the length of the output from to_string.
Definition: rpl_gtid_set.cc:942
size_t to_string(char *buf, bool need_lock=false, const String_format *string_format=nullptr) const
Formats this Gtid_set as a string and saves in a given buffer.
Definition: rpl_gtid_set.cc:807
const Gtid_set * get_executed_gtids() const
Definition: rpl_gtid.h:3378
const Gtid_set * get_lost_gtids() const
Return a pointer to the Gtid_set that contains the lost gtids.
Definition: rpl_gtid.h:3373
const Owned_gtids * get_owned_gtids() const
Return a pointer to the Owned_gtids that contains the owned gtids.
Definition: rpl_gtid.h:3394
int32 get_anonymous_ownership_count()
Return the number of clients that hold anonymous ownership.
Definition: rpl_gtid.h:3038
virtual double val_real()=0
virtual longlong val_int()=0
virtual Item_result result_type() const
Definition: item.h:1448
bool unsigned_flag
Definition: item.h:3714
virtual String * val_str(String *str)=0
Represents the set of GTIDs that are owned by some thread.
Definition: rpl_gtid.h:2587
size_t get_max_string_length() const
Return an upper bound on the length of the string representation of this Owned_gtids.
Definition: rpl_gtid.h:2683
int to_string(char *out) const
Write a string representation of this Owned_gtids to the given buffer.
Definition: rpl_gtid.h:2657
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:52
char * mem_strdup(const char *str)
Definition: sql_class.h:437
LEX_CSTRING external_user() const
Getter method for member m_external_user.
Definition: sql_security_ctx.h:455
LEX_CSTRING proxy_user() const
Getter method for member m_proxy_user.
Definition: sql_security_ctx.cc:1108
bool update(char **var, char *val, size_t val_len)
Frees the old allocated memory, memdup()'s the given val to a new memory address & updates the sessio...
Definition: sys_vars_resource_mgr.cc:73
@ SL_WARNING
Definition: sql_error.h:64
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
LEX_CSTRING lex_cstring() const
Definition: sql_string.h:299
const CHARSET_INFO * charset() const
Definition: sql_string.h:242
static bool needs_conversion(size_t arg_length, const CHARSET_INFO *cs_from, const CHARSET_INFO *cs_to, size_t *offset)
Checks that the source string can be just copied to the destination string without conversion.
Definition: sql_string.h:637
const char * ptr() const
Definition: sql_string.h:251
size_t length() const
Definition: sql_string.h:243
A sys_var that is an alias for another sys_var.
Definition: sys_vars.h:353
bool set_user(const char *usr) override
Definition: sys_vars.h:435
Sys_var_alias(const char *name_arg, sys_var &base_var, const char *deprecation_substitute_arg, sys_var *persisted_alias, bool is_persisted_deprecated)
Special constructor used to implement Sys_var_deprecated alias.
Definition: sys_vars.h:379
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.h:459
const char * get_host() override
Definition: sys_vars.h:437
ulonglong get_max_value() override
Definition: sys_vars.h:410
sys_var & m_base_var
Definition: sys_vars.h:355
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:456
bool is_non_persistent() override
Definition: sys_vars.h:418
void set_timestamp(ulonglong ts) override
Definition: sys_vars.h:444
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view keycache_name) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:464
void cleanup() override
All the cleanup procedures should be performed here.
Definition: sys_vars.h:401
Sys_var_alias(const char *name_arg, sys_var &base_var)
Definition: sys_vars.h:395
ulonglong get_timestamp() const override
Definition: sys_vars.h:439
void set_source(enum_variable_source src) override
Definition: sys_vars.h:429
void update_default(longlong new_def_value) override
Definition: sys_vars.h:405
longlong get_default() override
Definition: sys_vars.h:408
void session_save_default(THD *thd, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:450
void set_timestamp() override
Definition: sys_vars.h:443
sys_var & get_base_var()
Definition: sys_vars.h:399
void set_user_host(THD *thd) override
Definition: sys_vars.h:442
const char * get_user() override
Definition: sys_vars.h:436
bool set_source_name(const char *path) override
Definition: sys_vars.h:432
void set_arg_source(get_opt_arg_source *arg_source) override
Definition: sys_vars.h:412
const uchar * global_value_ptr(THD *thd, std::string_view keycache_name) override
Definition: sys_vars.h:468
void set_is_plugin(bool is_plugin) override
Definition: sys_vars.h:415
bool check_update_type(Item_result type) override
Definition: sys_vars.h:422
void global_save_default(THD *thd, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:453
const char * get_source_name() override
Definition: sys_vars.h:426
ulong get_var_type() override
Returns variable type.
Definition: sys_vars.h:411
void saved_value_to_string(THD *thd, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:419
enum_variable_source get_source() override
Definition: sys_vars.h:425
sys_var_pluginvar * cast_pluginvar() override
downcast for sys_var_pluginvar.
Definition: sys_vars.h:402
longlong get_min_value() override
Definition: sys_vars.h:409
bool set_host(const char *hst) override
Definition: sys_vars.h:438
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:447
Definition: sys_vars.h:2823
Sys_var_binlog_encryption(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, bool def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func)
Definition: sys_vars.h:2825
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:7225
The class for bit variables - a variant of boolean that stores the value in a bit.
Definition: sys_vars.h:1920
Sys_var_bit(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, ulonglong bitmask_arg, bool def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, pre_update_function pre_update_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr)
Definition: sys_vars.h:1931
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1962
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1965
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1968
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1959
void set(uchar *ptr, ulonglong value)
Definition: sys_vars.h:1923
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1951
ulonglong bitmask
Definition: sys_vars.h:1921
bool reverse_semantics
Definition: sys_vars.h:1922
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:1975
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1955
The class for boolean variables - a variant of ENUM variables with the fixed list of values of { OFF ...
Definition: sys_vars.h:686
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:709
Sys_var_bool(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, bool def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:688
void session_save_default(THD *thd, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:713
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:720
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:717
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:704
Abstract base class for read-only variables (global or session) of string type where the value is gen...
Definition: sys_vars.h:2555
bool session_update(THD *, set_var *) override
Definition: sys_vars.h:2568
Sys_var_charptr_func(const char *name_arg, const char *comment, flag_enum flag_arg)
Definition: sys_vars.h:2557
const uchar * session_value_ptr(THD *, THD *, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2589
bool check_update_type(Item_result) override
Definition: sys_vars.h:2585
bool do_check(THD *, set_var *) override
Definition: sys_vars.h:2581
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2578
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:2572
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2593
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2577
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:2576
The class for string variables.
Definition: sys_vars.h:1009
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:1035
bool check_update_type(Item_result type) override
Definition: sys_vars.h:1096
void cleanup() override
All the cleanup procedures should be performed here.
Definition: sys_vars.h:1030
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1092
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1076
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1070
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1059
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:4086
Sys_var_charptr(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, enum charset_enum is_os_charset_arg, const char *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:1011
@session.dbug and @global.dbug variables.
Definition: sys_vars.h:1229
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:1244
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:1268
const uchar * session_value_ptr(THD *running_thd, THD *, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1277
bool check_update_type(Item_result type) override
Definition: sys_vars.h:1288
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:1283
bool session_update(THD *, set_var *var) override
Definition: sys_vars.h:1255
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1263
Sys_var_dbug(const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt, const char *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:1231
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1273
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1269
A deprecated alias for a variable.
Definition: sys_vars.h:552
std::string m_comment
Definition: sys_vars.h:554
Sys_var_deprecated_alias(const char *name_arg, sys_var &base_var)
Definition: sys_vars.h:557
The class for floating point variables.
Definition: sys_vars.h:1392
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1428
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1441
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1424
Sys_var_double(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, double min_val, double max_val, double def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:1394
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1438
bool check_update_type(Item_result type) override
Definition: sys_vars.h:1432
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:1416
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1435
Definition: sys_vars.h:2807
Sys_var_enforce_gtid_consistency(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const ALIAS aliases[], const uint value_count, uint def_val, uint command_line_no_value, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr)
Definition: sys_vars.h:2809
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:4554
A class for @global.binlog_checksum that has a specialized update method.
Definition: sys_vars.h:2395
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:4102
Sys_var_enum_binlog_checksum(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], uint def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func=nullptr)
Definition: sys_vars.h:2397
The class for ENUM variables - variables that take one value from a fixed list of values.
Definition: sys_vars.h:633
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:660
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:656
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:666
Sys_var_enum(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], uint def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:635
const uchar * session_value_ptr(THD *, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:670
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:663
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:675
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:651
Definition: sys_vars.h:1163
const uchar * session_value_ptr(THD *, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1170
Sys_var_external_user(const char *name_arg, const char *comment_arg, enum charset_enum is_os_charset_arg)
Definition: sys_vars.h:1165
The class for flagset variables - a variant of SET that allows in-place editing (turning on/off indiv...
Definition: sys_vars.h:1523
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1587
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1602
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1583
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:1608
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1594
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:1544
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1591
Sys_var_flagset(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], ulonglong def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr)
Definition: sys_vars.h:1525
void saved_value_to_string(THD *thd, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1597
Class for @global.gtid_executed.
Definition: sys_vars.h:2602
Sys_var_gtid_executed(const char *name_arg, const char *comment_arg)
Definition: sys_vars.h:2604
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:2607
Definition: sys_vars.h:2793
Sys_var_gtid_mode(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], uint def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr)
Definition: sys_vars.h:2795
bool global_update(THD *thd, set_var *var) override
This function shall be called whenever the global scope of gtid_mode var is updated.
Definition: sys_vars.cc:4242
Class for gtid_next.
Definition: sys_vars.h:2412
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2441
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2449
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:4136
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2460
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2442
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:2430
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:2434
bool do_check(THD *, set_var *) override
Definition: sys_vars.h:2445
bool check_update_type(Item_result type) override
Definition: sys_vars.h:2446
Sys_var_gtid_next(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:2414
Definition: sys_vars.h:2736
Sys_var_gtid_owned(const char *name_arg, const char *comment_arg)
Definition: sys_vars.h:2738
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:2779
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2742
Class for @session.gtid_purged.
Definition: sys_vars.h:2653
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.cc:6571
const uchar * session_value_ptr(THD *, THD *, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2730
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2676
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:2684
bool check_update_type(Item_result type) override
Definition: sys_vars.h:2702
bool session_update(THD *, set_var *) override
Definition: sys_vars.h:2667
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:2706
Sys_var_gtid_purged(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t, CMD_LINE getopt, const char *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:2655
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:2672
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2680
A subclass of Sys_var_have to return dynamic values.
Definition: sys_vars.h:2162
static enum SHOW_COMP_OPTION dummy_
Definition: sys_vars.h:2191
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:2185
enum SHOW_COMP_OPTION(* func_)(THD *)
Definition: sys_vars.h:2190
Sys_var_have_func(const char *name_arg, const char *comment, enum SHOW_COMP_OPTION(*func)(THD *), const char *substitute=nullptr)
Construct a new variable.
Definition: sys_vars.h:2172
The class for read-only variables that show whether a particular feature is supported by the server.
Definition: sys_vars.h:2109
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:2137
Sys_var_have(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:2111
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:2141
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2148
bool check_update_type(Item_result) override
Definition: sys_vars.h:2152
bool do_check(THD *, set_var *) override
Definition: sys_vars.h:2129
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2142
const uchar * session_value_ptr(THD *, THD *, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2144
bool session_update(THD *, set_var *) override
Definition: sys_vars.h:2133
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2143
Sys_var_integer template is used to generate Sys_var_* classes for variables that represent the value...
Definition: sys_vars.h:197
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:315
Sys_var_integer(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, T min_val, T max_val, T def_val, uint block_size, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:199
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:232
T * max_var_ptr()
Definition: sys_vars.h:328
void session_save_default(THD *thd, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:311
bool check_update_type(Item_result type) override
Definition: sys_vars.h:308
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:300
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:318
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:304
The class for keycache_* variables.
Definition: sys_vars.h:1312
const uchar * global_value_ptr(THD *thd, std::string_view keycache_name) override
Definition: sys_vars.h:1368
Sys_var_keycache(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, ulonglong min_val, ulonglong max_val, ulonglong def_val, uint block_size, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func, keycache_update_function on_update_func, const char *substitute=nullptr)
Definition: sys_vars.h:1316
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1335
keycache_update_function keycache_update
Definition: sys_vars.h:1313
The class for string variables.
Definition: sys_vars.h:1191
Sys_var_lexstring(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, enum charset_enum is_os_charset_arg, const char *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr)
Definition: sys_vars.h:1193
bool global_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1210
The class for the max_user_connections.
Definition: sys_vars.h:1484
Sys_var_max_user_conn(const char *name_arg, const char *comment, int, ptrdiff_t off, size_t size, CMD_LINE getopt, uint min_val, uint max_val, uint def_val, uint block_size, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr)
Definition: sys_vars.h:1486
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view keycache_name) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1497
A variant of enum where:
Definition: sys_vars.h:749
uint command_line_no_value
Definition: sys_vars.h:994
const char * command_line_value
Pointer to the value set by the command line (set by the command line parser, copied to the global va...
Definition: sys_vars.h:993
const uint value_count
The number of allowed numeric values.
Definition: sys_vars.h:983
uint alias_count
The number of elements of aliases (computed in the constructor).
Definition: sys_vars.h:987
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:954
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:928
const ALIAS * aliases
Array of all textual aliases.
Definition: sys_vars.h:985
bool check_update_type(Item_result type) override
Definition: sys_vars.h:913
const uchar * session_value_ptr(THD *, THD *, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:965
bool session_update(THD *, set_var *) override
Definition: sys_vars.h:916
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:941
int find_value(const char *text)
Return the numeric value for a given alias string, or -1 if the string is not a valid alias.
Definition: sys_vars.h:834
bool do_check(THD *, set_var *var) override
Definition: sys_vars.h:885
Sys_var_multi_enum(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const ALIAS aliases_arg[], uint value_count_arg, uint def_val, uint command_line_no_value_arg, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Enumerated type system variable.
Definition: sys_vars.h:801
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:961
const char * fixup_command_line(const char *value_str)
Because of limitations in the command-line parsing library, the value given on the command-line canno...
Definition: sys_vars.h:855
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:976
The class for variables which value is a plugin.
Definition: sys_vars.h:1724
bool check_update_type(Item_result type) override
Definition: sys_vars.h:1823
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:1746
void session_save_default(THD *thd, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1799
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1819
void global_save_default(THD *thd, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1803
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1826
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1791
bool allow_secondary_engine
Definition: sys_vars.h:1726
void do_update(plugin_ref *valptr, plugin_ref newval)
Definition: sys_vars.h:1784
int plugin_type
Definition: sys_vars.h:1725
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1795
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:1833
Sys_var_plugin(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, int plugin_type_arg, const char **def_val, bool allow_secondary_engine, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr)
Definition: sys_vars.h:1729
Definition: sys_vars.h:1125
void session_save_default(THD *, set_var *) override
save the session default value of the variable in var
Definition: sys_vars.h:1148
const uchar * session_value_ptr(THD *, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1156
bool check_update_type(Item_result) override
Definition: sys_vars.h:1153
bool session_update(THD *, set_var *) override
Definition: sys_vars.h:1140
bool do_check(THD *, set_var *) override
Definition: sys_vars.h:1136
Sys_var_proxy_user(const char *name_arg, const char *comment, enum charset_enum is_os_charset_arg)
Definition: sys_vars.h:1127
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:1144
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:1149
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1150
Similar to Sys_var_session_special, but with double storage.
Definition: sys_vars.h:2050
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2084
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:2081
session_special_read_double_function read_func
Definition: sys_vars.h:2054
double(* session_special_read_double_function)(THD *thd)
Definition: sys_vars.h:2052
session_special_update_function update_func
Definition: sys_vars.h:2055
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2085
Sys_var_session_special_double(const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt, double min_val, double max_val, uint, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func, session_special_update_function update_func_arg, session_special_read_double_function read_func_arg, const char *substitute=nullptr)
Definition: sys_vars.h:2058
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:2077
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:2074
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2088
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2093
bool(* session_special_update_function)(THD *thd, set_var *var)
Definition: sys_vars.h:2051
The class for variables that have a special meaning for a session, such as @timestamp or @rnd_seed1,...
Definition: sys_vars.h:1997
bool global_update(THD *, set_var *) override
Definition: sys_vars.h:2025
bool(* session_special_update_function)(THD *thd, set_var *var)
Definition: sys_vars.h:1998
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:2022
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:2029
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2041
Sys_var_session_special(const char *name_arg, const char *comment, int flag_args, CMD_LINE getopt, ulonglong min_val, ulonglong max_val, uint block_size, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func, session_special_update_function update_func_arg, session_special_read_function read_func_arg, const char *substitute=nullptr)
Definition: sys_vars.h:2005
void global_save_default(THD *, set_var *) override
save the global default value of the variable in var
Definition: sys_vars.h:2032
ulonglong(* session_special_read_function)(THD *thd)
Definition: sys_vars.h:1999
session_special_read_function read_func
Definition: sys_vars.h:2001
session_special_update_function update_func
Definition: sys_vars.h:2002
void saved_value_to_string(THD *, set_var *, char *) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2033
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2036
The class for SET variables - variables taking zero or more values from the given list.
Definition: sys_vars.h:1623
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:1680
bool do_check(THD *, set_var *var) override
Definition: sys_vars.h:1643
const uchar * global_value_ptr(THD *thd, std::string_view) override
Definition: sys_vars.h:1705
Sys_var_set(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], ulonglong def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr)
Definition: sys_vars.h:1625
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:1688
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:1691
void saved_value_to_string(THD *thd, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:1694
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:1684
const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:1699
Generic class for variables for storing entities that are internally represented as structures,...
Definition: sys_vars.h:2208
bool check_update_type(Item_result type) override
Definition: sys_vars.h:2256
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2250
const uchar * session_value_ptr(THD *, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2259
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:2235
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:2246
Sys_var_struct(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, void *def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:2210
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:2239
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2264
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:2243
bool do_check(THD *, set_var *) override
Definition: sys_vars.h:2234
Class for @global.system_time_zone.
Definition: sys_vars.h:2624
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2631
Sys_var_system_time_zone(const char *name_arg, const char *comment_arg)
Definition: sys_vars.h:2626
The class for test_flags (core_file for now).
Definition: sys_vars.h:1456
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:1468
bool test_flag_value
Definition: sys_vars.h:1458
uint test_flag_mask
Definition: sys_vars.h:1459
Sys_var_test_flag(const char *name_arg, const char *comment, uint mask)
Definition: sys_vars.h:1462
Class representing the 'transaction_isolation' system variable.
Definition: sys_vars.h:2357
bool session_update(THD *thd, set_var *var) override
This function sets the session variable thd->variables.transaction_isolation to reflect changes to @s...
Definition: sys_vars.cc:5011
Sys_var_transaction_isolation(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, const char *values[], uint def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func)
Definition: sys_vars.h:2359
Class representing the tx_read_only system variable for setting default transaction access mode.
Definition: sys_vars.h:2379
bool session_update(THD *thd, set_var *var) override
This function sets the session variable thd->variables.transaction_read_only to reflect changes to @s...
Definition: sys_vars.cc:5080
Sys_var_transaction_read_only(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, bool def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func)
Definition: sys_vars.h:2381
Helper class for variables that take values from a TYPELIB.
Definition: sys_vars.h:568
Sys_var_typelib(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, CMD_LINE getopt, SHOW_TYPE show_val_type_arg, const char *values[], ulonglong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func, on_update_function on_update_func, const char *substitute, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:573
bool do_check(THD *, set_var *var) override
Definition: sys_vars.h:591
TYPELIB typelib
Definition: sys_vars.h:570
bool check_update_type(Item_result type) override
Definition: sys_vars.h:614
The class for variables that store time zones.
Definition: sys_vars.h:2280
bool do_check(THD *thd, set_var *var) override
Definition: sys_vars.h:2297
bool session_update(THD *thd, set_var *var) override
Definition: sys_vars.h:2311
void global_save_default(THD *, set_var *var) override
save the global default value of the variable in var
Definition: sys_vars.h:2322
Sys_var_tz(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, Time_zone **def_val, PolyLock *lock=nullptr, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, on_check_function on_check_func=nullptr, on_update_function on_update_func=nullptr, const char *substitute=nullptr, int parse_flag=PARSE_NORMAL)
Definition: sys_vars.h:2282
bool check_update_type(Item_result type) override
Definition: sys_vars.h:2346
bool global_update(THD *, set_var *var) override
Definition: sys_vars.h:2315
void session_save_default(THD *, set_var *var) override
save the session default value of the variable in var
Definition: sys_vars.h:2319
const uchar * session_value_ptr(THD *, THD *target_thd, std::string_view) override
A pointer to a value of the variable for SHOW.
Definition: sys_vars.h:2328
void saved_value_to_string(THD *, set_var *var, char *def_val) override
This function converts value stored in save_result to string.
Definition: sys_vars.h:2325
const uchar * global_value_ptr(THD *, std::string_view) override
Definition: sys_vars.h:2342
Definition: sys_vars.h:1101
~Sys_var_version() override=default
const uchar * global_value_ptr(THD *thd, std::string_view keycache_name) override
Definition: sys_vars.h:1111
Sys_var_version(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, enum charset_enum is_os_charset_arg, const char *def_val)
Definition: sys_vars.h:1103
std::string_view get_keycache_name() const
Definition: set_var.h:684
bool is_keycache_var() const
Definition: set_var.h:661
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Gtid owned_gtid
The GTID of the currently owned transaction.
Definition: sql_class.h:3823
static const int OWNED_SIDNO_GTID_SET
Definition: sql_class.h:3824
double double_value
Definition: sql_class.h:2865
static const int OWNED_SIDNO_ANONYMOUS
Definition: sql_class.h:3825
Session_sysvar_resource_manager session_sysvar_res_mgr
Definition: sql_class.h:4505
void * alloc(size_t size)
Definition: sql_lexer_thd.h:50
bool bool_value
Definition: sql_class.h:2861
System_variables variables
Definition: sql_lexer_thd.h:64
mysql::gtid::Tsid owned_tsid
For convenience, this contains the TSID component of the GTID stored in owned_gtid.
Definition: sql_class.h:3831
char * strmake(const char *str, size_t size) const
Definition: sql_lexer_thd.h:52
Security_context * security_context() const
Definition: sql_class.h:1351
bool time_zone_used
Definition: sql_class.h:2825
ulonglong ulonglong_value
Definition: sql_class.h:2864
union THD::@182 sys_var_tmp
const USER_CONN * get_user_connect() const
Definition: sql_class.h:2472
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:49
virtual const String * get_name() const =0
Because of constness of String returned by get_name() time zone name have to be already zeroended to ...
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:983
ulonglong ulonglong_value
for all integer, set, enum sysvars
Definition: set_var.h:989
const System_variable_tracker m_var_tracker
Definition: set_var.h:998
bool is_global_persist()
Definition: set_var.h:1017
Time_zone * time_zone
for Sys_var_tz
Definition: set_var.h:992
Item * value
the expression that provides the new value of the variable
Definition: set_var.h:985
LEX_STRING string_value
for Sys_var_charptr and others
Definition: set_var.h:993
union set_var::@177 save_result
Resolver of the variable at the left hand side of the assignment.
plugin_ref plugin
for Sys_var_plugin
Definition: set_var.h:991
const void * ptr
for Sys_var_struct
Definition: set_var.h:994
double double_value
for Sys_var_double
Definition: set_var.h:990
Definition: sql_plugin_var.h:211
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:107
virtual bool global_update(THD *thd, set_var *var)=0
virtual bool set_source_name(const char *path)
Definition: set_var.h:243
my_option option
min, max, default values are stored here
Definition: set_var.h:178
my_option * get_option()
Definition: set_var.h:257
bool(* on_update_function)(sys_var *self, THD *thd, enum_var_type type)
Definition: set_var.h:172
virtual void session_save_default(THD *thd, set_var *var)=0
save the session default value of the variable in var
LEX_CSTRING name
Definition: set_var.h:110
virtual void set_arg_source(get_opt_arg_source *)
Definition: set_var.h:236
virtual const char * get_host()
Definition: set_var.h:251
virtual ulonglong get_max_value()
Definition: set_var.h:229
virtual void set_user_host(THD *thd)
Definition: set_var.cc:458
uchar * global_var_ptr()
Definition: set_var.cc:405
enum sys_var::binlog_status_enum binlog_status
Global system variable attributes.
uchar * session_var_ptr(THD *thd)
A pointer to a storage area of the variable, to the raw data.
Definition: set_var.cc:401
flag_enum
Definition: set_var.h:128
@ SESSION
Definition: set_var.h:130
@ GLOBAL
Definition: set_var.h:129
@ READONLY
Definition: set_var.h:133
@ ALLOCATED
Definition: set_var.h:134
@ NOTPERSIST
Definition: set_var.h:137
@ PERSIST_AS_READ_ONLY
There can be some variables which needs to be set before plugin is loaded.
Definition: set_var.h:148
@ ONLY_SESSION
Definition: set_var.h:131
virtual bool do_check(THD *thd, set_var *var)=0
virtual bool check_update_type(Item_result type)=0
virtual const char * get_user()
Definition: set_var.h:250
virtual void cleanup()
All the cleanup procedures should be performed here.
Definition: set_var.h:212
virtual longlong get_min_value()
Definition: set_var.h:228
virtual void set_is_plugin(bool)
Definition: set_var.h:237
binlog_status_enum
Enumeration type to indicate for a system variable whether it will be written to the binlog or not.
Definition: set_var.h:161
@ VARIABLE_NOT_IN_BINLOG
Definition: set_var.h:162
virtual void saved_value_to_string(THD *thd, set_var *var, char *def_val)=0
This function converts value stored in save_result to string.
bool is_os_charset
true if the value is in character_set_filesystem
Definition: set_var.h:189
ptrdiff_t offset
offset to the value from global_system_variables
Definition: set_var.h:180
virtual bool set_user(const char *usr)
Definition: set_var.h:247
bool(* on_check_function)(sys_var *self, THD *thd, set_var *var)
Definition: set_var.h:170
virtual enum_variable_source get_source()
Definition: set_var.h:238
virtual void global_save_default(THD *thd, set_var *var)=0
save the global default value of the variable in var
virtual const uchar * global_value_ptr(THD *thd, std::string_view keycache_name)
Definition: set_var.cc:397
on_check_function on_check
Definition: set_var.h:181
const CHARSET_INFO * charset(THD *thd)
Definition: set_var.cc:593
virtual ulong get_var_type()
Returns variable type.
Definition: set_var.h:235
virtual const char * get_source_name()
Definition: set_var.h:239
pre_update_function pre_update
Pointer to function to be invoked before updating system variable (but after calling on_check hook),...
Definition: set_var.h:186
int scope() const
Definition: set_var.h:278
virtual void set_timestamp()
Definition: set_var.h:258
const SHOW_TYPE show_val_type
what value_ptr() returns for sql_show.cc
Definition: set_var.h:177
on_update_function on_update
Definition: set_var.h:187
int flags
or'ed flag_enum values
Definition: set_var.h:175
static const int PARSE_NORMAL
Definition: set_var.h:156
virtual const uchar * session_value_ptr(THD *running_thd, THD *target_thd, std::string_view keycache_name)
A pointer to a value of the variable for SHOW.
Definition: set_var.cc:392
virtual void update_default(longlong new_def_value)
Definition: set_var.h:224
virtual bool set_host(const char *hst)
Definition: set_var.h:252
PolyLock * guard
second lock that protects the variable
Definition: set_var.h:179
virtual longlong get_default()
Definition: set_var.h:227
virtual bool is_non_persistent()
Definition: set_var.h:260
virtual sys_var_pluginvar * cast_pluginvar()
downcast for sys_var_pluginvar.
Definition: set_var.h:217
const char *const deprecation_substitute
Definition: set_var.h:188
virtual ulonglong get_timestamp() const
Definition: set_var.h:255
bool(* pre_update_function)(sys_var *self, THD *thd, set_var *var)
Definition: set_var.h:171
bool is_readonly() const
Definition: set_var.h:280
virtual bool session_update(THD *thd, set_var *var)=0
int m_parse_flag
either PARSE_EARLY or PARSE_NORMAL.
Definition: set_var.h:176
virtual void set_source(enum_variable_source src)
Definition: set_var.h:240
static char buf[MAX_BUF]
Definition: conf_to_src.cc:74
MYSQL_STRINGS_EXPORT size_t my_fcvt(double x, int precision, char *to, bool *error)
Converts a given floating point number to a zero-terminated string representation using the 'f' forma...
Definition: dtoa.cc:202
#define MAX_TIME_ZONE_NAME_LENGTH
Maximum length of time zone name that we support (Time zone name is char(64) in db).
Definition: binlog_event.h:122
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
ALWAYS_INLINE const char * base_name(const char *A)
Definition: my_sys.h:709
#define MYSQL_STORAGE_ENGINE_PLUGIN
Definition: plugin.h:116
MYSQL_STRINGS_EXPORT char * longlong10_to_str(int64_t val, char *dst, int radix)
Converts a 64-bit integer to its string representation in decimal notation.
Definition: int2str.cc:99
#define T
Definition: jit_executor_value.cc:373
Key cache variable structures.
KEY_CACHE * dflt_key_cache
Definition: keycache.h:135
KEY_CACHE * create_key_cache(std::string_view name)
Create a MyISAM Multiple Key Cache.
Definition: keycaches.cc:76
KEY_CACHE * get_key_cache(std::string_view cache_name)
Resolve a MyISAM Multiple Key Cache by name.
Definition: keycaches.cc:68
KEY_CACHE zero_key_cache
@nonexistent_cache.param->value_ptr() points here
Definition: keycaches.cc:66
static std::string to_string(const LEX_STRING &str)
Definition: lex_string.h:50
#define comment
Definition: lexyy.cc:959
@ READ_ONLY
The opened file can be only read.
A better implementation of the UNIX ctype(3) library.
int my_strcasecmp(const CHARSET_INFO *cs, const char *s1, const char *s2)
Definition: m_ctype.h:651
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_latin1
Definition: ctype-latin1.cc:365
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1566
static mi_bit_type mask[]
Definition: mi_packrec.cc:141
This file includes constants used by all storage engines.
Header for compiler-dependent features.
#define DBUG_SET_INITIAL(a1)
Definition: my_dbug.h:192
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_EXPLAIN(buf, len)
Definition: my_dbug.h:199
#define DBUG_SET(a1)
Definition: my_dbug.h:191
#define DBUG_EXPLAIN_INITIAL(buf, len)
Definition: my_dbug.h:200
#define DBUG_POP()
Definition: my_dbug.h:190
#define DBUG_TRACE
Definition: my_dbug.h:146
#define GET_NO_ARG
Definition: my_getopt.h:44
get_opt_arg_type
Enumeration of the my_option::arg_type attributes.
Definition: my_getopt.h:81
@ OPT_ARG
Definition: my_getopt.h:81
@ NO_ARG
Definition: my_getopt.h:81
#define GET_STR
Definition: my_getopt.h:52
#define GET_DOUBLE
Definition: my_getopt.h:57
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, bool *fix)
Definition: my_getopt.cc:1262
#define GET_SET
Definition: my_getopt.h:56
#define GET_ENUM
Definition: my_getopt.h:55
#define GET_FLAGSET
Definition: my_getopt.h:58
#define GET_STR_ALLOC
Definition: my_getopt.h:53
ulonglong getopt_double2ulonglong(double)
Returns an ulonglong value containing a raw representation of the given double value.
Definition: my_getopt.cc:160
double getopt_double_limit_value(double num, const struct my_option *optp, bool *fix)
Definition: my_getopt.cc:1302
double getopt_ulonglong2double(ulonglong)
Returns the double value which corresponds to the given raw representation.
Definition: my_getopt.cc:171
ulonglong max_of_int_range(int var_type)
Maximum possible value for an integer GET_* variable type.
Definition: my_getopt.cc:1163
#define GET_ASK_ADDR
Definition: my_getopt.h:71
#define GET_BOOL
Definition: my_getopt.h:45
longlong getopt_ll_limit_value(longlong, const struct my_option *, bool *fix)
Definition: my_getopt.cc:1190
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
intptr_t intptr
Definition: my_inttypes.h:70
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
uint test_flags
Definition: mysqld.cc:1350
const char * show_comp_option_name[]
Definition: mysqld.cc:1060
char system_time_zone_dst_off[30]
Definition: mysqld.cc:1500
bool opt_bin_log
Definition: mysqld.cc:1212
Tsid_map * global_tsid_map
Definition: mysqld.cc:1852
Gtid_state * gtid_state
Global state of GTIDs.
Definition: mysqld.cc:1853
Checkable_rwlock * global_tsid_lock
Protects Gtid_state. See comment above gtid_state for details.
Definition: mysqld.cc:1851
struct System_variables max_system_variables
Definition: mysqld.cc:1560
char system_time_zone_dst_on[30]
Definition: mysqld.cc:1500
static char * path
Definition: mysqldump.cc:150
arg_type
Definition: mysqltest.cc:1130
int find_set(REP_SETS *sets, REP_SET *find)
Definition: mysqltest.cc:11421
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1084
Definition: buf0block_hint.cc:30
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
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:905
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
size_t size(const char *const c)
Definition: base64.h:46
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
required string type
Definition: replication_group_member_actions.proto:34
bool throw_bounds_warning(THD *thd, const char *name, bool fixed, bool is_unsigned, longlong v)
Throw warning (error in STRICT mode) if value for variable needed bounding.
Definition: set_var.cc:554
"public" interface to sys_var - server configuration variables.
enum enum_mysql_show_type SHOW_TYPE
Definition: set_var.h:75
Declarations for the Debug Sync Facility.
plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, bool is_temp_table)
Return the storage engine handlerton for the supplied name.
Definition: handler.cc:413
#define HTON_IS_SECONDARY_ENGINE
Engine is a secondary storage engine.
Definition: handler.h:3119
File containing constants that can be used throughout the server.
SHOW_COMP_OPTION
Definition: sql_const.h:230
constexpr const size_t STRING_BUFFER_USUAL_SIZE
Definition: sql_const.h:126
void push_warning_printf(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *format,...)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:690
void plugin_unlock(THD *thd, plugin_ref plugin)
Definition: sql_plugin.cc:1267
#define my_plugin_lock_by_name(A, B, C)
Definition: sql_plugin.h:175
#define my_plugin_lock(A, B)
Definition: sql_plugin.h:177
LEX_CSTRING * plugin_name(st_plugin_int **ref)
Definition: sql_plugin_ref.h:95
Our own string classes, used pervasively throughout the executor.
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.
Definition: sql_string.cc:1131
@ SHOW_DOUBLE
Definition: status_variables_bits.h:42
@ SHOW_CHAR_PTR
Definition: status_variables_bits.h:39
@ SHOW_MY_BOOL
Definition: status_variables_bits.h:52
@ SHOW_CHAR
Definition: status_variables_bits.h:38
@ SHOW_LEX_STRING
Definition: status_variables_bits.h:57
char * set_to_string(THD *thd, LEX_STRING *result, ulonglong set, const char *lib[], bool quoted)
Definition: strfunc.cc:270
char * flagset_to_string(THD *thd, LEX_STRING *result, ulonglong set, const char *lib[])
Definition: strfunc.cc:303
A small wrapper class to pass getopt arguments as a pair to the Sys_var_* constructors.
Definition: sys_vars.h:175
int id
Definition: sys_vars.h:176
CMD_LINE(enum get_opt_arg_type getopt_arg_type, int getopt_id=0)
Definition: sys_vars.h:178
enum get_opt_arg_type arg_type
Definition: sys_vars.h:177
Holds information about a Gtid_set.
Definition: rpl_gtid.h:2540
Gtid_set * get_gtid_set() const
Return NULL if this is NULL, otherwise return the Gtid_set.
Definition: rpl_gtid.h:2546
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3999
static const int MAX_TEXT_LENGTH
Definition: rpl_gtid.h:4126
static const int MAX_TEXT_LENGTH
The maximal length of the textual representation of a TSID, not including the terminating '\0'.
Definition: rpl_gtid.h:1138
rpl_sidno sidno
SIDNO of this Gtid.
Definition: rpl_gtid.h:1105
int to_string(const Tsid &tsid, char *buf) const
Convert a Gtid to a string.
Definition: rpl_gtid_misc.cc:214
Definition: keycache.h:73
bool in_init
Definition: keycache.h:131
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35
char * str
Definition: mysql_lex_string.h:36
size_t length
Definition: mysql_lex_string.h:37
Definition: sys_vars.h:751
uint number
Definition: sys_vars.h:753
const char * alias
Definition: sys_vars.h:752
Definition: system_variables.h:203
Definition: typelib.h:35
const char ** type_names
Definition: typelib.h:38
size_t count
Definition: typelib.h:36
const char * name
Definition: typelib.h:37
unsigned int * type_lengths
Definition: typelib.h:39
Definition: my_getopt.h:83
const char * comment
option comment, for autom.
Definition: my_getopt.h:113
longlong min_value
Min allowed value (for numbers)
Definition: my_getopt.h:123
ulonglong max_value
Max allowed value (for numbers)
Definition: my_getopt.h:124
longlong def_value
Default value.
Definition: my_getopt.h:122
long block_size
Value should be a mult.
Definition: my_getopt.h:127
const char * name
Name of the option.
Definition: my_getopt.h:94
void * u_max_value
The user def.
Definition: my_getopt.h:118
ulong var_type
GET_BOOL, GET_ULL, etc.
Definition: my_getopt.h:120
TYPELIB * typelib
Pointer to possible values.
Definition: my_getopt.h:119
void * value
A pointer to the variable value.
Definition: my_getopt.h:117
Definition: sql_plugin_ref.h:45
Definition: set_var.h:82
Definition: sql_connect.h:70
USER_RESOURCES user_resources
Definition: sql_connect.h:94
uint user_conn
Definition: sql_connect.h:52
#define NO_CMD_LINE
Definition: sys_vars.h:128
Sys_var_integer< ulong, GET_ULONG, SHOW_LONG, false > Sys_var_ulong
Definition: sys_vars.h:338
#define keycache_var_ptr(KC, OFF)
Definition: sys_vars.h:1296
#define keycache_var(KC, OFF)
Definition: sys_vars.h:1297
charset_enum
Definition: sys_vars.h:164
@ IN_SYSTEM_CHARSET
Definition: sys_vars.h:164
@ IN_FS_CHARSET
Definition: sys_vars.h:164
#define NON_PERSIST
Definition: sys_vars.h:146
#define MAX_SET(X)
Definition: sys_vars.h:1507
Sys_var_integer< uint, GET_UINT, SHOW_INT, false > Sys_var_uint
Definition: sys_vars.h:337
sys_var_chain all_sys_vars
Definition: set_var.cc:142
Sys_var_integer< int32, GET_UINT, SHOW_INT, false > Sys_var_int32
Definition: sys_vars.h:336
constexpr const unsigned long MAX_CONNECTIONS_DEFAULT
Maximum number of connections default value.
Definition: sys_vars.h:110
void update_parser_max_mem_size()
Definition: sys_vars.cc:3225
const char * fixup_enforce_gtid_consistency_command_line(char *value_arg)
Definition: sys_vars.cc:6419
#define session_var(THD, TYPE)
Definition: sys_vars.h:157
void update_temptable_max_ram_default()
Definition: sys_vars.cc:5184
Sys_var_integer< long, GET_LONG, SHOW_SIGNED_LONG, true > Sys_var_long
Definition: sys_vars.h:343
constexpr const unsigned long TABLE_DEF_CACHE_DEFAULT
Definition: sys_vars.h:104
#define GLOBAL_VAR(X)
Definition: sys_vars.h:119
bool(* keycache_update_function)(THD *, KEY_CACHE *, ptrdiff_t, ulonglong)
Definition: sys_vars.h:1298
void update_optimizer_switch()
Definition: sys_vars.cc:3235
static const char * bool_values[3]
Definition: sys_vars.h:166
constexpr const unsigned long TABLE_OPEN_CACHE_DEFAULT
Definition: sys_vars.h:103
#define global_var(TYPE)
Definition: sys_vars.h:158
Sys_var_integer< ha_rows, GET_HA_ROWS, SHOW_HA_ROWS, false > Sys_var_harows
Definition: sys_vars.h:340
Sys_var_integer< ulonglong, GET_ULL, SHOW_LONGLONG, false > Sys_var_ulonglong
Definition: sys_vars.h:342
"protected" interface to sys_var - server configuration variables.
enum_variable_source
This enum values define how system variables are set.
Definition: system_variable_source_type.h:33
int find_type(const char *x, const TYPELIB *typelib, unsigned int flags)
uint64_t find_set_from_flags(const TYPELIB *lib, int default_name, uint64_t cur_set, uint64_t default_set, const char *str, unsigned int length, const char **err_pos, unsigned int *err_len)
Time_zone * my_tz_find(const int64 displacement)
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:41
@ DECIMAL_RESULT
not valid for UDFs
Definition: udf_registration_types.h:45
@ REAL_RESULT
char *
Definition: udf_registration_types.h:42
@ INT_RESULT
double
Definition: udf_registration_types.h:43
Definition: dtoa.cc:595
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510