Skip to content

Commit 49152d3

Browse files
committed
rm unused replaceAll for \Z
1 parent 07b76fa commit 49152d3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

enginetest/queries/alter_table_queries.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,21 @@ var AlterTableScripts = []ScriptTest{
10471047
},
10481048
},
10491049
},
1050+
{
1051+
Name: "alter table supports non-escaped \\Z",
1052+
SetUpScript: []string{
1053+
"create table t (i int);",
1054+
`alter table t modify column i int comment "ctrlz \\Z \\Z"`,
1055+
},
1056+
Assertions: []ScriptTestAssertion{
1057+
{
1058+
Query: "show create table t",
1059+
Expected: []sql.Row{{"t", "CREATE TABLE `t` (\n" +
1060+
" `i` int COMMENT 'ctrlz \\Z \\Z'\n" +
1061+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
1062+
},
1063+
},
1064+
},
10501065
}
10511066

10521067
var RenameTableScripts = []ScriptTest{

enginetest/queries/create_table_queries.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ var CreateTableQueries = []WriteQueryTest{
5858
SelectQuery: "SHOW CREATE TABLE tableWithComment",
5959
ExpectedSelect: []sql.Row{{"tableWithComment", "CREATE TABLE `tableWithComment` (\n `pk` int\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='newline \\n | return \\r | backslash \\\\ | NUL \\0 x00 | ctrlz \x1A x1A'"}},
6060
},
61+
{
62+
WriteQuery: `create table tableWithComment (pk int) COMMENT "ctrlz \Z \x1A \\Z \\\Z"`,
63+
ExpectedWriteResult: []sql.Row{{types.NewOkResult(0)}},
64+
SelectQuery: "SHOW CREATE TABLE tableWithComment",
65+
ExpectedSelect: []sql.Row{{"tableWithComment", "CREATE TABLE `tableWithComment` (\n `pk` int\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='ctrlz \x1A x1A \\\\Z \\\\\x1A'"}},
66+
},
6167
{
6268
WriteQuery: `create table tableWithColumnComment (pk int COMMENT "'")`,
6369
ExpectedWriteResult: []sql.Row{{types.NewOkResult(0)}},

sql/parser.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ func EscapeSpecialCharactersInComment(comment string) string {
138138
commentString := comment
139139
commentString = strings.ReplaceAll(commentString, "'", "''")
140140
commentString = strings.ReplaceAll(commentString, "\\", "\\\\")
141-
commentString = strings.ReplaceAll(commentString, "\\Z", "\x1A") // MYSQL handles \\ first, then \Z
142141
commentString = strings.ReplaceAll(commentString, "\"", "\\\"")
143142
commentString = strings.ReplaceAll(commentString, "\n", "\\n")
144143
commentString = strings.ReplaceAll(commentString, "\r", "\\r")

0 commit comments

Comments
 (0)