Skip to content

Commit c527a20

Browse files
committed
Making SHOW VARIABLES show boolean values as ON/OFF to match MySQL.
1 parent 3d7fa0e commit c527a20

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

sql/rowexec/show.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,20 @@ func (b *BaseBuilder) buildShowVariables(ctx *sql.Context, n *plan.ShowVariables
557557
continue
558558
}
559559
}
560-
rows = append(rows, sql.NewRow(k, v))
560+
561+
// SHOW VARIABLES displays boolean values as "ON" or "OFF".
562+
if boolVal, isBoolVal := v.(int8); isBoolVal {
563+
switch boolVal {
564+
case 0:
565+
rows = append(rows, sql.NewRow(k, "OFF"))
566+
case 1:
567+
rows = append(rows, sql.NewRow(k, "ON"))
568+
default:
569+
rows = append(rows, sql.NewRow(k, v))
570+
}
571+
} else {
572+
rows = append(rows, sql.NewRow(k, v))
573+
}
561574
}
562575

563576
sort.Slice(rows, func(i, j int) bool {

sql/variables/system_variables.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,24 @@ var systemVars = map[string]sql.SystemVariable{
12861286
// Integrators who provide binary logging may change this default.
12871287
Default: int8(0),
12881288
},
1289+
"log_replica_updates": &sql.MysqlSystemVariable{
1290+
Name: "log_replica_updates",
1291+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Persist),
1292+
Dynamic: true,
1293+
SetVarHintApplies: false,
1294+
Type: types.NewSystemBoolType("log_replica_updates"),
1295+
Default: int8(1),
1296+
},
1297+
"log_slave_updates": &sql.MysqlSystemVariable{
1298+
// TODO: This var should be an *alias* for log_replica_updates, but
1299+
// we don't support system variable aliases yet.
1300+
Name: "log_slave_updates",
1301+
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Persist),
1302+
Dynamic: true,
1303+
SetVarHintApplies: false,
1304+
Type: types.NewSystemBoolType("log_slave_updates"),
1305+
Default: int8(1),
1306+
},
12891307
"log_error": &sql.MysqlSystemVariable{
12901308
Name: "log_error",
12911309
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
@@ -2041,7 +2059,7 @@ var systemVars = map[string]sql.SystemVariable{
20412059
Dynamic: true,
20422060
SetVarHintApplies: false,
20432061
Type: types.NewSystemUintType("query_cache_size", 0, 18446744073709551615),
2044-
Default: int8(1),
2062+
Default: 1,
20452063
},
20462064
"query_cache_type": &sql.MysqlSystemVariable{
20472065
Name: "query_cache_type",
@@ -2933,31 +2951,31 @@ var systemVars = map[string]sql.SystemVariable{
29332951
Dynamic: true,
29342952
SetVarHintApplies: false,
29352953
Type: types.NewSystemIntType("validate_password.length", 0, 2147483647, false),
2936-
Default: int8(8),
2954+
Default: 8,
29372955
},
29382956
"validate_password.number_count": &sql.MysqlSystemVariable{
29392957
Name: "validate_password.number_count",
29402958
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
29412959
Dynamic: true,
29422960
SetVarHintApplies: false,
29432961
Type: types.NewSystemIntType("validate_password.number_count", 0, 2147483647, false),
2944-
Default: int8(1),
2962+
Default: 1,
29452963
},
29462964
"validate_password.mixed_case_count": &sql.MysqlSystemVariable{
29472965
Name: "validate_password.mixed_case_count",
29482966
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
29492967
Dynamic: true,
29502968
SetVarHintApplies: false,
29512969
Type: types.NewSystemIntType("validate_password.mixed_case_count", 0, 2147483647, false),
2952-
Default: int8(1),
2970+
Default: 1,
29532971
},
29542972
"validate_password.special_char_count": &sql.MysqlSystemVariable{
29552973
Name: "validate_password.special_char_count",
29562974
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
29572975
Dynamic: true,
29582976
SetVarHintApplies: false,
29592977
Type: types.NewSystemIntType("validate_password.special_char_count", 0, 2147483647, false),
2960-
Default: int8(1),
2978+
Default: 1,
29612979
},
29622980
"validate_user_plugins": &sql.MysqlSystemVariable{
29632981
Name: "validate_user_plugins",

0 commit comments

Comments
 (0)