• Annamalai Gurusami's avatar
    Bug #16044655 CRASH: SETTING DEFAULT VALUE FOR SOME VARIABLES · 436d8402
    Annamalai Gurusami authored
    Problem:
    
    When a system variable is being set to the DEFAULT value, the server
    segfaults if there is no 'default' defined for that system variable.
    For example, for the following statements server segfaults.
    
    set session rand_seed1=DEFAULT;
    set session rand_seed2=DEFAULT;
    
    Analysis:
    
    The class sys_var represents one system variable.  The class set_var represents
    one system variable that is to be updated.   The class set_var contains two 
    pieces of information, the system variable to object (set_var::var) member
    and the value to be updated (set_var::value).
    
    When the given value is 'default', the set_var::value will be NULL.
    
    To update a system variable the member set_var::update() will be called, 
    which in turn will call sys_var::update() or sys_var::set_default() depending
    on whether a value has been provided or not.  
    
    If the sys_var::set_default() is called, then the default value is obtained
    either from the session scope or the global scope.  This default value is
    stored in a local temporary set_var object and then passed on to the 
    sys_var::update() call.  A local temporary set_var object is needed because
    sys_var::set_default() does not take set_var as an argument.
    
    In the given scenario, the set_var::update() called sys_var::set_default().
    And this sys_var::set_default() obtains the default value and then calls
    sys_var::update().  To pass this value to sys_var::update() a local set_var
    object is being created.   While creating this local set_var object, its member
    set_var::var was incorrectly left as 0.  
    
    Solution:
    
    Instead of creating a local set_var object, the sys_var::set_default() can take
    the set_var object as an argument just like sys_var::update().
    
    rb://1996 approved by Nirbhay and Ramil.
    
    436d8402
set_var.h 11.1 KB