Skip to content

Commit d3067d0

Browse files
committed
amend init global sys vars
1 parent 183764d commit d3067d0

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

sql/variables/system_variables.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package variables
1616

1717
import (
1818
"fmt"
19-
"maps"
2019
"math"
2120
"os"
2221
"strings"
@@ -167,25 +166,31 @@ func (sv *globalSystemVariables) GetAllGlobalVariables() map[string]interface{}
167166
return m
168167
}
169168

170-
// InitSystemVariables resets the systemVars singleton in the sql package
169+
// InitSystemVariables resets the global systemVars singleton in the sql package
171170
func InitSystemVariables() {
172-
vars := &globalSystemVariables{
173-
mutex: &sync.RWMutex{},
174-
sysVarVals: make(map[string]sql.SystemVarValue, len(systemVars)),
171+
out := &globalSystemVariables{
172+
mutex: &sync.RWMutex{},
173+
sysVarVals: make(map[string]sql.SystemVarValue,
174+
len(systemVars)+len(mariadbSystemVars)),
175175
}
176-
for _, sysVar := range systemVars {
177-
vars.sysVarVals[sysVar.GetName()] = sql.SystemVarValue{
178-
Var: sysVar,
179-
Val: sysVar.GetDefault(),
176+
177+
for _, vars := range []map[string]sql.SystemVariable{
178+
systemVars,
179+
mariadbSystemVars,
180+
} {
181+
for _, sysVar := range vars {
182+
out.sysVarVals[sysVar.GetName()] = sql.SystemVarValue{
183+
Var: sysVar,
184+
Val: sysVar.GetDefault(),
185+
}
180186
}
181187
}
182-
sql.SystemVariables = vars
188+
sql.SystemVariables = out
183189
}
184190

185191
// init initializes SystemVariables as it functions as a global variable.
186192
// TODO: get rid of me, make this construction the responsibility of the engine
187193
func init() {
188-
maps.Copy(systemVars, mariadbSystemVars)
189194
InitSystemVariables()
190195
}
191196

0 commit comments

Comments
 (0)