@@ -159,23 +159,20 @@ func (s *BaseSession) InitSessionVariable(ctx *Context, sysVarName string, value
159159 return s .setSessVar (ctx , sysVar , value , true )
160160}
161161
162- // InitSessionDefaultVariable implements the Session interface and is used to initialize variables (Including read-only variables)
163- func (s * BaseSession ) InitSessionDefaultVariable (ctx * Context , sysVarName string , value interface {}) error {
162+ // InitSessionVariableDefault implements the Session interface and is used to initialize variables (Including read-only variables)
163+ func (s * BaseSession ) InitSessionVariableDefault (ctx * Context , sysVarName string , value interface {}) error {
164164 sysVar , _ , ok := SystemVariables .GetGlobal (sysVarName )
165165 if ! ok {
166166 return ErrUnknownSystemVariable .New (sysVarName )
167167 }
168168
169- sysVarName = strings .ToLower (sysVarName )
170- val , ok := s .systemVars [sysVarName ]
171- if ok && val .Val != sysVar .GetDefault () {
172- return ErrSystemVariableReinitialized .New (sysVarName )
173- }
174- svv , err := sysVar .InitValue (ctx , "" , value , false )
169+ sysVar .SetDefault (value )
170+ svv , err := sysVar .InitValue (ctx , sysVar .GetDefault (), value , false )
175171 if err != nil {
176172 return err
177173 }
178- svv .Var .SetDefault (value )
174+
175+ sysVarName = strings .ToLower (sysVarName )
179176 s .systemVars [sysVarName ] = svv
180177 if sysVarName == characterSetResultsSysVarName {
181178 s .charset = CharacterSet_Unspecified
@@ -230,6 +227,22 @@ func (s *BaseSession) GetSessionVariable(ctx *Context, sysVarName string) (inter
230227 return sysVar .Val , nil
231228}
232229
230+ // GetSessionVariableDefault implements the Session interface.
231+ func (s * BaseSession ) GetSessionVariableDefault (ctx * Context , sysVarName string ) (interface {}, error ) {
232+ sysVarName = strings .ToLower (sysVarName )
233+ sysVar , ok := s .systemVars [sysVarName ]
234+ if ! ok {
235+ return nil , ErrUnknownSystemVariable .New (sysVarName )
236+ }
237+ // TODO: this is duplicated from within variables.globalSystemVariables, suggesting the need for an interface
238+ if sysType , ok := sysVar .Var .GetType ().(SetType ); ok {
239+ if sv , ok := sysVar .Var .GetDefault ().(uint64 ); ok {
240+ return sysType .BitsToString (sv )
241+ }
242+ }
243+ return sysVar .Var .GetDefault (), nil
244+ }
245+
233246// GetUserVariable implements the Session interface.
234247func (s * BaseSession ) GetUserVariable (ctx * Context , varName string ) (Type , interface {}, error ) {
235248 return s .userVars .GetUserVariable (ctx , varName )
0 commit comments