MySQL  8.0.27
Source Code Documentation
set_var.h
Go to the documentation of this file.
1 #ifndef SET_VAR_INCLUDED
2 #define SET_VAR_INCLUDED
3 /* Copyright (c) 2002, 2021, Oracle and/or its affiliates.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License, version 2.0,
7  as published by the Free Software Foundation.
8 
9  This program is also distributed with certain software (including
10  but not limited to OpenSSL) that is licensed under separate terms,
11  as designated in a particular file or component or in included license
12  documentation. The authors of MySQL hereby grant you an additional
13  permission to link the program and your derivative works with the
14  separately licensed software that they have included with MySQL.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License, version 2.0, for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24 
25 /**
26  @file
27  "public" interface to sys_var - server configuration variables.
28 */
29 
30 #include "my_config.h"
31 
32 #include <stddef.h>
33 #include <string.h>
34 #include <sys/types.h>
35 #include <string>
36 #include <vector>
37 
38 #include "lex_string.h"
39 #include "m_ctype.h"
40 #include "my_getopt.h" // get_opt_arg_type
41 #include "my_hostname.h" // HOSTNAME_LENGTH
42 #include "my_inttypes.h"
43 #include "my_sys.h"
44 #include "my_systime.h" // my_micro_time()
46 #include "mysql/status_var.h"
48 #include "mysql_com.h" // Item_result
49 #include "prealloced_array.h" // Prealloced_array
50 #include "sql/sql_const.h" // SHOW_COMP_OPTION
51 #include "sql/sql_plugin_ref.h" // plugin_ref
52 #include "typelib.h" // TYPELIB
53 
54 class Item;
56 class PolyLock;
57 class String;
58 class THD;
59 class Time_zone;
60 class set_var;
61 class sys_var;
62 class sys_var_pluginvar;
63 struct LEX_USER;
64 template <class Key, class Value>
66 
68 typedef enum enum_mysql_show_type SHOW_TYPE;
70 template <class T>
71 class List;
72 
73 extern TYPELIB bool_typelib;
74 
75 /* Number of system variable elements to preallocate. */
76 #define SHOW_VAR_PREALLOC 200
78 
79 struct sys_var_chain {
82 };
83 
86 
87 enum enum_var_type : int {
93 };
94 
95 /**
96  A class representing one system variable - that is something
97  that can be accessed as @@global.variable_name or @@session.variable_name,
98  visible in SHOW xxx VARIABLES and in INFORMATION_SCHEMA.xxx_VARIABLES,
99  optionally it can be assigned to, optionally it can have a command-line
100  counterpart with the same name.
101 */
102 class sys_var {
103  public:
106  /**
107  If the variable has an alias in the persisted variables file, this
108  should point to it. This has the following consequences:
109  - A SET PERSIST statement that sets either of the variables will
110  persist both variables in the file.
111  - When loading persisted variables, an occurrence of any one of
112  the variables will initialize both variables.
113  */
115  /**
116  If m_persist_alias is set, and the current variable is deprecated
117  and m_persist_alias is the recommended substitute, then this flag
118  should be set to true. This has the consequence that the code
119  that loads persisted variables will generate a warning if it
120  encounters this variable but does not encounter the alias.
121  */
123  enum flag_enum {
124  GLOBAL = 0x0001,
125  SESSION = 0x0002,
126  ONLY_SESSION = 0x0004,
127  SCOPE_MASK = 0x03FF, // 1023
128  READONLY = 0x0400, // 1024
129  ALLOCATED = 0x0800, // 2048
130  INVISIBLE = 0x1000, // 4096
131  TRI_LEVEL = 0x2000, // 8192 - default is neither GLOBAL nor SESSION
132  NOTPERSIST = 0x4000,
133  HINT_UPDATEABLE = 0x8000, // Variable is updateable using SET_VAR hint
134  /**
135  There can be some variables which needs to be set before plugin is loaded.
136  ex: binlog_checksum needs to be set before GR plugin is loaded.
137  Also, there are some variables which needs to be set before some server
138  internal component initialization.
139  ex: binlog_encryption needs to be set before binary and relay log
140  files generation.
141  */
142 
143  PERSIST_AS_READ_ONLY = 0x10000
144  };
145  static const int PARSE_EARLY = 1;
146  static const int PARSE_NORMAL = 2;
147  /**
148  Enumeration type to indicate for a system variable whether
149  it will be written to the binlog or not.
150  */
155 
156  protected:
157  typedef bool (*on_check_function)(sys_var *self, THD *thd, set_var *var);
158  typedef bool (*pre_update_function)(sys_var *self, THD *thd, set_var *var);
159  typedef bool (*on_update_function)(sys_var *self, THD *thd,
161 
162  int flags; ///< or'ed flag_enum values
163  int m_parse_flag; ///< either PARSE_EARLY or PARSE_NORMAL.
164  const SHOW_TYPE show_val_type; ///< what value_ptr() returns for sql_show.cc
165  my_option option; ///< min, max, default values are stored here
166  PolyLock *guard; ///< *second* lock that protects the variable
167  ptrdiff_t offset; ///< offset to the value from global_system_variables
169  /**
170  Pointer to function to be invoked before updating system variable (but
171  after calling on_check hook), while we do not hold any locks yet.
172  */
175  const char *const deprecation_substitute;
176  bool is_os_charset; ///< true if the value is in character_set_filesystem
177  struct get_opt_arg_source source;
178  char user[USERNAME_CHAR_LENGTH + 1]; /* which user has set this variable */
179  char host[HOSTNAME_LENGTH + 1]; /* host on which this variable is set */
180  ulonglong timestamp; /* represents when this variable was set */
181 
182  public:
183  sys_var(sys_var_chain *chain, const char *name_arg, const char *comment,
184  int flag_args, ptrdiff_t off, int getopt_id,
185  enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg,
186  longlong def_val, PolyLock *lock,
187  enum binlog_status_enum binlog_status_arg,
188  on_check_function on_check_func, on_update_function on_update_func,
189  const char *substitute, int parse_flag,
190  sys_var *persisted_alias = nullptr,
191  bool is_persisted_deprecated = false);
192 
193  virtual ~sys_var() = default;
194 
196  /**
197  All the cleanup procedures should be performed here
198  */
199  virtual void cleanup() {}
200  /**
201  downcast for sys_var_pluginvar. Returns this if it's an instance
202  of sys_var_pluginvar, and 0 otherwise.
203  */
204  virtual sys_var_pluginvar *cast_pluginvar() { return nullptr; }
205 
206  bool check(THD *thd, set_var *var);
207  const uchar *value_ptr(THD *running_thd, THD *target_thd, enum_var_type type,
208  LEX_STRING *base);
209  const uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
210  virtual void update_default(longlong new_def_value) {
211  option.def_value = new_def_value;
212  }
213  virtual longlong get_default() { return option.def_value; }
214  virtual longlong get_min_value() { return option.min_value; }
215  virtual ulonglong get_max_value() { return option.max_value; }
216  /**
217  Returns variable type.
218 
219  @return variable type
220  */
221  virtual ulong get_var_type() { return (option.var_type & GET_TYPE_MASK); }
223  virtual void set_is_plugin(bool) {}
225  virtual const char *get_source_name() { return source.m_path_name; }
226  virtual void set_source(enum_variable_source src) {
227  option.arg_source->m_source = src;
228  }
229  virtual bool set_source_name(const char *path) {
231  sizeof(option.arg_source->m_path_name));
232  }
233  virtual bool set_user(const char *usr) {
234  return set_and_truncate(user, usr, sizeof(user));
235  }
236  virtual const char *get_user() { return user; }
237  virtual const char *get_host() { return host; }
238  virtual bool set_host(const char *hst) {
239  return set_and_truncate(host, hst, sizeof(host));
240  }
241  virtual ulonglong get_timestamp() const { return timestamp; }
242  virtual void set_user_host(THD *thd);
243  my_option *get_option() { return &option; }
244  virtual void set_timestamp() { timestamp = my_micro_time(); }
245  virtual void set_timestamp(ulonglong ts) { timestamp = ts; }
246  virtual bool is_non_persistent() { return flags & NOTPERSIST; }
247 
248  /**
249  Update the system variable with the default value from either
250  session or global scope. The default value is stored in the
251  'var' argument. Return false when successful.
252  */
253  bool set_default(THD *thd, set_var *var);
254  bool update(THD *thd, set_var *var);
255 
256  /**
257  This function converts value stored in save_result to string. This
258  function must ba called after calling save_default() as save_default() will
259  store default value to save_result.
260  */
261  virtual void saved_value_to_string(THD *thd, set_var *var, char *def_val) = 0;
262 
264  int scope() const { return flags & SCOPE_MASK; }
265  const CHARSET_INFO *charset(THD *thd);
266  bool is_readonly() const { return flags & READONLY; }
267  bool not_visible() const { return flags & INVISIBLE; }
268  bool is_trilevel() const { return flags & TRI_LEVEL; }
269  bool is_persist_readonly() const { return flags & PERSIST_AS_READ_ONLY; }
270  /**
271  Check if the variable can be set using SET_VAR hint.
272 
273  @return true if the variable can be set using SET_VAR hint,
274  false otherwise.
275  */
276  bool is_hint_updateable() const { return flags & HINT_UPDATEABLE; }
277  /**
278  the following is only true for keycache variables,
279  that support the syntax @@keycache_name.variable_name
280  */
281  bool is_struct() { return option.var_type & GET_ASK_ADDR; }
282  /*
283  Indicates whether this system variable is written to the binlog or not.
284 
285  Variables are written to the binlog as part of "status_vars" in
286  Query_log_event, as an Intvar_log_event, or a Rand_log_event.
287 
288  @return true if the variable is written to the binlog, false otherwise.
289  */
292  }
293  virtual bool check_update_type(Item_result type) = 0;
294 
295  /**
296  Return true for success if:
297  Global query and variable scope is GLOBAL or SESSION, or
298  Session query and variable scope is SESSION or ONLY_SESSION.
299  */
300  bool check_scope(enum_var_type query_type) {
301  switch (query_type) {
302  case OPT_PERSIST:
303  case OPT_PERSIST_ONLY:
304  case OPT_GLOBAL:
305  return scope() & (GLOBAL | SESSION);
306  case OPT_SESSION:
307  return scope() & (SESSION | ONLY_SESSION);
308  case OPT_DEFAULT:
309  return scope() & (SESSION | ONLY_SESSION);
310  }
311  return false;
312  }
314  return (type == OPT_GLOBAL || type == OPT_PERSIST ||
316  }
317 
318  /**
319  Return true if settable at the command line
320  */
321  bool is_settable_at_command_line() { return option.id != -1; }
322 
323  bool register_option(std::vector<my_option> *array, int parse_flags) {
324  return is_settable_at_command_line() && (m_parse_flag & parse_flags) &&
325  (array->push_back(option), false);
326  }
327  void do_deprecated_warning(THD *thd);
328  /**
329  Create item from system variable value.
330 
331  @param thd pointer to THD object
332 
333  @return pointer to Item object or NULL if it's
334  impossible to obtain the value.
335  */
336  Item *copy_value(THD *thd);
337 
338  void save_default(THD *thd, set_var *var) { global_save_default(thd, var); }
339 
340  private:
341  /**
342  Like strncpy, but ensures the destination is '\0'-terminated. Is
343  also safe to call if dst==string (but not if they overlap in any
344  other way).
345 
346  @param dst Target string
347  @param string Source string
348  @param sizeof_dst Size of the dst buffer
349  @retval false The entire string was copied to dst
350  @retval true strlen(string) was bigger than or equal to sizeof_dst, so
351  dst contains only the sizeof_dst-1 first characters of string.
352  */
353  inline static bool set_and_truncate(char *dst, const char *string,
354  size_t sizeof_dst) {
355  if (dst == string) return false;
356  size_t string_length = strlen(string), length;
357  length = std::min(sizeof_dst - 1, string_length);
358  memcpy(dst, string, length);
359  dst[length] = 0;
360  return length < string_length; // truncated
361  }
362 
363  private:
364  virtual bool do_check(THD *thd, set_var *var) = 0;
365  /**
366  save the session default value of the variable in var
367  */
368  virtual void session_save_default(THD *thd, set_var *var) = 0;
369  /**
370  save the global default value of the variable in var
371  */
372  virtual void global_save_default(THD *thd, set_var *var) = 0;
373  virtual bool session_update(THD *thd, set_var *var) = 0;
374  virtual bool global_update(THD *thd, set_var *var) = 0;
375 
376  protected:
377  /**
378  A pointer to a value of the variable for SHOW.
379  It must be of show_val_type type (bool for SHOW_BOOL, int for SHOW_INT,
380  longlong for SHOW_LONGLONG, etc).
381  */
382  virtual const uchar *session_value_ptr(THD *running_thd, THD *target_thd,
383  LEX_STRING *base);
384  virtual const uchar *global_value_ptr(THD *thd, LEX_STRING *base);
385 
386  /**
387  A pointer to a storage area of the variable, to the raw data.
388  Typically it's the same as session_value_ptr(), but it's different,
389  for example, for ENUM, that is printed as a string, but stored as a number.
390  */
391  uchar *session_var_ptr(THD *thd);
392 
394 
395  friend class Sys_var_alias;
396 };
397 
399  public:
400  Sys_var_tracker(sys_var *var);
401 
403 
404  bool operator==(const Sys_var_tracker &x) const {
405  return m_var && m_var == x.m_var;
406  }
407 
408  LEX_CSTRING get_var_name() const { return m_name; }
409  bool is_sys_var(sys_var *x) const { return m_var == x; }
410  bool is_plugin_var() const { return m_is_dynamic; }
411 
412  private:
413  const bool m_is_dynamic; ///< true if dynamic variable
414  const LEX_CSTRING m_name; ///< variable name
415 
416  sys_var *m_var; ///< variable pointer
417 };
418 
419 /****************************************************************************
420  Classes for parsing of the SET command
421 ****************************************************************************/
422 
423 /**
424  A base class for everything that can be set with SET command.
425  It's similar to Items, an instance of this is created by the parser
426  for every assigmnent in SET (or elsewhere, e.g. in SELECT).
427 */
429  public:
430  set_var_base() = default;
431  virtual ~set_var_base() = default;
432  virtual int resolve(THD *thd) = 0; ///< Check privileges & fix_fields
433  virtual int check(THD *thd) = 0; ///< Evaluate the expression
434  virtual int update(THD *thd) = 0; ///< Set the value
435  virtual void print(const THD *thd, String *str) = 0; ///< To self-print
436 
437  /**
438  @returns whether this variable is @@@@optimizer_trace.
439  */
440  virtual bool is_var_optimizer_trace() const { return false; }
441  virtual void cleanup() {}
442 
443  /**
444  Used only by prepared statements to resolve and check. No locking of tables
445  between the two phases.
446  */
447  virtual int light_check(THD *thd) { return (resolve(thd) || check(thd)); }
448 };
449 
450 /**
451  set_var_base descendant for assignments to the system variables.
452 */
453 class set_var : public set_var_base {
454  public:
455  sys_var *var; ///< system variable to be updated
456  Item *value; ///< the expression that provides the new value of the variable
458  union ///< temp storage to hold a value between sys_var::check and ::update
459  {
460  ulonglong ulonglong_value; ///< for all integer, set, enum sysvars
461  double double_value; ///< for Sys_var_double
462  plugin_ref plugin; ///< for Sys_var_plugin
463  Time_zone *time_zone; ///< for Sys_var_tz
464  LEX_STRING string_value; ///< for Sys_var_charptr and others
465  const void *ptr; ///< for Sys_var_struct
468  base; /**< for structured variables, like keycache_name.variable_name */
469 
470  private:
472 
473  public:
474  set_var(enum_var_type type_arg, sys_var *var_arg, LEX_CSTRING base_name_arg,
475  Item *value_arg);
476 
477  int resolve(THD *thd) override;
478  int check(THD *thd) override;
479  int update(THD *thd) override;
481  int light_check(THD *thd) override;
482  /**
483  Print variable in short form.
484 
485  @param thd Thread handle.
486  @param str String buffer to append the partial assignment to.
487  */
488  void print_short(const THD *thd, String *str);
489  void print(const THD *, String *str) override; /* To self-print */
491  return (type == OPT_GLOBAL || type == OPT_PERSIST ||
493  }
494  bool is_var_optimizer_trace() const override {
497  }
498  void cleanup() override { var = nullptr; }
499 };
500 
501 /* User variables like @my_own_variable */
502 class set_var_user : public set_var_base {
504 
505  public:
507  int resolve(THD *thd) override;
508  int check(THD *thd) override;
509  int update(THD *thd) override;
510  int light_check(THD *thd) override;
511  void print(const THD *thd, String *str) override; /* To self-print */
512 };
513 
516  char *password;
517  const char *current_password;
521 
522  public:
523  set_var_password(LEX_USER *user_arg, char *password_arg,
524  char *current_password_arg, bool retain_current,
525  bool generate_password);
526 
527  const LEX_USER *get_user(void) { return user; }
529  const char *get_generated_password(void) { return str_generated_password; }
530  int resolve(THD *) override { return 0; }
531  int check(THD *thd) override;
532  int update(THD *thd) override;
533  void print(const THD *thd, String *str) override; /* To self-print */
534  ~set_var_password() override;
535 };
536 
537 /* For SET NAMES and SET CHARACTER SET */
538 
544 
545  public:
549  SET_CS_COLLATE = 4
550  };
551  set_var_collation_client(int set_cs_flags_arg,
552  const CHARSET_INFO *client_coll_arg,
553  const CHARSET_INFO *connection_coll_arg,
554  const CHARSET_INFO *result_coll_arg)
555  : set_cs_flags(set_cs_flags_arg),
556  character_set_client(client_coll_arg),
557  character_set_results(result_coll_arg),
558  collation_connection(connection_coll_arg) {}
559  int resolve(THD *) override { return 0; }
560  int check(THD *thd) override;
561  int update(THD *thd) override;
562  void print(const THD *thd, String *str) override; /* To self-print */
563 };
564 
565 /* optional things, have_* variables */
567 
573 
574 /*
575  Helper functions
576 */
580 
581 extern bool get_sysvar_source(const char *name, uint length,
583 
584 bool enumerate_sys_vars(Show_var_array *show_var_array, bool sort,
585  enum enum_var_type type, bool strict);
586 void lock_plugin_mutex();
587 void unlock_plugin_mutex();
588 sys_var *find_sys_var(THD *thd, const char *str, size_t length = 0);
589 sys_var *find_sys_var_ex(THD *thd, const char *str, size_t length = 0,
590  bool throw_error = false, bool locked = false);
591 int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool opened);
592 bool keyring_access_test();
594 
597  LEX_STRING *ls);
599  LEX_STRING *ls);
601 
603 extern sys_var *Sys_gtid_next_ptr;
606 
608 
609 const CHARSET_INFO *get_old_charset_by_name(const char *old_name);
610 
611 int sys_var_init();
612 int sys_var_add_options(std::vector<my_option> *long_options, int parse_flags);
613 void sys_var_end(void);
614 
615 /* check needed privileges to perform SET PERSIST[_only] or RESET PERSIST */
616 bool check_priv(THD *thd, bool static_variable);
617 
618 #define PERSIST_ONLY_ADMIN_X509_SUBJECT "persist_only_admin_x509_subject"
619 #define PERSISTED_GLOBALS_LOAD "persisted_globals_load"
621 
622 #endif
This class is used to implement operations like SET @variable or @variable:= expression.
Definition: item_func.h:3208
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Definition: sql_list.h:431
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:49
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
A sys_var that is an alias for another sys_var.
Definition: sys_vars.h:338
Definition: set_var.h:398
sys_var * m_var
variable pointer
Definition: set_var.h:416
const LEX_CSTRING m_name
variable name
Definition: set_var.h:414
Sys_var_tracker(sys_var *var)
Definition: set_var.cc:560
const bool m_is_dynamic
true if dynamic variable
Definition: set_var.h:413
LEX_CSTRING get_var_name() const
Definition: set_var.h:408
bool operator==(const Sys_var_tracker &x) const
Definition: set_var.h:404
bool is_plugin_var() const
Definition: set_var.h:410
bool is_sys_var(sys_var *x) const
Definition: set_var.h:409
sys_var * bind_system_variable(THD *thd)
Definition: set_var.cc:565
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:48
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:209
A base class for everything that can be set with SET command.
Definition: set_var.h:428
virtual ~set_var_base()=default
set_var_base()=default
virtual int check(THD *thd)=0
Evaluate the expression.
virtual int light_check(THD *thd)
Used only by prepared statements to resolve and check.
Definition: set_var.h:447
virtual void cleanup()
Definition: set_var.h:441
virtual int resolve(THD *thd)=0
Check privileges & fix_fields.
virtual int update(THD *thd)=0
Set the value.
virtual bool is_var_optimizer_trace() const
Definition: set_var.h:440
virtual void print(const THD *thd, String *str)=0
To self-print.
Definition: set_var.h:539
set_cs_flags_enum
Definition: set_var.h:546
@ SET_CS_DEFAULT
Definition: set_var.h:548
@ SET_CS_NAMES
Definition: set_var.h:547
@ SET_CS_COLLATE
Definition: set_var.h:549
void print(const THD *thd, String *str) override
To self-print.
Definition: set_var.cc:1453
const CHARSET_INFO * character_set_client
Definition: set_var.h:541
const CHARSET_INFO * character_set_results
Definition: set_var.h:542
const CHARSET_INFO * collation_connection
Definition: set_var.h:543
set_var_collation_client(int set_cs_flags_arg, const CHARSET_INFO *client_coll_arg, const CHARSET_INFO *connection_coll_arg, const CHARSET_INFO *result_coll_arg)
Definition: set_var.h:551
int update(THD *thd) override
Set the value.
Definition: set_var.cc:1423
int set_cs_flags
Definition: set_var.h:540
int resolve(THD *) override
Check privileges & fix_fields.
Definition: set_var.h:559
int check(THD *thd) override
Evaluate the expression.
Definition: set_var.cc:1413
Definition: set_var.h:514
LEX_USER * user
Definition: set_var.h:515
char * str_generated_password
Definition: set_var.h:520
const char * get_generated_password(void)
Definition: set_var.h:529
int check(THD *thd) override
Check the validity of the SET PASSWORD request.
Definition: set_var.cc:1357
set_var_password(LEX_USER *user_arg, char *password_arg, char *current_password_arg, bool retain_current, bool generate_password)
Definition: set_var.cc:1327
bool retain_current_password
Definition: set_var.h:518
bool has_generated_password(void)
Definition: set_var.h:528
void print(const THD *thd, String *str) override
To self-print.
Definition: set_var.cc:1389
int resolve(THD *) override
Check privileges & fix_fields.
Definition: set_var.h:530
const LEX_USER * get_user(void)
Definition: set_var.h:527
char * password
Definition: set_var.h:516
int update(THD *thd) override
Set the value.
Definition: set_var.cc:1365
bool generate_password
Definition: set_var.h:519
~set_var_password() override
Definition: set_var.cc:1343
const char * current_password
Definition: set_var.h:517
Definition: set_var.h:502
int check(THD *thd) override
Evaluate the expression.
Definition: set_var.cc:1278
int update(THD *thd) override
Set the value.
Definition: set_var.cc:1306
set_var_user(Item_func_set_user_var *item)
Definition: set_var.h:506
int resolve(THD *thd) override
Check privileges & fix_fields.
Definition: set_var.cc:1269
Item_func_set_user_var * user_var_item
Definition: set_var.h:503
void print(const THD *thd, String *str) override
To self-print.
Definition: set_var.cc:1319
int light_check(THD *thd) override
Check variable, but without assigning value (used by PS).
Definition: set_var.cc:1298
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:453
ulonglong ulonglong_value
for all integer, set, enum sysvars
Definition: set_var.h:460
int resolve(THD *thd) override
Resolve the variable assignment.
Definition: set_var.cc:1018
LEX_CSTRING base
for structured variables, like keycache_name.variable_name
Definition: set_var.h:468
union set_var::@145 save_result
int update(THD *thd) override
Update variable.
Definition: set_var.cc:1207
void update_source_user_host_timestamp(THD *thd)
Update variable source, user, host and timestamp values.
Definition: set_var.cc:1188
bool is_global_persist()
Definition: set_var.h:490
void cleanup() override
Definition: set_var.h:498
set_var(enum_var_type type_arg, sys_var *var_arg, LEX_CSTRING base_name_arg, Item *value_arg)
Definition: set_var.cc:918
Time_zone * time_zone
for Sys_var_tz
Definition: set_var.h:463
int light_check(THD *thd) override
Check variable, but without assigning value (used by PS).
Definition: set_var.cc:1140
Item * value
the expression that provides the new value of the variable
Definition: set_var.h:456
void print(const THD *, String *str) override
Self-print assignment.
Definition: set_var.cc:1244
sys_var * var
system variable to be updated
Definition: set_var.h:455
int check(THD *thd) override
Verify that the supplied value is correct.
Definition: set_var.cc:1097
LEX_STRING string_value
for Sys_var_charptr and others
Definition: set_var.h:464
enum_var_type type
Definition: set_var.h:457
bool is_var_optimizer_trace() const override
Definition: set_var.h:494
plugin_ref plugin
for Sys_var_plugin
Definition: set_var.h:462
void print_short(const THD *thd, String *str)
Print variable in short form.
Definition: set_var.cc:1229
const void * ptr
for Sys_var_struct
Definition: set_var.h:465
double double_value
for Sys_var_double
Definition: set_var.h:461
Sys_var_tracker var_tracker
Definition: set_var.h:471
Definition: sql_plugin_var.h:195
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:102
static const int PARSE_EARLY
Definition: set_var.h:145
virtual bool global_update(THD *thd, set_var *var)=0
my_option * get_option()
Definition: set_var.h:243
bool is_hint_updateable() const
Check if the variable can be set using SET_VAR hint.
Definition: set_var.h:276
virtual bool set_source_name(const char *path)
Definition: set_var.h:229
my_option option
min, max, default values are stored here
Definition: set_var.h:165
bool(* on_update_function)(sys_var *self, THD *thd, enum_var_type type)
Definition: set_var.h:159
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:105
virtual void set_arg_source(get_opt_arg_source *)
Definition: set_var.h:222
sys_var * next
Definition: set_var.h:104
char host[HOSTNAME_LENGTH+1]
Definition: set_var.h:179
virtual ulonglong get_max_value()
Definition: set_var.h:215
virtual void set_user_host(THD *thd)
Definition: set_var.cc:419
uchar * global_var_ptr()
Definition: set_var.cc:367
bool m_is_persisted_deprecated
If m_persist_alias is set, and the current variable is deprecated and m_persist_alias is the recommen...
Definition: set_var.h:122
virtual const uchar * global_value_ptr(THD *thd, LEX_STRING *base)
Definition: set_var.cc:359
bool check(THD *thd, set_var *var)
Definition: set_var.cc:371
enum sys_var::binlog_status_enum binlog_status
uchar * session_var_ptr(THD *thd)
A pointer to a storage area of the variable, to the raw data.
Definition: set_var.cc:363
void save_default(THD *thd, set_var *var)
Definition: set_var.h:338
bool register_option(std::vector< my_option > *array, int parse_flags)
Definition: set_var.h:323
flag_enum
Definition: set_var.h:123
@ SESSION
Definition: set_var.h:125
@ GLOBAL
Definition: set_var.h:124
@ INVISIBLE
Definition: set_var.h:130
@ READONLY
Definition: set_var.h:128
@ SCOPE_MASK
Definition: set_var.h:127
@ ALLOCATED
Definition: set_var.h:129
@ NOTPERSIST
Definition: set_var.h:132
@ TRI_LEVEL
Definition: set_var.h:131
@ PERSIST_AS_READ_ONLY
There can be some variables which needs to be set before plugin is loaded.
Definition: set_var.h:143
@ HINT_UPDATEABLE
Definition: set_var.h:133
@ ONLY_SESSION
Definition: set_var.h:126
virtual bool do_check(THD *thd, set_var *var)=0
sys_var * m_persisted_alias
If the variable has an alias in the persisted variables file, this should point to it.
Definition: set_var.h:114
bool is_global_persist(enum_var_type type)
Definition: set_var.h:313
virtual bool check_update_type(Item_result type)=0
virtual void set_timestamp(ulonglong ts)
Definition: set_var.h:245
virtual void cleanup()
All the cleanup procedures should be performed here.
Definition: set_var.h:199
virtual longlong get_min_value()
Definition: set_var.h:214
virtual ~sys_var()=default
virtual const char * get_host()
Definition: set_var.h:237
virtual void set_is_plugin(bool)
Definition: set_var.h:223
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:151
@ SESSION_VARIABLE_IN_BINLOG
Definition: set_var.h:153
@ VARIABLE_NOT_IN_BINLOG
Definition: set_var.h:152
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:176
ptrdiff_t offset
offset to the value from global_system_variables
Definition: set_var.h:167
virtual bool set_user(const char *usr)
Definition: set_var.h:233
bool check_scope(enum_var_type query_type)
Return true for success if: Global query and variable scope is GLOBAL or SESSION, or Session query an...
Definition: set_var.h:300
bool(* on_check_function)(sys_var *self, THD *thd, set_var *var)
Definition: set_var.h:157
virtual enum_variable_source get_source()
Definition: set_var.h:224
SHOW_TYPE show_type()
Definition: set_var.h:263
virtual sys_var_pluginvar * cast_pluginvar()
downcast for sys_var_pluginvar.
Definition: set_var.h:204
virtual void global_save_default(THD *thd, set_var *var)=0
save the global default value of the variable in var
virtual const char * get_user()
Definition: set_var.h:236
on_check_function on_check
Definition: set_var.h:168
const CHARSET_INFO * charset(THD *thd)
Definition: set_var.cc:555
virtual ulong get_var_type()
Returns variable type.
Definition: set_var.h:221
bool is_struct()
the following is only true for keycache variables, that support the syntax @keycache_name....
Definition: set_var.h:281
bool set_default(THD *thd, set_var *var)
Update the system variable with the default value from either session or global scope.
Definition: set_var.cc:408
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:173
bool is_trilevel() const
Definition: set_var.h:268
const uchar * value_ptr(THD *running_thd, THD *target_thd, enum_var_type type, LEX_STRING *base)
Definition: set_var.cc:393
bool is_persist_readonly() const
Definition: set_var.h:269
void do_deprecated_warning(THD *thd)
Definition: set_var.cc:442
virtual const uchar * session_value_ptr(THD *running_thd, THD *target_thd, LEX_STRING *base)
A pointer to a value of the variable for SHOW.
Definition: set_var.cc:355
int scope() const
Definition: set_var.h:264
struct get_opt_arg_source source
Definition: set_var.h:177
virtual void set_timestamp()
Definition: set_var.h:244
const SHOW_TYPE show_val_type
what value_ptr() returns for sql_show.cc
Definition: set_var.h:164
on_update_function on_update
Definition: set_var.h:174
int flags
or'ed flag_enum values
Definition: set_var.h:162
static const int PARSE_NORMAL
Definition: set_var.h:146
bool update(THD *thd, set_var *var)
Definition: set_var.cc:304
char user[USERNAME_CHAR_LENGTH+1]
Definition: set_var.h:178
bool is_written_to_binlog(enum_var_type type)
Definition: set_var.h:290
virtual const char * get_source_name()
Definition: set_var.h:225
virtual void update_default(longlong new_def_value)
Definition: set_var.h:210
virtual bool set_host(const char *hst)
Definition: set_var.h:238
bool not_visible() const
Definition: set_var.h:267
bool is_settable_at_command_line()
Return true if settable at the command line.
Definition: set_var.h:321
PolyLock * guard
second lock that protects the variable
Definition: set_var.h:166
virtual longlong get_default()
Definition: set_var.h:213
virtual bool is_non_persistent()
Definition: set_var.h:246
Item * copy_value(THD *thd)
Create item from system variable value.
Definition: set_var.cc:463
const char *const deprecation_substitute
Definition: set_var.h:175
virtual ulonglong get_timestamp() const
Definition: set_var.h:241
static bool set_and_truncate(char *dst, const char *string, size_t sizeof_dst)
Like strncpy, but ensures the destination is '\0'-terminated.
Definition: set_var.h:353
bool(* pre_update_function)(sys_var *self, THD *thd, set_var *var)
Definition: set_var.h:158
const char * get_deprecation_substitute()
Definition: set_var.h:195
bool is_readonly() const
Definition: set_var.h:266
virtual bool session_update(THD *thd, set_var *var)=0
int m_parse_flag
either PARSE_EARLY or PARSE_NORMAL.
Definition: set_var.h:163
ulonglong timestamp
Definition: set_var.h:180
sys_var(sys_var_chain *chain, const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, int getopt_id, enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg, longlong 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, sys_var *persisted_alias=nullptr, bool is_persisted_deprecated=false)
sys_var constructor
Definition: set_var.cc:235
virtual void set_source(enum_variable_source src)
Definition: set_var.h:226
ulonglong sql_mode_t
Definition: dd_event.h:36
#define comment
Definition: lexyy.cc:959
static int opened
Definition: log_filter_dragnet.cc:122
A better implementation of the UNIX ctype(3) library.
get_opt_arg_type
Enumeration of the my_option::arg_type attributes.
Definition: my_getopt.h:78
#define GET_TYPE_MASK
Definition: my_getopt.h:69
#define GET_ASK_ADDR
Definition: my_getopt.h:68
Common definition used by mysys, performance schema and server & client.
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:42
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
Common header for many mysys elements.
Defines for getting and processing the current system type programmatically.
unsigned long long int my_micro_time()
Return time in microseconds.
Definition: my_systime.h:185
Common definition between mysql server & client.
#define USERNAME_CHAR_LENGTH
Definition: mysql_com.h:63
static char * path
Definition: mysqldump.cc:130
static const char * sql_mode
Definition: mysqlslap.cc:193
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:41
required string type
Definition: replication_group_member_actions.proto:33
int sys_var_init()
Definition: set_var.cc:116
sys_var * Sys_gtid_purged_ptr
Definition: sys_vars.cc:6538
enum enum_mysql_show_type SHOW_TYPE
Definition: set_var.h:68
SHOW_COMP_OPTION have_rtree_keys
Definition: set_var.h:570
ulonglong sql_mode_t
Definition: set_var.h:65
char * sys_var_persist_only_admin_x509_subject
global X509 subject name to require from the client session to allow SET PERSIST[_ONLY] on sys_var::N...
Definition: set_var.cc:947
ulong get_system_variable_hash_records(void)
Definition: set_var.cc:705
SHOW_COMP_OPTION have_profiling
Definition: mysqld.cc:1522
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type)
Definition: sys_vars.cc:1999
bool get_sysvar_source(const char *name, uint length, enum enum_variable_source *source)
Get source of a given system variable given its name and name length.
Definition: set_var.cc:90
enum enum_mysql_show_scope SHOW_SCOPE
Definition: set_var.h:69
bool enumerate_sys_vars(Show_var_array *show_var_array, bool sort, enum enum_var_type type, bool strict)
Constructs an array of system variables for display to the user.
Definition: set_var.cc:727
SHOW_COMP_OPTION have_compress
Definition: mysqld.cc:1521
Prealloced_array< SHOW_VAR, SHOW_VAR_PREALLOC > Show_var_array
Definition: set_var.h:77
void unlock_plugin_mutex()
Definition: sql_plugin.cc:2766
sys_var * Sys_gtid_next_ptr
Definition: sys_vars.cc:6439
void update_parser_max_mem_size()
Definition: sys_vars.cc:3238
int mysql_add_sys_var_chain(sys_var *chain)
Add variables to the dynamic hash of system variables.
Definition: set_var.cc:637
SHOW_COMP_OPTION have_symlink
Definition: mysqld.cc:1519
SHOW_COMP_OPTION have_statement_timeout
Definition: mysqld.cc:1523
bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls)
Definition: sys_vars.cc:4768
void lock_plugin_mutex()
Definition: sql_plugin.cc:2764
ulonglong system_variable_hash_version
Definition: set_var.cc:78
int mysql_del_sys_var_chain(sys_var *chain)
Definition: set_var.cc:672
bool keyring_access_test()
This function is used to check if key management UDFs like keying_key_generate/store/remove should pr...
Definition: set_var.cc:906
sys_var * find_sys_var(THD *thd, const char *str, size_t length=0)
Definition: sql_plugin.cc:2796
SHOW_COMP_OPTION have_geometry
Definition: mysqld.cc:1520
bool sql_mode_quoted_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls)
Definition: sys_vars.cc:4773
sys_var * Sys_autocommit_ptr
Definition: sys_vars.cc:5252
int sql_set_variables(THD *thd, List< set_var_base > *var_list, bool opened)
Execute update of all variables.
Definition: set_var.cc:836
TYPELIB bool_typelib
Definition: sys_vars.cc:153
const CHARSET_INFO * get_old_charset_by_name(const char *old_name)
Definition: set_var.cc:609
void sys_var_end(void)
Definition: set_var.cc:152
ulonglong get_system_variable_hash_version(void)
Definition: set_var.cc:713
collation_unordered_map< std::string, sys_var * > * get_system_variable_hash(void)
Definition: set_var.cc:80
int sys_var_add_options(std::vector< my_option > *long_options, int parse_flags)
Definition: set_var.cc:138
enum_var_type
Definition: set_var.h:87
@ OPT_PERSIST_ONLY
Definition: set_var.h:92
@ OPT_PERSIST
Definition: set_var.h:91
@ OPT_GLOBAL
Definition: set_var.h:90
@ OPT_DEFAULT
Definition: set_var.h:88
@ OPT_SESSION
Definition: set_var.h:89
sql_mode_t expand_sql_mode(sql_mode_t sql_mode, THD *thd)
Definition: sys_vars.cc:4660
bool check_priv(THD *thd, bool static_variable)
This function will check for necessary privileges needed to perform RESET PERSIST or SET PERSIST[_ONL...
Definition: set_var.cc:172
SHOW_COMP_OPTION have_query_cache
Definition: mysqld.cc:1519
SHOW_COMP_OPTION have_dlopen
Definition: set_var.h:568
sys_var * find_sys_var_ex(THD *thd, const char *str, size_t length=0, bool throw_error=false, bool locked=false)
Definition: sql_plugin.cc:2768
sys_var * Sys_gtid_next_list_ptr
File containing constants that can be used throughout the server.
SHOW_COMP_OPTION
Definition: sql_const.h:375
case opt name
Definition: sslopt-case.h:32
enum_mysql_show_type
Declarations for SHOW STATUS support in plugins.
Definition: status_var.h:29
enum_mysql_show_scope
Status variable scope.
Definition: status_var.h:67
Definition: m_ctype.h:354
Definition: table.h:2561
Definition: mysql_lex_string.h:39
Definition: mysql_lex_string.h:34
Definition: typelib.h:34
Definition: my_getopt.h:80
char m_path_name[FN_REFLEN]
config file path OR compiled default values
Definition: my_getopt.h:84
enum enum_variable_source m_source
Definition: my_getopt.h:85
Definition: my_getopt.h:90
longlong min_value
Min allowed value (for numbers)
Definition: my_getopt.h:120
ulonglong max_value
Max allowed value (for numbers)
Definition: my_getopt.h:121
longlong def_value
Default value.
Definition: my_getopt.h:119
ulong var_type
GET_BOOL, GET_ULL, etc.
Definition: my_getopt.h:117
int id
For 0<id<=255 it's means one character for a short option (like -A), if >255 no short option is creat...
Definition: my_getopt.h:95
struct get_opt_arg_source * arg_source
Represents source/path from where this variable is set.
Definition: my_getopt.h:122
Definition: sql_plugin_ref.h:44
Definition: set_var.h:79
sys_var * first
Definition: set_var.h:80
sys_var * last
Definition: set_var.h:81
export sys_var * Sys_optimizer_trace_ptr
Definition: sys_vars.cc:3345
enum_variable_source
This enum values define how system variables are set.
Definition: system_variable_source_type.h:32
unsigned int uint
Definition: uca-dump.cc:29
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38