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