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