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