diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2019-07-18 03:15:55 +1000 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2021-07-27 14:15:01 +0300 |
commit | 6ed47508c86b7d1761ae325f11aefe27cac31e38 (patch) | |
tree | 8c75cfd7f941a2db630bf2268ff0e1ba5fb87492 /sql/set_var.h | |
parent | c6bff46958faa745f529ac17101a63377925dbd8 (diff) | |
download | mariadb-git-6ed47508c86b7d1761ae325f11aefe27cac31e38.tar.gz |
add const qualifiers to sys_var::value_ptr functions and fix const casts
This is important since Sys_var_typelib and its descendants return
pointers to constant symbols from *_value_ptr, which are situated in
write-protected-memory.
* functions const-qualified:
- value_ptr
- session_value_ptr
- global_value_ptr
- default_value_ptr
- Sys_var_vers_asof::value_ptr
- other minor private ones
* remove C-style typecasts when it discards qualifiers
Diffstat (limited to 'sql/set_var.h')
-rw-r--r-- | sql/set_var.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sql/set_var.h b/sql/set_var.h index 6e84c0bd09c..1c02cdcc6e5 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -112,7 +112,7 @@ public: virtual sys_var_pluginvar *cast_pluginvar() { return 0; } bool check(THD *thd, set_var *var); - uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base); + const uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base) const; /** Update the system variable with the default value from either @@ -127,9 +127,9 @@ public: String *val_str(String *str, THD *thd, enum_var_type type, const LEX_CSTRING *base); double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base); - SHOW_TYPE show_type() { return show_val_type; } + SHOW_TYPE show_type() const { return show_val_type; } int scope() const { return flags & SCOPE_MASK; } - CHARSET_INFO *charset(THD *thd); + CHARSET_INFO *charset(THD *thd) const; bool is_readonly() const { return flags & READONLY; } /** the following is only true for keycache variables, @@ -208,7 +208,7 @@ public: */ virtual bool session_is_default(THD *thd) { return false; } - virtual uchar *default_value_ptr(THD *thd) + virtual const uchar *default_value_ptr(THD *thd) const { return (uchar*)&option.def_value; } private: @@ -230,18 +230,18 @@ protected: It must be of show_val_type type (my_bool for SHOW_MY_BOOL, int for SHOW_INT, longlong for SHOW_LONGLONG, etc). */ - virtual uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base); - virtual uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base); + virtual const uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base) const; + virtual const uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base) const; /** A pointer to a storage area of the variable, to the raw data. Typically it's the same as session_value_ptr(), but it's different, for example, for ENUM, that is printed as a string, but stored as a number. */ - uchar *session_var_ptr(THD *thd) + uchar *session_var_ptr(THD *thd) const { return ((uchar*)&(thd->variables)) + offset; } - uchar *global_var_ptr() + uchar *global_var_ptr() const { return ((uchar*)&global_system_variables) + offset; } void *max_var_ptr() |