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