@@ -16,7 +16,6 @@ package rowexec
1616
1717import (
1818 "errors"
19- "fmt"
2019 "io"
2120 "strings"
2221
@@ -393,21 +392,18 @@ func setSystemVar(ctx *sql.Context, sysVar *expression.SystemVar, right sql.Expr
393392 if err != nil {
394393 return err
395394 }
396-
397395 err = validateSystemVariableValue (sysVar .Name , val )
398396 if err != nil {
399397 return err
400398 }
399+ err = sysVar .Scope .SetValue (ctx , sysVar .Name , val )
400+ if err != nil {
401+ return err
402+ }
401403
402404 // Setting `character_set_connection` and `collation_connection` will set the corresponding variable
403405 // Setting `character_set_server` and `collation_server` will set the corresponding variable
404406 switch strings .ToLower (sysVar .Name ) {
405- case "sql_mode" :
406- val , err = sql .ConvertSqlModeBitmask (val )
407- if err != nil {
408- return err
409- }
410- return sysVar .Scope .SetValue (ctx , sysVar .Name , val )
411407 case "character_set_connection" :
412408 if val == nil {
413409 return sysVar .Scope .SetValue (ctx , "collation_connection" , val )
@@ -424,16 +420,8 @@ func setSystemVar(ctx *sql.Context, sysVar *expression.SystemVar, right sql.Expr
424420 collationName := charset .DefaultCollation ().Name ()
425421 return sysVar .Scope .SetValue (ctx , "collation_connection" , collationName )
426422 case "collation_connection" :
427- val , err = sql .ConvertCollationID (val )
428- if err != nil {
429- return err
430- }
431- err = sysVar .Scope .SetValue (ctx , sysVar .Name , val )
432- if err != nil {
433- return err
434- }
435423 if val == nil {
436- return sysVar .Scope .SetValue (ctx , "character_set_connection" , nil )
424+ return sysVar .Scope .SetValue (ctx , "character_set_connection" , val )
437425 }
438426 valStr , ok := val .(string )
439427 if ! ok {
@@ -462,16 +450,8 @@ func setSystemVar(ctx *sql.Context, sysVar *expression.SystemVar, right sql.Expr
462450 collationName := charset .DefaultCollation ().Name ()
463451 return sysVar .Scope .SetValue (ctx , "collation_server" , collationName )
464452 case "collation_server" :
465- val , err = sql .ConvertCollationID (val )
466- if err != nil {
467- return err
468- }
469- err = sysVar .Scope .SetValue (ctx , sysVar .Name , val )
470- if err != nil {
471- return err
472- }
473453 if val == nil {
474- return sysVar .Scope .SetValue (ctx , "character_set_server" , nil )
454+ return sysVar .Scope .SetValue (ctx , "character_set_server" , val )
475455 }
476456 valStr , ok := val .(string )
477457 if ! ok {
@@ -484,19 +464,6 @@ func setSystemVar(ctx *sql.Context, sysVar *expression.SystemVar, right sql.Expr
484464 }
485465 charsetName := collation .CharacterSet ().Name ()
486466 return sysVar .Scope .SetValue (ctx , "character_set_server" , charsetName )
487- case "collation_database" :
488- val , err = sql .ConvertCollationID (val )
489- if err != nil {
490- return err
491- }
492- return sysVar .Scope .SetValue (ctx , sysVar .Name , val )
493- case "lc_time_names" :
494- // TODO: convert numeric locale ID to locale name
495- switch val .(type ) {
496- case int8 , int16 , int , int32 , int64 , uint8 , uint16 , uint , uint32 , uint64 :
497- val = fmt .Sprintf ("%v" , val )
498- }
499- return sysVar .Scope .SetValue (ctx , sysVar .Name , val )
500467 }
501468 return nil
502469}
0 commit comments