@@ -993,6 +993,11 @@ var TransactionTests = []TransactionTest{
993993 Query : "/* client a */ select * from t2" ,
994994 Expected : []sql.Row {{0 , 0 , nil }},
995995 },
996+
997+ {
998+ Query : "/* client a */ START TRANSACTION READ ONLY" ,
999+ Expected : []sql.Row {},
1000+ },
9961001 {
9971002 Query : "/* client a */ create temporary table tmp2(pk int primary key)" ,
9981003 ExpectedErr : sql .ErrReadOnlyTransaction ,
@@ -1065,7 +1070,7 @@ var TransactionTests = []TransactionTest{
10651070 },
10661071 },
10671072 {
1068- Name : "ddl queries are implicitly committed" ,
1073+ Name : "create table queries are implicitly committed" ,
10691074 Assertions : []ScriptTestAssertion {
10701075 {
10711076 Query : "/* client a */ set @@autocommit = 0;" ,
@@ -1080,10 +1085,6 @@ var TransactionTests = []TransactionTest{
10801085 Query : "/* client a */ create table t (pk int primary key);" ,
10811086 Expected : []sql.Row {{types.OkResult {}}},
10821087 },
1083- {
1084- Query : "/* client a */ commit;" ,
1085- Expected : []sql.Row {},
1086- },
10871088 {
10881089 Query : "/* client b */ select * from t;" ,
10891090 Expected : []sql.Row {},
@@ -1116,4 +1117,88 @@ var TransactionTests = []TransactionTest{
11161117 },
11171118 },
11181119 },
1120+ {
1121+ Name : "alter table queries are implicitly committed" ,
1122+ Assertions : []ScriptTestAssertion {
1123+ {
1124+ Query : "/* client a */ set @@autocommit = 0;" ,
1125+ Expected : []sql.Row {{}},
1126+ },
1127+ {
1128+ Query : "/* client a */ start transaction;" ,
1129+ Expected : []sql.Row {},
1130+ },
1131+ {
1132+ // This implicitly commits the transaction
1133+ Query : "/* client a */ create table t (pk int primary key);" ,
1134+ Expected : []sql.Row {{types.OkResult {}}},
1135+ },
1136+ {
1137+ Query : "/* client b */ show create table t;" ,
1138+ Expected : []sql.Row {{"t" , "CREATE TABLE `t` (\n " +
1139+ " `pk` int NOT NULL,\n " +
1140+ " PRIMARY KEY (`pk`)\n " +
1141+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
1142+ },
1143+
1144+ {
1145+ Query : "/* client a */ start transaction;" ,
1146+ Expected : []sql.Row {},
1147+ },
1148+ {
1149+ Query : "/* client a */ alter table t add column i int;" ,
1150+ Expected : []sql.Row {{types.OkResult {RowsAffected : 0 }}},
1151+ },
1152+ {
1153+ Query : "/* client b */ show create table t;" ,
1154+ Expected : []sql.Row {{"t" , "CREATE TABLE `t` (\n " +
1155+ " `pk` int NOT NULL,\n " +
1156+ " `i` int,\n " +
1157+ " PRIMARY KEY (`pk`)\n " +
1158+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
1159+ },
1160+ },
1161+ },
1162+ {
1163+ Name : "create index queries are implicitly committed" ,
1164+ Assertions : []ScriptTestAssertion {
1165+ {
1166+ Query : "/* client a */ set @@autocommit = 0;" ,
1167+ Expected : []sql.Row {{}},
1168+ },
1169+ {
1170+ Query : "/* client a */ start transaction;" ,
1171+ Expected : []sql.Row {},
1172+ },
1173+ {
1174+ // This implicitly commits the transaction
1175+ Query : "/* client a */ create table t (i int primary key);" ,
1176+ Expected : []sql.Row {{types.OkResult {}}},
1177+ },
1178+ {
1179+ Query : "/* client b */ show create table t;" ,
1180+ Expected : []sql.Row {{"t" , "CREATE TABLE `t` (\n " +
1181+ " `i` int NOT NULL,\n " +
1182+ " PRIMARY KEY (`i`)\n " +
1183+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
1184+ },
1185+
1186+ {
1187+ Query : "/* client a */ start transaction;" ,
1188+ Expected : []sql.Row {},
1189+ },
1190+ {
1191+ Query : "/* client a */ create unique index idx on t (i);" ,
1192+ Expected : []sql.Row {{types.OkResult {RowsAffected : 0 }}},
1193+ },
1194+ {
1195+ Query : "/* client b */ show create table t;" ,
1196+ Expected : []sql.Row {{"t" , "CREATE TABLE `t` (\n " +
1197+ " `i` int NOT NULL,\n " +
1198+ " PRIMARY KEY (`i`),\n " +
1199+ " UNIQUE KEY `idx` (`i`)\n " +
1200+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin" }},
1201+ },
1202+ },
1203+ },
11191204}
0 commit comments