Skip to content

Commit be8d29a

Browse files
committed
fix sys var getter
1 parent d3067d0 commit be8d29a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

sql/variables/system_variables.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (sv *globalSystemVariables) AssignValues(vals map[string]interface{}) error
7474
defer sv.mutex.Unlock()
7575
for varName, val := range vals {
7676
varName = strings.ToLower(varName)
77-
sysVar, ok := systemVars[varName]
77+
sysVar, ok := getSystemVar(varName)
7878
if !ok {
7979
return sql.ErrUnknownSystemVariable.New(varName)
8080
}
@@ -104,7 +104,7 @@ func (sv *globalSystemVariables) GetGlobal(name string) (sql.SystemVariable, int
104104
sv.mutex.RLock()
105105
defer sv.mutex.RUnlock()
106106
name = strings.ToLower(name)
107-
v, ok := systemVars[name]
107+
v, ok := getSystemVar(name)
108108
if !ok {
109109
return nil, nil, false
110110
}
@@ -141,7 +141,7 @@ func (sv *globalSystemVariables) SetGlobal(ctx *sql.Context, name string, val in
141141
sv.mutex.Lock()
142142
defer sv.mutex.Unlock()
143143
name = strings.ToLower(name)
144-
sysVar, ok := systemVars[name]
144+
sysVar, ok := getSystemVar(name)
145145
if !ok {
146146
return sql.ErrUnknownSystemVariable.New(name)
147147
}
@@ -199,6 +199,19 @@ func getHostname() string {
199199
return hostname
200200
}
201201

202+
// getSystemVar looks up a system variable by name in both systemVars and mariadbSystemVars.
203+
// Returns the variable and true if found, or nil and false if not found.
204+
func getSystemVar(name string) (sql.SystemVariable, bool) {
205+
name = strings.ToLower(name)
206+
if v, ok := systemVars[name]; ok {
207+
return v, true
208+
}
209+
if v, ok := mariadbSystemVars[name]; ok {
210+
return v, true
211+
}
212+
return nil, false
213+
}
214+
202215
// systemVars is the internal collection of all MySQL system variables according to the following pages:
203216
// https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html
204217
// https://dev.mysql.com/doc/refman/8.0/en/replication-options-gtids.html

0 commit comments

Comments
 (0)