Skip to content

Commit 7d0507a

Browse files
authored
fix: make SET system type case-insensitive (#2702)
1 parent 58d51b3 commit 7d0507a

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

enginetest/queries/insert_queries.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,10 +1278,10 @@ var InsertScripts = []ScriptTest{
12781278
},
12791279
},
12801280
{
1281-
Name: "sql_mode=NO_AUTO_VALUE_ON_ZERO",
1281+
Name: "sql_mode=NO_auto_value_ON_ZERO",
12821282
SetUpScript: []string{
12831283
"set @old_sql_mode=@@sql_mode;",
1284-
"set @@sql_mode='NO_AUTO_VALUE_ON_ZERO';",
1284+
"set @@sql_mode='NO_auto_value_ON_ZERO';",
12851285
"create table auto (i int auto_increment, index (i));",
12861286
"create table auto_pk (i int auto_increment primary key);",
12871287
},

sql/expression/function/coalesce_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestCoalesce(t *testing.T) {
213213
{
214214
name: "coalesce(sysSet)",
215215
input: []sql.Expression{
216-
expression.NewLiteral("abc", types.NewSystemSetType("str1", "abc")),
216+
expression.NewLiteral("abc", types.NewSystemSetType("str1", sql.Collation_Default, "abc")),
217217
},
218218
expected: "abc",
219219
typ: types.MustCreateSetType([]string{"abc"}, sql.Collation_Default),

sql/types/system_set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ var _ sql.SystemVariableType = systemSetType{}
3434
var _ sql.CollationCoercible = systemSetType{}
3535

3636
// NewSystemSetType returns a new systemSetType.
37-
func NewSystemSetType(varName string, values ...string) sql.SystemVariableType {
38-
return systemSetType{MustCreateSetType(values, sql.Collation_Default), varName}
37+
func NewSystemSetType(varName string, collation sql.CollationID, values ...string) sql.SystemVariableType {
38+
return systemSetType{MustCreateSetType(values, collation), varName}
3939
}
4040

4141
// Compare implements Type interface.

sql/types/typecheck_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package types
1717
import (
1818
"testing"
1919

20+
"github.com/dolthub/go-mysql-server/sql"
2021
"github.com/stretchr/testify/assert"
2122
)
2223

@@ -93,6 +94,6 @@ func TestSystemTypesIsSet(t *testing.T) {
9394
assert.False(t, IsSet(systemUintType{}))
9495
assert.False(t, IsSet(systemDoubleType{}))
9596
assert.False(t, IsSet(systemEnumType{}))
96-
assert.True(t, IsSet(NewSystemSetType("", "")))
97+
assert.True(t, IsSet(NewSystemSetType("", sql.Collation_Default, "")))
9798
assert.False(t, IsSet(systemStringType{}))
9899
}

sql/variables/system_variables.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ var systemVars = map[string]sql.SystemVariable{
12831283
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
12841284
Dynamic: true,
12851285
SetVarHintApplies: false,
1286-
Type: types.NewSystemSetType("log_output", "TABLE", "FILE", "NONE"),
1286+
Type: types.NewSystemSetType("log_output", sql.Collation_utf8mb4_0900_ai_ci, "TABLE", "FILE", "NONE"),
12871287
Default: "FILE",
12881288
},
12891289
"log_queries_not_using_indexes": &sql.MysqlSystemVariable{
@@ -1951,7 +1951,7 @@ var systemVars = map[string]sql.SystemVariable{
19511951
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Global),
19521952
Dynamic: true,
19531953
SetVarHintApplies: false,
1954-
Type: types.NewSystemSetType("protocol_compression_algorithms", "zlib", "zstd", "uncompressed"),
1954+
Type: types.NewSystemSetType("protocol_compression_algorithms", sql.Collation_latin1_swedish_ci, "zlib", "zstd", "uncompressed"),
19551955
Default: "zlib,zstd,uncompressed",
19561956
},
19571957
"protocol_version": &sql.MysqlSystemVariable{
@@ -2430,7 +2430,7 @@ var systemVars = map[string]sql.SystemVariable{
24302430
Scope: sql.GetMysqlScope(sql.SystemVariableScope_Both),
24312431
Dynamic: true,
24322432
SetVarHintApplies: true,
2433-
Type: types.NewSystemSetType("sql_mode", "ALLOW_INVALID_DATES", "ANSI_QUOTES", "ERROR_FOR_DIVISION_BY_ZERO", "HIGH_NOT_PRECEDENCE", "IGNORE_SPACE", "NO_AUTO_VALUE_ON_ZERO", "NO_BACKSLASH_ESCAPES", "NO_DIR_IN_CREATE", "NO_ENGINE_SUBSTITUTION", "NO_UNSIGNED_SUBTRACTION", "NO_ZERO_DATE", "NO_ZERO_IN_DATE", "ONLY_FULL_GROUP_BY", "PAD_CHAR_TO_FULL_LENGTH", "PIPES_AS_CONCAT", "REAL_AS_FLOAT", "STRICT_ALL_TABLES", "STRICT_TRANS_TABLES", "TIME_TRUNCATE_FRACTIONAL", "TRADITIONAL", "ANSI"),
2433+
Type: types.NewSystemSetType("sql_mode", sql.Collation_utf8mb4_0900_ai_ci, "ALLOW_INVALID_DATES", "ANSI_QUOTES", "ERROR_FOR_DIVISION_BY_ZERO", "HIGH_NOT_PRECEDENCE", "IGNORE_SPACE", "NO_AUTO_VALUE_ON_ZERO", "NO_BACKSLASH_ESCAPES", "NO_DIR_IN_CREATE", "NO_ENGINE_SUBSTITUTION", "NO_UNSIGNED_SUBTRACTION", "NO_ZERO_DATE", "NO_ZERO_IN_DATE", "ONLY_FULL_GROUP_BY", "PAD_CHAR_TO_FULL_LENGTH", "PIPES_AS_CONCAT", "REAL_AS_FLOAT", "STRICT_ALL_TABLES", "STRICT_TRANS_TABLES", "TIME_TRUNCATE_FRACTIONAL", "TRADITIONAL", "ANSI"),
24342434
Default: sql.DefaultSqlMode,
24352435
},
24362436
"sql_notes": &sql.MysqlSystemVariable{

0 commit comments

Comments
 (0)