@@ -40,6 +40,42 @@ var CreateTableQueries = []WriteQueryTest{
4040 SelectQuery : "SHOW CREATE TABLE tableWithComment" ,
4141 ExpectedSelect : []sql.Row {{"tableWithComment" , "CREATE TABLE `tableWithComment` (\n `pk` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT='~!@ #$ %^ &* ()'" }},
4242 },
43+ {
44+ WriteQuery : `create table tableWithComment (pk int) COMMENT "'"` ,
45+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
46+ SelectQuery : "SHOW CREATE TABLE tableWithComment" ,
47+ ExpectedSelect : []sql.Row {{"tableWithComment" , "CREATE TABLE `tableWithComment` (\n `pk` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT=''''" }},
48+ },
49+ {
50+ WriteQuery : `create table tableWithComment (pk int) COMMENT "\'"` ,
51+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
52+ SelectQuery : "SHOW CREATE TABLE tableWithComment" ,
53+ ExpectedSelect : []sql.Row {{"tableWithComment" , "CREATE TABLE `tableWithComment` (\n `pk` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT=''''" }},
54+ },
55+ {
56+ WriteQuery : `create table tableWithComment (pk int) COMMENT "newline \n | return \r | backslash \\ | NUL \0 \x00"` ,
57+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
58+ SelectQuery : "SHOW CREATE TABLE tableWithComment" ,
59+ 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'" }},
60+ },
61+ {
62+ WriteQuery : `create table tableWithColumnComment (pk int COMMENT "'")` ,
63+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
64+ SelectQuery : "SHOW CREATE TABLE tableWithColumnComment" ,
65+ ExpectedSelect : []sql.Row {{"tableWithColumnComment" , "CREATE TABLE `tableWithColumnComment` (\n `pk` int COMMENT ''''\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
66+ },
67+ {
68+ WriteQuery : `create table tableWithColumnComment (pk int COMMENT "\'")` ,
69+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
70+ SelectQuery : "SHOW CREATE TABLE tableWithColumnComment" ,
71+ ExpectedSelect : []sql.Row {{"tableWithColumnComment" , "CREATE TABLE `tableWithColumnComment` (\n `pk` int COMMENT ''''\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
72+ },
73+ {
74+ WriteQuery : `create table tableWithColumnComment (pk int COMMENT "newline \n | return \r | backslash \\ | NUL \0 \x00")` ,
75+ ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
76+ SelectQuery : "SHOW CREATE TABLE tableWithColumnComment" ,
77+ ExpectedSelect : []sql.Row {{"tableWithColumnComment" , "CREATE TABLE `tableWithColumnComment` (\n `pk` int COMMENT 'newline \\ n | return \\ r | backslash \\ \\ | NUL \\ 0 x00'\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
78+ },
4379 {
4480 WriteQuery : `create table floattypedefs (a float(10), b float(10, 2), c double(10, 2))` ,
4581 ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
@@ -1118,18 +1154,6 @@ var CreateTableAutoIncrementTests = []ScriptTest{
11181154}
11191155
11201156var BrokenCreateTableQueries = []WriteQueryTest {
1121- {
1122- // TODO: We don't support table comments that contain single quotes due to how table options are parsed.
1123- // Vitess parses them, but turns any double quotes into single quotes and puts all table options back
1124- // into a string that GMS has to reparse. This means we can't tell if the single quote is the end of
1125- // the quoted string, or if it was a single quote inside of double quotes and needs to be escaped.
1126- // To fix this, Vitess should return the parsed table options as structured data, instead of as a
1127- // single string.
1128- WriteQuery : `create table tableWithComment (pk int) COMMENT "'"` ,
1129- ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
1130- SelectQuery : "SHOW CREATE TABLE tableWithComment" ,
1131- ExpectedSelect : []sql.Row {{"tableWithComment" , "CREATE TABLE `tableWithComment` (\n `pk` int\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin COMMENT=''''" }},
1132- },
11331157 {
11341158 WriteQuery : `create table t1 (b blob, primary key(b(1)))` ,
11351159 ExpectedWriteResult : []sql.Row {{types .NewOkResult (0 )}},
0 commit comments