Commit bd6afd8b authored by Alexander Barkov's avatar Alexander Barkov

MDEV-21956 Add class Sys_var_charptr_fscs

Simplifying definitions on Sys_var_charptr*:

- Removing sys_var::is_os_charset
- Adding a new class Sys_var_charptr_fscs, to handle system
  variables with character_set_filesystem.
parent 9cc7edb1
...@@ -154,8 +154,7 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg, ...@@ -154,8 +154,7 @@ sys_var::sys_var(sys_var_chain *chain, const char *name_arg,
next(0), binlog_status(binlog_status_arg), value_origin(COMPILE_TIME), next(0), binlog_status(binlog_status_arg), value_origin(COMPILE_TIME),
flags(flags_arg), show_val_type(show_val_type_arg), flags(flags_arg), show_val_type(show_val_type_arg),
guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func), guard(lock), offset(off), on_check(on_check_func), on_update(on_update_func),
deprecation_substitute(substitute), deprecation_substitute(substitute)
is_os_charset(FALSE)
{ {
/* /*
There is a limitation in handle_options() related to short options: There is a limitation in handle_options() related to short options:
...@@ -509,12 +508,6 @@ bool throw_bounds_warning(THD *thd, const char *name, bool fixed, double v) ...@@ -509,12 +508,6 @@ bool throw_bounds_warning(THD *thd, const char *name, bool fixed, double v)
return false; return false;
} }
CHARSET_INFO *sys_var::charset(THD *thd)
{
return is_os_charset ? thd->variables.character_set_filesystem :
system_charset_info;
}
typedef struct old_names_map_st typedef struct old_names_map_st
{ {
......
...@@ -90,7 +90,6 @@ class sys_var: protected Value_source // for double_from_string_with_check ...@@ -90,7 +90,6 @@ class sys_var: protected Value_source // for double_from_string_with_check
on_check_function on_check; on_check_function on_check;
on_update_function on_update; on_update_function on_update;
const char *const deprecation_substitute; const char *const deprecation_substitute;
bool is_os_charset; ///< true if the value is in character_set_filesystem
public: public:
sys_var(sys_var_chain *chain, const char *name_arg, const char *comment, sys_var(sys_var_chain *chain, const char *name_arg, const char *comment,
...@@ -130,7 +129,10 @@ class sys_var: protected Value_source // for double_from_string_with_check ...@@ -130,7 +129,10 @@ class sys_var: protected Value_source // for double_from_string_with_check
SHOW_TYPE show_type() { return show_val_type; } SHOW_TYPE show_type() { return show_val_type; }
int scope() const { return flags & SCOPE_MASK; } int scope() const { return flags & SCOPE_MASK; }
CHARSET_INFO *charset(THD *thd); virtual CHARSET_INFO *charset(THD *thd) const
{
return system_charset_info;
}
bool is_readonly() const { return flags & READONLY; } bool is_readonly() const { return flags & READONLY; }
/** /**
the following is only true for keycache variables, the following is only true for keycache variables,
......
This diff is collapsed.
...@@ -97,7 +97,6 @@ ...@@ -97,7 +97,6 @@
exit(255); \ exit(255); \
} }
enum charset_enum {IN_SYSTEM_CHARSET, IN_FS_CHARSET};
static const char *bool_values[3]= {"OFF", "ON", 0}; static const char *bool_values[3]= {"OFF", "ON", 0};
TYPELIB bool_typelib={ array_elements(bool_values)-1, "", bool_values, 0 }; TYPELIB bool_typelib={ array_elements(bool_values)-1, "", bool_values, 0 };
...@@ -449,9 +448,6 @@ public: ...@@ -449,9 +448,6 @@ public:
or not. The state of the initial value is specified in the constructor, or not. The state of the initial value is specified in the constructor,
after that it's managed automatically. The value of NULL is supported. after that it's managed automatically. The value of NULL is supported.
Class specific constructor arguments:
enum charset_enum is_os_charset_arg
Backing store: char* Backing store: char*
@note @note
...@@ -465,7 +461,6 @@ public: ...@@ -465,7 +461,6 @@ public:
Sys_var_charptr_base(const char *name_arg, Sys_var_charptr_base(const char *name_arg,
const char *comment, int flag_args, ptrdiff_t off, size_t size, const char *comment, int flag_args, ptrdiff_t off, size_t size,
CMD_LINE getopt, CMD_LINE getopt,
enum charset_enum is_os_charset_arg,
const char *def_val, PolyLock *lock=0, const char *def_val, PolyLock *lock=0,
enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
on_check_function on_check_func=0, on_check_function on_check_func=0,
...@@ -476,7 +471,6 @@ public: ...@@ -476,7 +471,6 @@ public:
lock, binlog_status_arg, on_check_func, on_update_func, lock, binlog_status_arg, on_check_func, on_update_func,
substitute) substitute)
{ {
is_os_charset= is_os_charset_arg == IN_FS_CHARSET;
/* /*
use GET_STR_ALLOC - if ALLOCATED it must be *always* allocated, use GET_STR_ALLOC - if ALLOCATED it must be *always* allocated,
otherwise (GET_STR) you'll never know whether to free it or not. otherwise (GET_STR) you'll never know whether to free it or not.
...@@ -566,14 +560,13 @@ public: ...@@ -566,14 +560,13 @@ public:
Sys_var_charptr(const char *name_arg, Sys_var_charptr(const char *name_arg,
const char *comment, int flag_args, ptrdiff_t off, size_t size, const char *comment, int flag_args, ptrdiff_t off, size_t size,
CMD_LINE getopt, CMD_LINE getopt,
enum charset_enum is_os_charset_arg,
const char *def_val, PolyLock *lock=0, const char *def_val, PolyLock *lock=0,
enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
on_check_function on_check_func=0, on_check_function on_check_func=0,
on_update_function on_update_func=0, on_update_function on_update_func=0,
const char *substitute=0) : const char *substitute=0) :
Sys_var_charptr_base(name_arg, comment, flag_args, off, size, getopt, Sys_var_charptr_base(name_arg, comment, flag_args, off, size, getopt,
is_os_charset_arg, def_val, lock, binlog_status_arg, def_val, lock, binlog_status_arg,
on_check_func, on_update_func, substitute) on_check_func, on_update_func, substitute)
{ {
SYSVAR_ASSERT(scope() == GLOBAL); SYSVAR_ASSERT(scope() == GLOBAL);
...@@ -589,6 +582,18 @@ public: ...@@ -589,6 +582,18 @@ public:
{ DBUG_ASSERT(FALSE); } { DBUG_ASSERT(FALSE); }
}; };
class Sys_var_charptr_fscs: public Sys_var_charptr
{
using Sys_var_charptr::Sys_var_charptr;
public:
CHARSET_INFO *charset(THD *thd) const override
{
return thd->variables.character_set_filesystem;
}
};
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
class Sys_var_sesvartrack: public Sys_var_charptr_base class Sys_var_sesvartrack: public Sys_var_charptr_base
{ {
...@@ -596,11 +601,10 @@ public: ...@@ -596,11 +601,10 @@ public:
Sys_var_sesvartrack(const char *name_arg, Sys_var_sesvartrack(const char *name_arg,
const char *comment, const char *comment,
CMD_LINE getopt, CMD_LINE getopt,
enum charset_enum is_os_charset_arg,
const char *def_val, PolyLock *lock= 0) : const char *def_val, PolyLock *lock= 0) :
Sys_var_charptr_base(name_arg, comment, Sys_var_charptr_base(name_arg, comment,
SESSION_VAR(session_track_system_variables), SESSION_VAR(session_track_system_variables),
getopt, is_os_charset_arg, def_val, lock, getopt, def_val, lock,
VARIABLE_NOT_IN_BINLOG, 0, 0, 0) VARIABLE_NOT_IN_BINLOG, 0, 0, 0)
{} {}
bool do_check(THD *thd, set_var *var) bool do_check(THD *thd, set_var *var)
...@@ -649,14 +653,12 @@ public: ...@@ -649,14 +653,12 @@ public:
class Sys_var_proxy_user: public sys_var class Sys_var_proxy_user: public sys_var
{ {
public: public:
Sys_var_proxy_user(const char *name_arg, Sys_var_proxy_user(const char *name_arg, const char *comment)
const char *comment, enum charset_enum is_os_charset_arg)
: sys_var(&all_sys_vars, name_arg, comment, : sys_var(&all_sys_vars, name_arg, comment,
sys_var::READONLY+sys_var::ONLY_SESSION, 0, NO_GETOPT, sys_var::READONLY+sys_var::ONLY_SESSION, 0, NO_GETOPT,
NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG, NO_ARG, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG,
NULL, NULL, NULL) NULL, NULL, NULL)
{ {
is_os_charset= is_os_charset_arg == IN_FS_CHARSET;
option.var_type|= GET_STR; option.var_type|= GET_STR;
} }
bool do_check(THD *thd, set_var *var) bool do_check(THD *thd, set_var *var)
...@@ -689,9 +691,8 @@ protected: ...@@ -689,9 +691,8 @@ protected:
class Sys_var_external_user : public Sys_var_proxy_user class Sys_var_external_user : public Sys_var_proxy_user
{ {
public: public:
Sys_var_external_user(const char *name_arg, const char *comment_arg, Sys_var_external_user(const char *name_arg, const char *comment_arg)
enum charset_enum is_os_charset_arg) : Sys_var_proxy_user (name_arg, comment_arg)
: Sys_var_proxy_user (name_arg, comment_arg, is_os_charset_arg)
{} {}
protected: protected:
...@@ -743,9 +744,6 @@ protected: ...@@ -743,9 +744,6 @@ protected:
The class for string variables. Useful for strings that aren't necessarily The class for string variables. Useful for strings that aren't necessarily
\0-terminated. Otherwise the same as Sys_var_charptr. \0-terminated. Otherwise the same as Sys_var_charptr.
Class specific constructor arguments:
enum charset_enum is_os_charset_arg
Backing store: LEX_CSTRING Backing store: LEX_CSTRING
@note @note
...@@ -757,14 +755,13 @@ public: ...@@ -757,14 +755,13 @@ public:
Sys_var_lexstring(const char *name_arg, Sys_var_lexstring(const char *name_arg,
const char *comment, int flag_args, ptrdiff_t off, size_t size, const char *comment, int flag_args, ptrdiff_t off, size_t size,
CMD_LINE getopt, CMD_LINE getopt,
enum charset_enum is_os_charset_arg,
const char *def_val, PolyLock *lock=0, const char *def_val, PolyLock *lock=0,
enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG, enum binlog_status_enum binlog_status_arg=VARIABLE_NOT_IN_BINLOG,
on_check_function on_check_func=0, on_check_function on_check_func=0,
on_update_function on_update_func=0, on_update_function on_update_func=0,
const char *substitute=0) const char *substitute=0)
: Sys_var_charptr(name_arg, comment, flag_args, off, sizeof(char*), : Sys_var_charptr(name_arg, comment, flag_args, off, sizeof(char*),
getopt, is_os_charset_arg, def_val, lock, binlog_status_arg, getopt, def_val, lock, binlog_status_arg,
on_check_func, on_update_func, substitute) on_check_func, on_update_func, substitute)
{ {
global_var(LEX_CSTRING).length= strlen(def_val); global_var(LEX_CSTRING).length= strlen(def_val);
...@@ -793,7 +790,6 @@ public: ...@@ -793,7 +790,6 @@ public:
Sys_var_session_lexstring(const char *name_arg, Sys_var_session_lexstring(const char *name_arg,
const char *comment, int flag_args, const char *comment, int flag_args,
ptrdiff_t off, size_t size, CMD_LINE getopt, ptrdiff_t off, size_t size, CMD_LINE getopt,
enum charset_enum is_os_charset_arg,
const char *def_val, size_t max_length_arg, const char *def_val, size_t max_length_arg,
on_check_function on_check_func=0, on_check_function on_check_func=0,
on_update_function on_update_func=0) on_update_function on_update_func=0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment