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.cc | |
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.cc')
-rw-r--r-- | sql/set_var.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index 58b6b392449..cc44dbe401b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -233,12 +233,12 @@ bool sys_var::update(THD *thd, set_var *var) } } -uchar *sys_var::session_value_ptr(THD *thd, const LEX_CSTRING *base) +const uchar *sys_var::session_value_ptr(THD *thd, const LEX_CSTRING *base) const { return session_var_ptr(thd); } -uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base) +const uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base) const { return global_var_ptr(); } @@ -271,8 +271,8 @@ bool sys_var::check(THD *thd, set_var *var) return false; } -uchar *sys_var::value_ptr(THD *thd, enum_var_type type, - const LEX_CSTRING *base) +const uchar *sys_var::value_ptr(THD *thd, enum_var_type type, + const LEX_CSTRING *base) const { DBUG_ASSERT(base); if (type == OPT_GLOBAL || scope() == GLOBAL) @@ -510,7 +510,7 @@ bool throw_bounds_warning(THD *thd, const char *name, bool fixed, double v) return false; } -CHARSET_INFO *sys_var::charset(THD *thd) +CHARSET_INFO *sys_var::charset(THD *thd) const { return is_os_charset ? thd->variables.character_set_filesystem : system_charset_info; @@ -1047,7 +1047,7 @@ int set_var_collation_client::update(THD *thd) INFORMATION_SCHEMA.SYSTEM_VARIABLES *****************************************************************************/ static void store_value_ptr(Field *field, sys_var *var, String *str, - uchar *value_ptr) + const uchar *value_ptr) { field->set_notnull(); str= var->val_str_nolock(str, field->table->in_use, value_ptr); @@ -1115,8 +1115,8 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) fields[3]->store(origin->str, origin->length, scs); // DEFAULT_VALUE - uchar *def= var->is_readonly() && var->option.id < 0 - ? 0 : var->default_value_ptr(thd); + const uchar *def= var->is_readonly() && var->option.id < 0 + ? 0 : var->default_value_ptr(thd); if (def) store_value_ptr(fields[4], var, &strbuf, def); |