I am not looking to make a new set method and never intended to. My
set method already works and uses existing coded functions. I think
there is a misunderstanding in why I need it.
I already use the standard check, set and update methods. These
however do not give me the current value for a setting that I need to
reset back to at the end. What I wanted was how to get the current
value. I figured since when using set_default the offset says what
the variable to go to in the System Var struct. Such as this value=
&(global_system_variables.*offset); I need that value but I need
the session variable values in order to reset it later just obviously
not inside global_system_variables. I need to pull the session
variables from something like (reset_value=thd->variables.*offset) in
looking at other set_default both have the same variable layout and
will use the same *offset in order to get to the variable I will need
to reset. I will not be using this method to reset only to get the
value for the reset after I have the value I will use the standard SET
function to both set and reset the settings.
I traversed the SHOW SESSION VARIABLES from the parse tree execution
and it will not work as it seems to use a select method and without
modification would output not return the values I need. I do not know
of other ways to get the current value of the session variable I am to
temporarily change. If there is another call I can perform I am open
to it. I have yet though to find a simple function to get a current
SESSION setting. I do not need to use set_default at all I was
simply following the set functions and this seems to show how to get
to the values.
If no easy way I figure I will be using the set_default as a template
to make functions that simply return the values I need to reset back
to. I figure that this is not needed as a single line such as
reset_value=thd->variables.*offset should work. I am inserting this
into a set_var in order to reset my values after statement execution.
I cannot use set_default as the setting may have been changed before
the statement that uses my new feature and the requirement is to reset
back to the previous setting not the default.
On Jul 12, 2009, at 5:09 AM, Sergei Golubchik wrote:
> Hi, Joseph!
> On Jul 11, Joseph Lukas wrote:
>> Ok so I think I found how to get the value for the variables as
>> currently set. However I am having trouble getting it to get the
>> In looking at the set_default which gets the global_system_variable
>> value I cannot find anywhere what *offset is nor any place it is
>> defined. I tried a search of all files in the MySQL repository folder
>> but with 631 different possible files is a little bit hard.
>> What I want to do is have set function check if the variable is valid
>> then use thd->variables.<variable> to get the value. As in searching
>> this is the location of system variables for the session. I looked
>> the definition and it does not help that the names are a little
>> different. Such as sort_buffer_size is sortbuffer_size in the struct
>> for the variables.
> if you look at how SET @@variable= is parsed in sql_yacc.yy, you'll
> the function to check if the variable is valid.
> It's find_sys_var().
>> Implemented in one set default is in set_var.cc
>> void sys_var_thd_storage_engine::set_default(THD *thd,
>> enum_var_type type)
>> plugin_ref old_value, new_value, *value;
>> if (type == OPT_GLOBAL)
>> value= &(global_system_variables.*offset);
>> new_value= ha_lock_engine(NULL, myisam_hton);
>> value= &(thd->variables.*offset);
>> new_value= my_plugin_lock(NULL,
>> old_value= *value;
>> *value= new_value;
>> plugin_unlock(NULL, old_value);
>> If I can use *offset in the same way in another file I should have no
>> problem but I have to know what the *offset is defined as and how it
>> sets to the proper variable.
> You cannot use *offset, it's not even public in some classes.
> You should use public methods like check(), uppate(), and
>> Can somebody please help explain where *offset is setup or how it
>> works above? This is my current set back and I am getting very
> Please, don't invent new ways to bypass the interface, SET is already
> implemented, use the existing functions and solutions.
> Regards / Mit vielen Grüßen,
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
> / /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server
> /_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München
> <___/ Sonnenallee 1, 85551 Kirchheim-
> Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
> Vorsitzender des Aufsichtsrates: Martin Häring