diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/create_options.cc | 2 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/set_var.cc | 185 | ||||
-rw-r--r-- | sql/set_var.h | 4 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 9 | ||||
-rw-r--r-- | sql/sql_show.cc | 28 | ||||
-rw-r--r-- | sql/sql_show.h | 1 | ||||
-rw-r--r-- | sql/sys_vars.h | 146 |
8 files changed, 307 insertions, 69 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc index d60639a4f4a..efae87e7533 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -331,7 +331,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg, char buf[256]; String sbuf(buf, sizeof(buf), system_charset_info), *str; - if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, 0))) + if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_lex_str))) { LEX_STRING name= { const_cast<char*>(opt->name), opt->name_length }; default_val.str= strmake_root(root, str->ptr(), str->length()); diff --git a/sql/handler.h b/sql/handler.h index 9d411bba5d3..4c7648b390c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -748,6 +748,7 @@ enum enum_schema_tables SCH_SESSION_STATUS, SCH_SESSION_VARIABLES, SCH_STATISTICS, + SCH_SYSTEM_VARIABLES, SCH_TABLES, SCH_TABLESPACES, SCH_TABLE_CONSTRAINTS, diff --git a/sql/set_var.cc b/sql/set_var.cc index 03378f2be73..f8287ca1ffe 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -35,6 +35,7 @@ #include "tztime.h" // my_tz_find, my_tz_SYSTEM, struct Time_zone #include "sql_acl.h" // SUPER_ACL #include "sql_select.h" // free_underlaid_joins +#include "sql_show.h" #include "sql_view.h" // updatable_views_with_limit_typelib #include "lock.h" // lock_global_read_lock, // make_global_read_lock_block_commit, @@ -240,6 +241,7 @@ bool sys_var::check(THD *thd, set_var *var) uchar *sys_var::value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base) { + DBUG_ASSERT(base); if (type == OPT_GLOBAL || scope() == GLOBAL) { mysql_mutex_assert_owner(&LOCK_global_system_variables); @@ -468,6 +470,7 @@ CHARSET_INFO *sys_var::charset(THD *thd) system_charset_info; } + typedef struct old_names_map_st { const char *old_name; @@ -938,3 +941,185 @@ int set_var_collation_client::update(THD *thd) return 0; } +/***************************************************************************** + INFORMATION_SCHEMA.SYSTEM_VARIABLES +*****************************************************************************/ +static void store_value_ptr(Field *field, sys_var *var, String *str, + uchar *value_ptr) +{ + field->set_notnull(); + str= var->val_str_nolock(str, field->table->in_use, value_ptr); + if (str) + field->store(str->ptr(), str->length(), str->charset()); +} + +static void store_var(Field *field, sys_var *var, enum_var_type scope, + String *str) +{ + if (var->check_type(scope)) + return; + + store_value_ptr(field, var, str, + var->value_ptr(field->table->in_use, scope, &null_lex_str)); +} + + +int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) +{ + char name_buffer[NAME_CHAR_LEN]; + enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + bool res= 1; + CHARSET_INFO *scs= system_charset_info; + StringBuffer<STRING_BUFFER_USUAL_SIZE> strbuf(scs); + const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : 0; + Field **fields=tables->table->field; + + DBUG_ASSERT(tables->table->in_use == thd); + + cond= make_cond_for_info_schema(cond, tables); + thd->count_cuted_fields= CHECK_FIELD_WARN; + mysql_rwlock_rdlock(&LOCK_system_variables_hash); + + for (uint i= 0; i < system_variable_hash.records; i++) + { + sys_var *var= (sys_var*) my_hash_element(&system_variable_hash, i); + + strmake_buf(name_buffer, var->name.str); + my_caseup_str(system_charset_info, name_buffer); + + /* this must be done before evaluating cond */ + restore_record(tables->table, s->default_values); + fields[0]->store(name_buffer, strlen(name_buffer), scs); + + if ((wild && wild_case_compare(system_charset_info, name_buffer, wild)) + || (cond && !cond->val_int())) + continue; + + mysql_mutex_lock(&LOCK_global_system_variables); + + // SESSION_VALUE + store_var(fields[1], var, OPT_SESSION, &strbuf); + + // GLOBAL_VALUE + store_var(fields[2], var, OPT_GLOBAL, &strbuf); + + // DEFAULT_VALUE + uchar *def= var->is_readonly() && var->option.id < 0 + ? 0 : var->default_value_ptr(thd); + if (def) + store_value_ptr(fields[3], var, &strbuf, def); + + mysql_mutex_unlock(&LOCK_global_system_variables); + + static const LEX_CSTRING scopes[]= + { + { STRING_WITH_LEN("GLOBAL") }, + { STRING_WITH_LEN("SESSION") }, + { STRING_WITH_LEN("SESSION ONLY") } + }; + const LEX_CSTRING *scope= scopes + var->scope(); + fields[4]->store(scope->str, scope->length, scs); + +#if SIZEOF_LONG == SIZEOF_INT +#define LONG_TYPE "INT" +#else +#define LONG_TYPE "BIGINT" +#endif + + static const LEX_CSTRING types[]= + { + { 0, 0 }, // unused 0 + { 0, 0 }, // GET_NO_ARG 1 + { STRING_WITH_LEN("BOOLEAN") }, // GET_BOOL 2 + { STRING_WITH_LEN("INT") }, // GET_INT 3 + { STRING_WITH_LEN("INT UNSIGNED") }, // GET_UINT 4 + { STRING_WITH_LEN(LONG_TYPE) }, // GET_LONG 5 + { STRING_WITH_LEN(LONG_TYPE " UNSIGNED") }, // GET_ULONG 6 + { STRING_WITH_LEN("BIGINT") }, // GET_LL 7 + { STRING_WITH_LEN("BIGINT UNSIGNED") }, // GET_ULL 8 + { STRING_WITH_LEN("VARCHAR") }, // GET_STR 9 + { STRING_WITH_LEN("VARCHAR") }, // GET_STR_ALLOC 10 + { 0, 0 }, // GET_DISABLED 11 + { STRING_WITH_LEN("ENUM") }, // GET_ENUM 12 + { STRING_WITH_LEN("SET") }, // GET_SET 13 + { STRING_WITH_LEN("DOUBLE") }, // GET_DOUBLE 14 + { STRING_WITH_LEN("FLAGSET") }, // GET_FLAGSET 15 + }; + const LEX_CSTRING *type= types + (var->option.var_type & GET_TYPE_MASK); + fields[5]->store(type->str, type->length, scs); + + fields[6]->store(var->option.comment, strlen(var->option.comment), + scs); + + bool is_unsigned= true; + switch (var->option.var_type) + { + case GET_INT: + case GET_LONG: + case GET_LL: + is_unsigned= false; + /* fall through */ + case GET_UINT: + case GET_ULONG: + case GET_ULL: + fields[7]->set_notnull(); + fields[8]->set_notnull(); + fields[9]->set_notnull(); + fields[7]->store(var->option.min_value, is_unsigned); + fields[8]->store(var->option.max_value, is_unsigned); + fields[9]->store(var->option.block_size, is_unsigned); + break; + case GET_DOUBLE: + fields[7]->set_notnull(); + fields[8]->set_notnull(); + fields[7]->store(getopt_ulonglong2double(var->option.min_value)); + fields[8]->store(getopt_ulonglong2double(var->option.max_value)); + } + + TYPELIB *tl= var->option.typelib; + if (tl) + { + uint i; + strbuf.length(0); + for (i=0; i + 1 < tl->count; i++) + { + strbuf.append(tl->type_names[i]); + strbuf.append(','); + } + strbuf.append(tl->type_names[i]); + fields[10]->set_notnull(); + fields[10]->store(strbuf.ptr(), strbuf.length(), scs); + } + + static const LEX_CSTRING yesno[]= + { + { STRING_WITH_LEN("NO") }, + { STRING_WITH_LEN("YES") } + }; + const LEX_CSTRING *yn = yesno + var->is_readonly(); + fields[11]->store(yn->str, yn->length, scs); + + if (var->option.id >= 0) + { + static const LEX_CSTRING args[]= + { + { STRING_WITH_LEN("NONE") }, // NO_ARG + { STRING_WITH_LEN("OPTIONAL") }, // OPT_ARG + { STRING_WITH_LEN("REQUIRED") } // REQUIRED_ARG + }; + const LEX_CSTRING *arg= args + var->option.arg_type; + fields[12]->set_notnull(); + fields[12]->store(arg->str, arg->length, scs); + } + + if (schema_table_store_record(thd, tables->table)) + goto end; + thd->get_stmt_da()->inc_current_row_for_warning(); + } + res= 0; +end: + mysql_rwlock_unlock(&LOCK_system_variables_hash); + thd->count_cuted_fields= save_count_cuted_fields; + return res; +} + diff --git a/sql/set_var.h b/sql/set_var.h index 580a3378b23..79a5d90f8a1 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -190,6 +190,9 @@ public: } void do_deprecated_warning(THD *thd); + virtual uchar *default_value_ptr(THD *thd) + { return (uchar*)&option.def_value; } + private: virtual bool do_check(THD *thd, set_var *var) = 0; /** @@ -382,6 +385,7 @@ extern SHOW_COMP_OPTION have_openssl; */ SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted, enum enum_var_type type); +int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond); sys_var *find_sys_var(THD *thd, const char *str, uint length=0); int sql_set_variables(THD *thd, List<set_var_base> *var_list); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index bbd16dac6a7..480d1652e87 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -266,6 +266,8 @@ public: { return do_value_ptr(thd, OPT_SESSION, base); } uchar* global_value_ptr(THD *thd, const LEX_STRING *base) { return do_value_ptr(thd, OPT_GLOBAL, base); } + uchar *default_value_ptr(THD *thd) + { return do_value_ptr(thd, OPT_DEFAULT, 0); } bool do_check(THD *thd, set_var *var); virtual void session_save_default(THD *thd, set_var *var) {} virtual void global_save_default(THD *thd, set_var *var) {} @@ -3239,6 +3241,9 @@ sys_var_pluginvar::sys_var_pluginvar(sys_var_chain *chain, const char *name_arg, uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) { + if (type == OPT_DEFAULT) + return (uchar*)&option.def_value; + DBUG_ASSERT(thd || (type == OPT_GLOBAL)); if (plugin_var->flags & PLUGIN_VAR_THDLOCAL) { @@ -3307,7 +3312,7 @@ bool sys_var_pluginvar::session_update(THD *thd, set_var *var) DBUG_ASSERT(thd == current_thd); mysql_mutex_lock(&LOCK_global_system_variables); - void *tgt= real_value_ptr(thd, var->type); + void *tgt= real_value_ptr(thd, OPT_SESSION); const void *src= var->value ? (void*)&var->save_result : (void*)real_value_ptr(thd, OPT_GLOBAL); mysql_mutex_unlock(&LOCK_global_system_variables); @@ -3322,7 +3327,7 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var) DBUG_ASSERT(!is_readonly()); mysql_mutex_assert_owner(&LOCK_global_system_variables); - void *tgt= real_value_ptr(thd, var->type); + void *tgt= real_value_ptr(thd, OPT_GLOBAL); const void *src= &var->save_result; if (!var->value) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3dfecd3522b..7c36b3ccb2f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -116,10 +116,7 @@ static void get_cs_converted_string_value(THD *thd, bool use_hex); #endif -static void -append_algorithm(TABLE_LIST *table, String *buff); - -static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table); +static void append_algorithm(TABLE_LIST *table, String *buff); bool get_lookup_field_values(THD *, COND *, TABLE_LIST *, LOOKUP_FIELD_VALUES *); @@ -3691,7 +3688,7 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) } -static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table) +COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table) { if (!cond) return (COND*) 0; @@ -8855,6 +8852,25 @@ ST_FIELD_INFO variables_fields_info[]= }; +ST_FIELD_INFO sysvars_fields_info[]= +{ + {"VARIABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"SESSION_VALUE", 1024, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"GLOBAL_VALUE", 1024, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"DEFAULT_VALUE", 1024, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"VARIABLE_SCOPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"VARIABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"VARIABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"NUMERIC_MIN_VALUE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"NUMERIC_MAX_VALUE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"NUMERIC_BLOCK_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"ENUM_VALUE_LIST", 65535, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {"READ_ONLY", 3, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"COMMAND_LINE_ARGUMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, 0}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0} +}; + + ST_FIELD_INFO processlist_fields_info[]= { {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE}, @@ -9174,6 +9190,8 @@ ST_SCHEMA_TABLE schema_tables[]= {"STATISTICS", stat_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE}, + {"SYSTEM_VARIABLES", sysvars_fields_info, create_schema_table, + fill_sysvars, make_old_format, 0, 0, -1, 0, 0}, {"TABLES", tables_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, OPTIMIZE_I_S_TABLE}, diff --git a/sql/sql_show.h b/sql/sql_show.h index 2b58fc45d4c..6373978ef49 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -112,6 +112,7 @@ void view_store_options(THD *thd, TABLE_LIST *table, String *buff); void init_fill_schema_files_row(TABLE* table); bool schema_table_store_record(THD *thd, TABLE *table); void initialize_information_schema_acl(); +COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table); ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); diff --git a/sql/sys_vars.h b/sql/sys_vars.h index 4f25da3902f..fa997416cbd 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -333,10 +333,14 @@ public: { var->save_result.ulonglong_value= global_var(ulong); } void global_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= option.def_value; } + uchar *valptr(THD *thd, ulong val) + { return (uchar*)typelib.type_names[val]; } uchar *session_value_ptr(THD *thd, const LEX_STRING *base) - { return (uchar*)typelib.type_names[session_var(thd, ulong)]; } + { return valptr(thd, session_var(thd, ulong)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) - { return (uchar*)typelib.type_names[global_var(ulong)]; } + { return valptr(thd, global_var(ulong)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, option.def_value); } }; /** @@ -547,7 +551,7 @@ public: {} protected: - virtual uchar *session_value_ptr(THD *thd, const LEX_STRING *base) + uchar *session_value_ptr(THD *thd, const LEX_STRING *base) { return (uchar*)thd->security_ctx->external_user; } @@ -705,10 +709,6 @@ public: { DBUG_ASSERT(FALSE); } - uchar *session_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar*) &session_var(thd, LEX_STRING); - } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) { DBUG_ASSERT(FALSE); @@ -790,6 +790,8 @@ public: DBUG_EXPLAIN_INITIAL(buf, sizeof(buf)); return (uchar*) thd->strdup(buf); } + uchar *default_value_ptr(THD *thd) + { return (uchar*)""; } }; #endif @@ -1164,16 +1166,14 @@ public: { var->save_result.ulonglong_value= global_var(ulonglong); } void global_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= option.def_value; } + uchar *valptr(THD *thd, ulonglong val) + { return (uchar*)flagset_to_string(thd, 0, val, typelib.type_names); } uchar *session_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar*)flagset_to_string(thd, 0, session_var(thd, ulonglong), - typelib.type_names); - } + { return valptr(thd, session_var(thd, ulonglong)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar*)flagset_to_string(thd, 0, global_var(ulonglong), - typelib.type_names); - } + { return valptr(thd, global_var(ulonglong)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, option.def_value); } }; /** @@ -1265,16 +1265,14 @@ public: { var->save_result.ulonglong_value= global_var(ulonglong); } void global_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= option.def_value; } + uchar *valptr(THD *thd, ulonglong val) + { return (uchar*)set_to_string(thd, 0, val, typelib.type_names); } uchar *session_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar*)set_to_string(thd, 0, session_var(thd, ulonglong), - typelib.type_names); - } + { return valptr(thd, session_var(thd, ulonglong)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar*)set_to_string(thd, 0, global_var(ulonglong), - typelib.type_names); - } + { return valptr(thd, global_var(ulonglong)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, option.def_value); } }; /** @@ -1368,39 +1366,39 @@ public: plugin_ref plugin= global_var(plugin_ref); var->save_result.plugin= plugin ? my_plugin_lock(thd, plugin) : 0; } - void global_save_default(THD *thd, set_var *var) + plugin_ref get_default(THD *thd) { - LEX_STRING pname; char *default_value= *reinterpret_cast<char**>(option.def_value); if (!default_value) - var->save_result.plugin= 0; - else - { - pname.str= default_value; - pname.length= strlen(pname.str); + return 0; - plugin_ref plugin; - if (plugin_type == MYSQL_STORAGE_ENGINE_PLUGIN) - plugin= ha_resolve_by_name(thd, &pname, false); - else - plugin= my_plugin_lock_by_name(thd, &pname, plugin_type); - DBUG_ASSERT(plugin); + LEX_STRING pname= { default_value, strlen(pname.str) }; + plugin_ref plugin; - var->save_result.plugin= my_plugin_lock(thd, plugin); - } + if (plugin_type == MYSQL_STORAGE_ENGINE_PLUGIN) + plugin= ha_resolve_by_name(thd, &pname, false); + else + plugin= my_plugin_lock_by_name(thd, &pname, plugin_type); + DBUG_ASSERT(plugin); + return my_plugin_lock(thd, plugin); } - uchar *session_value_ptr(THD *thd, const LEX_STRING *base) + + void global_save_default(THD *thd, set_var *var) { - plugin_ref plugin= session_var(thd, plugin_ref); - return (uchar*)(plugin ? thd->strmake(plugin_name(plugin)->str, - plugin_name(plugin)->length) : 0); + var->save_result.plugin= get_default(thd); } - uchar *global_value_ptr(THD *thd, const LEX_STRING *base) + + uchar *valptr(THD *thd, plugin_ref plugin) { - plugin_ref plugin= global_var(plugin_ref); return (uchar*)(plugin ? thd->strmake(plugin_name(plugin)->str, plugin_name(plugin)->length) : 0); } + uchar *session_value_ptr(THD *thd, const LEX_STRING *base) + { return valptr(thd, session_var(thd, plugin_ref)); } + uchar *global_value_ptr(THD *thd, const LEX_STRING *base) + { return valptr(thd, global_var(plugin_ref)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, get_default(thd)); } }; #if defined(ENABLED_DEBUG_SYNC) @@ -1466,6 +1464,8 @@ public: DBUG_ASSERT(FALSE); return 0; } + uchar *default_value_ptr(THD *thd) + { return (uchar*)""; } }; #endif /* defined(ENABLED_DEBUG_SYNC) */ @@ -1536,16 +1536,19 @@ public: { var->save_result.ulonglong_value= global_var(ulonglong) & bitmask; } void global_save_default(THD *thd, set_var *var) { var->save_result.ulonglong_value= option.def_value; } - uchar *session_value_ptr(THD *thd, const LEX_STRING *base) + + uchar *valptr(THD *thd, ulonglong val) { - thd->sys_var_tmp.my_bool_value= reverse_semantics ^ - ((session_var(thd, ulonglong) & bitmask) != 0); + thd->sys_var_tmp.my_bool_value= reverse_semantics ^ ((val & bitmask) != 0); return (uchar*) &thd->sys_var_tmp.my_bool_value; } + uchar *session_value_ptr(THD *thd, const LEX_STRING *base) + { return valptr(thd, session_var(thd, ulonglong)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) + { return valptr(thd, global_var(ulonglong)); } + uchar *default_value_ptr(THD *thd) { - thd->sys_var_tmp.my_bool_value= reverse_semantics ^ - ((global_var(ulonglong) & bitmask) != 0); + thd->sys_var_tmp.my_bool_value= option.def_value != 0; return (uchar*) &thd->sys_var_tmp.my_bool_value; } }; @@ -1612,6 +1615,11 @@ public: DBUG_ASSERT(FALSE); return 0; } + uchar *default_value_ptr(THD *thd) + { + thd->sys_var_tmp.ulonglong_value= 0; + return (uchar*) &thd->sys_var_tmp.ulonglong_value; + } }; @@ -1662,6 +1670,11 @@ public: DBUG_ASSERT(FALSE); return 0; } + uchar *default_value_ptr(THD *thd) + { + thd->sys_var_tmp.double_value= 0; + return (uchar*) &thd->sys_var_tmp.double_value; + } }; @@ -1698,6 +1711,7 @@ public: SYSVAR_ASSERT(is_readonly()); SYSVAR_ASSERT(on_update == 0); SYSVAR_ASSERT(size == sizeof(enum SHOW_COMP_OPTION)); + option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) { DBUG_ASSERT(FALSE); @@ -1790,16 +1804,14 @@ public: void **default_value= reinterpret_cast<void**>(option.def_value); var->save_result.ptr= *default_value; } + uchar *valptr(THD *thd, uchar *val) + { return val ? *(uchar**)(val+name_offset) : 0; } uchar *session_value_ptr(THD *thd, const LEX_STRING *base) - { - uchar *ptr= session_var(thd, uchar*); - return ptr ? *(uchar**)(ptr+name_offset) : 0; - } + { return valptr(thd, session_var(thd, uchar*)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) - { - uchar *ptr= global_var(uchar*); - return ptr ? *(uchar**)(ptr+name_offset) : 0; - } + { return valptr(thd, global_var(uchar*)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, *(uchar**)option.def_value); } }; /** @@ -1868,6 +1880,8 @@ public: var->save_result.time_zone= *(Time_zone**)(intptr)option.def_value; } + uchar *valptr(THD *thd, Time_zone *val) + { return (uchar *)(val->get_name()->ptr()); } uchar *session_value_ptr(THD *thd, const LEX_STRING *base) { /* @@ -1879,12 +1893,12 @@ public: (binlog code stores session value only). */ thd->time_zone_used= 1; - return (uchar *)(session_var(thd, Time_zone*)->get_name()->ptr()); + return valptr(thd, session_var(thd, Time_zone *)); } uchar *global_value_ptr(THD *thd, const LEX_STRING *base) - { - return (uchar *)(global_var(Time_zone*)->get_name()->ptr()); - } + { return valptr(thd, global_var(Time_zone*)); } + uchar *default_value_ptr(THD *thd) + { return valptr(thd, *(Time_zone**)option.def_value); } }; /** @@ -2048,6 +2062,8 @@ public: getopt.arg_type, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG, NULL, NULL, NULL) { + SYSVAR_ASSERT(getopt.id < 0); + SYSVAR_ASSERT(is_readonly()); option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) @@ -2095,6 +2111,8 @@ public: getopt.arg_type, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG, NULL, NULL, NULL) { + SYSVAR_ASSERT(getopt.id < 0); + SYSVAR_ASSERT(is_readonly()); option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) @@ -2166,6 +2184,8 @@ public: return NULL; } uchar *global_value_ptr(THD *thd, const LEX_STRING *base); + uchar *default_value_ptr(THD *thd) + { return 0; } }; @@ -2206,6 +2226,8 @@ public: return NULL; } uchar *global_value_ptr(THD *thd, const LEX_STRING *base); + uchar *default_value_ptr(THD *thd) + { return 0; } }; @@ -2221,6 +2243,8 @@ public: getopt.arg_type, SHOW_CHAR, 0, NULL, VARIABLE_NOT_IN_BINLOG, NULL, NULL, NULL) { + SYSVAR_ASSERT(getopt.id < 0); + SYSVAR_ASSERT(is_readonly()); option.var_type= GET_STR; } bool do_check(THD *thd, set_var *var) |