@@ -1029,12 +1029,58 @@ var AlterTableScripts = []ScriptTest{
1029
1029
},
1030
1030
},
1031
1031
},
1032
+ {
1033
+ Name : "alter table comment" ,
1034
+ SetUpScript : []string {
1035
+ "create table t (i int)" ,
1036
+ "create table tableWithComment (i int) comment = 'comment'" ,
1037
+ },
1038
+ Assertions : []ScriptTestAssertion {
1039
+ {
1040
+ Query : "show create table t" ,
1041
+ Expected : []sql.Row {{
1042
+ "t" ,
1043
+ "CREATE TABLE `t` (\n `i` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" ,
1044
+ }},
1045
+ },
1046
+ {
1047
+ Query : "show create table tableWithComment" ,
1048
+ Expected : []sql.Row {{
1049
+ "tableWithComment" ,
1050
+ "CREATE TABLE `tableWithComment` (\n `i` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='comment'" ,
1051
+ }},
1052
+ },
1053
+ {
1054
+ Query : "alter table t comment = 'new comment'" ,
1055
+ Expected : []sql.Row {{types .NewOkResult (0 )}},
1056
+ },
1057
+ {
1058
+ Query : "alter table tableWithComment comment = 'new comment'" ,
1059
+ Expected : []sql.Row {{types .NewOkResult (0 )}},
1060
+ },
1061
+ {
1062
+ Query : "show create table t" ,
1063
+ Expected : []sql.Row {{
1064
+ "t" ,
1065
+ "CREATE TABLE `t` (\n `i` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='new comment'" ,
1066
+ }},
1067
+ },
1068
+ {
1069
+ Query : "show create table tableWithComment" ,
1070
+ Expected : []sql.Row {{
1071
+ "tableWithComment" ,
1072
+ "CREATE TABLE `tableWithComment` (\n `i` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='new comment'" ,
1073
+ }},
1074
+ },
1075
+ },
1076
+ },
1032
1077
{
1033
1078
Name : "alter table comments are escaped" ,
1034
1079
SetUpScript : []string {
1035
1080
"create table t (i int);" ,
1036
1081
`alter table t modify column i int comment "newline \n | return \r | backslash \\ | NUL \0 \x00 | ctrlz \Z \x1A"` ,
1037
1082
`alter table t add column j int comment "newline \n | return \r | backslash \\ | NUL \0 \x00 | ctrlz \Z \x1A"` ,
1083
+ `alter table t comment = "newline \n | return \r | backslash \\ | NUL \0 \x00 | ctrlz \Z \x1A"` ,
1038
1084
},
1039
1085
Assertions : []ScriptTestAssertion {
1040
1086
{
@@ -1043,7 +1089,7 @@ var AlterTableScripts = []ScriptTest{
1043
1089
"t" ,
1044
1090
"CREATE TABLE `t` (\n `i` int COMMENT 'newline \\ n | return \\ r | backslash \\ \\ | NUL \\ 0 x00 | ctrlz \x1A x1A'," +
1045
1091
"\n `j` int COMMENT 'newline \\ n | return \\ r | backslash \\ \\ | NUL \\ 0 x00 | ctrlz \x1A x1A'\n " +
1046
- ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
1092
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='newline \\ n | return \\ r | backslash \\ \\ | NUL \\ 0 x00 | ctrlz \u001A x1A' " }},
1047
1093
},
1048
1094
},
1049
1095
},
0 commit comments