Skip to content

Commit 329ce60

Browse files
Scott Lanningbramp
authored andcommitted
allow SET type in column definitions
(I'm replaying query.log queries through vtexplain again recently, so stirring up vtexplain errors.) I left it using EnumValues in ColumnType, not sure if that's acceptable. In terms of the grammar, enum and set are the same: https://dev.mysql.com/doc/refman/5.7/en/create-table.html In terms of values, they're a bit different: https://dev.mysql.com/doc/refman/5.7/en/constraint-enum.html Currently I think EnumValues is only "cosmetic" (for Format), so I kinda shrug about it. Signed-off-by: Scott Lanning <[email protected]>
1 parent bfea8c7 commit 329ce60

File tree

4 files changed

+1738
-1718
lines changed

4 files changed

+1738
-1718
lines changed

ast.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@ func (ct *ColumnType) SQLType() querypb.Type {
10201020
return sqltypes.Bit
10211021
case keywordStrings[ENUM]:
10221022
return sqltypes.Enum
1023+
case keywordStrings[SET]:
1024+
return sqltypes.Set
10231025
case keywordStrings[JSON]:
10241026
return sqltypes.TypeJSON
10251027
}

parse_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,13 @@ func TestCreateTable(t *testing.T) {
15651565
" col_text text character set ascii collate ascii_bin,\n" +
15661566
" col_json json,\n" +
15671567
" col_enum enum('a', 'b', 'c', 'd'),\n" +
1568-
" col_enum enum('a', 'b', 'c', 'd') character set ascii,\n" +
1569-
" col_enum enum('a', 'b', 'c', 'd') collate ascii_bin,\n" +
1570-
" col_enum enum('a', 'b', 'c', 'd') character set ascii collate ascii_bin\n" +
1568+
" col_enum2 enum('a', 'b', 'c', 'd') character set ascii,\n" +
1569+
" col_enum3 enum('a', 'b', 'c', 'd') collate ascii_bin,\n" +
1570+
" col_enum4 enum('a', 'b', 'c', 'd') character set ascii collate ascii_bin,\n" +
1571+
" col_set set('a', 'b', 'c', 'd'),\n" +
1572+
" col_set2 set('a', 'b', 'c', 'd') character set ascii,\n" +
1573+
" col_set3 set('a', 'b', 'c', 'd') collate ascii_bin,\n" +
1574+
" col_set4 set('a', 'b', 'c', 'd') character set ascii collate ascii_bin\n" +
15711575
")",
15721576

15731577
// test defaults

0 commit comments

Comments
 (0)