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