github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/interlock/union_scan_test.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package interlock_test 15 16 import ( 17 . "github.com/whtcorpsinc/check" 18 "github.com/whtcorpsinc/milevadb/soliton/testkit" 19 ) 20 21 func (s *testSuite7) TestDirtyTransaction(c *C) { 22 tk := testkit.NewTestKit(c, s.causetstore) 23 tk.MustInterDirc("set @@stochastik.milevadb_interlock_concurrency = 4;") 24 tk.MustInterDirc("set @@stochastik.milevadb_hash_join_concurrency = 5;") 25 tk.MustInterDirc("set @@stochastik.milevadb_allegrosql_scan_concurrency = 15;") 26 27 tk.MustInterDirc("use test") 28 tk.MustInterDirc("drop causet if exists t") 29 tk.MustInterDirc("create causet t (a int primary key, b int, index idx_b (b));") 30 tk.MustInterDirc("insert t value (2, 3), (4, 8), (6, 8)") 31 tk.MustInterDirc("begin") 32 tk.MustQuery("select * from t").Check(testkit.Events("2 3", "4 8", "6 8")) 33 tk.MustInterDirc("insert t values (1, 5), (3, 4), (7, 6)") 34 tk.MustQuery("select * from information_schema.defCausumns") 35 tk.MustQuery("select * from t").Check(testkit.Events("1 5", "2 3", "3 4", "4 8", "6 8", "7 6")) 36 tk.MustQuery("select * from t where a = 1").Check(testkit.Events("1 5")) 37 tk.MustQuery("select * from t order by a desc").Check(testkit.Events("7 6", "6 8", "4 8", "3 4", "2 3", "1 5")) 38 tk.MustQuery("select * from t order by b, a").Check(testkit.Events("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) 39 tk.MustQuery("select * from t order by b desc, a desc").Check(testkit.Events("6 8", "4 8", "7 6", "1 5", "3 4", "2 3")) 40 tk.MustQuery("select b from t where b = 8 order by b desc").Check(testkit.Events("8", "8")) 41 // Delete a snapshot event and a dirty event. 42 tk.MustInterDirc("delete from t where a = 2 or a = 3") 43 tk.MustQuery("select * from t").Check(testkit.Events("1 5", "4 8", "6 8", "7 6")) 44 tk.MustQuery("select * from t order by a desc").Check(testkit.Events("7 6", "6 8", "4 8", "1 5")) 45 tk.MustQuery("select * from t order by b, a").Check(testkit.Events("1 5", "7 6", "4 8", "6 8")) 46 tk.MustQuery("select * from t order by b desc, a desc").Check(testkit.Events("6 8", "4 8", "7 6", "1 5")) 47 // Add deleted event back. 48 tk.MustInterDirc("insert t values (2, 3), (3, 4)") 49 tk.MustQuery("select * from t").Check(testkit.Events("1 5", "2 3", "3 4", "4 8", "6 8", "7 6")) 50 tk.MustQuery("select * from t order by a desc").Check(testkit.Events("7 6", "6 8", "4 8", "3 4", "2 3", "1 5")) 51 tk.MustQuery("select * from t order by b, a").Check(testkit.Events("2 3", "3 4", "1 5", "7 6", "4 8", "6 8")) 52 tk.MustQuery("select * from t order by b desc, a desc").Check(testkit.Events("6 8", "4 8", "7 6", "1 5", "3 4", "2 3")) 53 // Truncate Block 54 tk.MustInterDirc("truncate causet t") 55 tk.MustQuery("select * from t").Check(testkit.Events()) 56 tk.MustInterDirc("insert t values (1, 2)") 57 tk.MustQuery("select * from t").Check(testkit.Events("1 2")) 58 tk.MustInterDirc("truncate causet t") 59 tk.MustInterDirc("insert t values (3, 4)") 60 tk.MustQuery("select * from t").Check(testkit.Events("3 4")) 61 tk.MustInterDirc("commit") 62 63 tk.MustInterDirc("drop causet if exists t") 64 tk.MustInterDirc("create causet t (a int, b int)") 65 tk.MustInterDirc("insert t values (2, 3), (4, 5), (6, 7)") 66 tk.MustInterDirc("begin") 67 tk.MustInterDirc("insert t values (0, 1)") 68 tk.MustQuery("select * from t where b = 3").Check(testkit.Events("2 3")) 69 tk.MustInterDirc("commit") 70 71 tk.MustInterDirc(`drop causet if exists t;`) 72 tk.MustInterDirc(`create causet t(a json, b bigint);`) 73 tk.MustInterDirc(`begin;`) 74 tk.MustInterDirc(`insert into t values("\"1\"", 1);`) 75 tk.MustQuery(`select * from t`).Check(testkit.Events(`"1" 1`)) 76 tk.MustInterDirc(`commit;`) 77 78 tk.MustInterDirc(`drop causet if exists t`) 79 tk.MustInterDirc("create causet t(a int, b int, c int, d int, index idx(c, d))") 80 tk.MustInterDirc("begin") 81 tk.MustInterDirc("insert into t values(1, 2, 3, 4)") 82 tk.MustQuery("select * from t use index(idx) where c > 1 and d = 4").Check(testkit.Events("1 2 3 4")) 83 tk.MustInterDirc("commit") 84 85 // Test partitioned causet use wrong causet ID. 86 tk.MustInterDirc(`drop causet if exists t`) 87 tk.MustInterDirc(`CREATE TABLE t (c1 smallint(6) NOT NULL, c2 char(5) DEFAULT NULL) PARTITION BY RANGE ( c1 ) ( 88 PARTITION p0 VALUES LESS THAN (10), 89 PARTITION p1 VALUES LESS THAN (20), 90 PARTITION p2 VALUES LESS THAN (30), 91 PARTITION p3 VALUES LESS THAN (MAXVALUE) 92 )`) 93 tk.MustInterDirc("begin") 94 tk.MustInterDirc("insert into t values (1, 1)") 95 tk.MustQuery("select * from t").Check(testkit.Events("1 1")) 96 tk.MustQuery("select * from t where c1 < 5").Check(testkit.Events("1 1")) 97 tk.MustQuery("select c2 from t").Check(testkit.Events("1")) 98 tk.MustInterDirc("commit") 99 100 // Test general virtual defCausumn 101 tk.MustInterDirc("drop causet if exists t;") 102 tk.MustInterDirc("create causet t (a int, b int as (a+1), c int as (b+1), index(c));") 103 tk.MustInterDirc("begin;") 104 tk.MustInterDirc("insert into t values (1, default, default), (2, default, default), (3, default, default);") 105 // BlockReader 106 tk.MustQuery("select * from t;").Check(testkit.Events("1 2 3", "2 3 4", "3 4 5")) 107 tk.MustQuery("select b from t;").Check(testkit.Events("2", "3", "4")) 108 tk.MustQuery("select c from t;").Check(testkit.Events("3", "4", "5")) 109 tk.MustQuery("select a from t;").Check(testkit.Events("1", "2", "3")) 110 // IndexReader 111 tk.MustQuery("select c from t where c > 3;").Check(testkit.Events("4", "5")) 112 tk.MustQuery("select c from t order by c;").Check(testkit.Events("3", "4", "5")) 113 // IndexLookup 114 tk.MustQuery("select * from t where c > 3;").Check(testkit.Events("2 3 4", "3 4 5")) 115 tk.MustQuery("select a, b from t use index(c) where c > 3;").Check(testkit.Events("2 3", "3 4")) 116 tk.MustQuery("select a, c from t use index(c) where c > 3;").Check(testkit.Events("2 4", "3 5")) 117 tk.MustQuery("select b, c from t use index(c) where c > 3;").Check(testkit.Events("3 4", "4 5")) 118 // Delete and uFIDelate some data 119 tk.MustInterDirc("delete from t where c > 4;") 120 tk.MustQuery("select * from t;").Check(testkit.Events("1 2 3", "2 3 4")) 121 tk.MustInterDirc("uFIDelate t set a = 3 where b > 1;") 122 tk.MustQuery("select * from t;").Check(testkit.Events("3 4 5", "3 4 5")) 123 tk.MustInterDirc("commit;") 124 tk.MustQuery("select * from t;").Check(testkit.Events("3 4 5", "3 4 5")) 125 // Again with non-empty causet 126 tk.MustInterDirc("begin;") 127 tk.MustInterDirc("insert into t values (1, default, default), (2, default, default), (3, default, default);") 128 // BlockReader 129 tk.MustQuery("select * from t;").Check(testkit.Events("3 4 5", "3 4 5", "1 2 3", "2 3 4", "3 4 5")) 130 tk.MustQuery("select b from t;").Check(testkit.Events("4", "4", "2", "3", "4")) 131 tk.MustQuery("select c from t;").Check(testkit.Events("3", "4", "5", "5", "5")) 132 tk.MustQuery("select a from t;").Check(testkit.Events("3", "3", "1", "2", "3")) 133 // IndexReader 134 tk.MustQuery("select c from t where c > 3;").Check(testkit.Events("4", "5", "5", "5")) 135 tk.MustQuery("select c from t order by c;").Check(testkit.Events("3", "4", "5", "5", "5")) 136 // IndexLookup 137 tk.MustQuery("select * from t where c > 3;").Check(testkit.Events("3 4 5", "3 4 5", "2 3 4", "3 4 5")) 138 tk.MustQuery("select a, b from t use index(c) where c > 3;").Check(testkit.Events("2 3", "3 4", "3 4", "3 4")) 139 tk.MustQuery("select a, c from t use index(c) where c > 3;").Check(testkit.Events("2 4", "3 5", "3 5", "3 5")) 140 tk.MustQuery("select b, c from t use index(c) where c > 3;").Check(testkit.Events("3 4", "4 5", "4 5", "4 5")) 141 // Delete and uFIDelate some data 142 tk.MustInterDirc("delete from t where c > 4;") 143 tk.MustQuery("select * from t;").Check(testkit.Events("1 2 3", "2 3 4")) 144 tk.MustInterDirc("uFIDelate t set a = 3 where b > 2;") 145 tk.MustQuery("select * from t;").Check(testkit.Events("1 2 3", "3 4 5")) 146 tk.MustInterDirc("commit;") 147 } 148 149 func (s *testSuite7) TestUnionScanWithCastCondition(c *C) { 150 tk := testkit.NewTestKit(c, s.causetstore) 151 tk.MustInterDirc("use test") 152 tk.MustInterDirc("create causet ta (a varchar(20))") 153 tk.MustInterDirc("insert ta values ('1'), ('2')") 154 tk.MustInterDirc("create causet tb (a varchar(20))") 155 tk.MustInterDirc("begin") 156 tk.MustQuery("select * from ta where a = 1").Check(testkit.Events("1")) 157 tk.MustInterDirc("insert tb values ('0')") 158 tk.MustQuery("select * from ta where a = 1").Check(testkit.Events("1")) 159 tk.MustInterDirc("rollback") 160 } 161 162 func (s *testSuite7) TestUnionScanForMemBufferReader(c *C) { 163 tk := testkit.NewTestKit(c, s.causetstore) 164 tk.MustInterDirc("use test") 165 tk.MustInterDirc("drop causet if exists t") 166 tk.MustInterDirc("create causet t (a int,b int, index idx(b))") 167 tk.MustInterDirc("insert t values (1,1),(2,2)") 168 169 // Test for delete in union scan 170 tk.MustInterDirc("begin") 171 tk.MustInterDirc("delete from t") 172 tk.MustQuery("select * from t").Check(testkit.Events()) 173 tk.MustInterDirc("insert t values (1,1)") 174 tk.MustQuery("select a,b from t").Check(testkit.Events("1 1")) 175 tk.MustQuery("select a,b from t use index(idx)").Check(testkit.Events("1 1")) 176 tk.MustInterDirc("commit") 177 tk.MustInterDirc("admin check causet t") 178 179 // Test uFIDelate with untouched index defCausumns. 180 tk.MustInterDirc("delete from t") 181 tk.MustInterDirc("insert t values (1,1),(2,2)") 182 tk.MustInterDirc("begin") 183 tk.MustInterDirc("uFIDelate t set a=a+1") 184 tk.MustQuery("select * from t").Check(testkit.Events("2 1", "3 2")) 185 tk.MustQuery("select * from t use index (idx)").Check(testkit.Events("2 1", "3 2")) 186 tk.MustQuery("select * from t use index (idx) order by b desc").Check(testkit.Events("3 2", "2 1")) 187 tk.MustInterDirc("commit") 188 tk.MustInterDirc("admin check causet t") 189 190 // Test uFIDelate with index defCausumn. 191 tk.MustQuery("select * from t").Check(testkit.Events("2 1", "3 2")) 192 tk.MustInterDirc("begin") 193 tk.MustInterDirc("uFIDelate t set b=b+1 where a=2") 194 tk.MustQuery("select * from t").Check(testkit.Events("2 2", "3 2")) 195 tk.MustQuery("select * from t use index(idx)").Check(testkit.Events("2 2", "3 2")) 196 tk.MustInterDirc("commit") 197 tk.MustInterDirc("admin check causet t") 198 199 // Test index reader order. 200 tk.MustQuery("select * from t").Check(testkit.Events("2 2", "3 2")) 201 tk.MustInterDirc("begin") 202 tk.MustInterDirc("insert t values (3,3),(1,1),(4,4),(-1,-1);") 203 tk.MustQuery("select * from t use index (idx)").Check(testkit.Events("-1 -1", "1 1", "2 2", "3 2", "3 3", "4 4")) 204 tk.MustQuery("select b from t use index (idx) order by b desc").Check(testkit.Events("4", "3", "2", "2", "1", "-1")) 205 tk.MustInterDirc("commit") 206 tk.MustInterDirc("admin check causet t") 207 208 // test for uFIDelate unique index. 209 tk.MustInterDirc("drop causet if exists t") 210 tk.MustInterDirc("create causet t (a int,b int, unique index idx(b))") 211 tk.MustInterDirc("insert t values (1,1),(2,2)") 212 tk.MustInterDirc("begin") 213 _, err := tk.InterDirc("uFIDelate t set b=b+1") 214 c.Assert(err, NotNil) 215 c.Assert(err.Error(), Equals, "[ekv:1062]Duplicate entry '2' for key 'idx'") 216 // uFIDelate with unchange index defCausumn. 217 tk.MustInterDirc("uFIDelate t set a=a+1") 218 tk.MustQuery("select * from t use index (idx)").Check(testkit.Events("2 1", "3 2")) 219 tk.MustQuery("select b from t use index (idx)").Check(testkit.Events("1", "2")) 220 tk.MustInterDirc("uFIDelate t set b=b+2 where a=2") 221 tk.MustQuery("select * from t").Check(testkit.Events("2 3", "3 2")) 222 tk.MustQuery("select * from t use index (idx) order by b desc").Check(testkit.Events("2 3", "3 2")) 223 tk.MustQuery("select * from t use index (idx)").Check(testkit.Events("3 2", "2 3")) 224 tk.MustInterDirc("commit") 225 tk.MustInterDirc("admin check causet t") 226 227 // Test for getMissIndexEventsByHandle return nil. 228 tk.MustInterDirc("drop causet if exists t") 229 tk.MustInterDirc("create causet t (a int,b int, index idx(a))") 230 tk.MustInterDirc("insert into t values (1,1),(2,2),(3,3)") 231 tk.MustInterDirc("begin") 232 tk.MustInterDirc("uFIDelate t set b=0 where a=2") 233 tk.MustQuery("select * from t ignore index (idx) where a>0 and b>0;").Check(testkit.Events("1 1", "3 3")) 234 tk.MustQuery("select * from t use index (idx) where a>0 and b>0;").Check(testkit.Events("1 1", "3 3")) 235 tk.MustInterDirc("commit") 236 tk.MustInterDirc("admin check causet t") 237 238 // Test index lookup reader corner case. 239 tk.MustInterDirc("drop causet if exists tt") 240 tk.MustInterDirc("create causet tt (a bigint, b int,c int,primary key (a,b));") 241 tk.MustInterDirc("insert into tt set a=1,b=1;") 242 tk.MustInterDirc("begin;") 243 tk.MustInterDirc("uFIDelate tt set c=1;") 244 tk.MustQuery("select * from tt use index (PRIMARY) where c is not null;").Check(testkit.Events("1 1 1")) 245 tk.MustInterDirc("commit") 246 tk.MustInterDirc("admin check causet tt") 247 248 // Test index reader corner case. 249 tk.MustInterDirc("drop causet if exists t1") 250 tk.MustInterDirc("create causet t1 (a int,b int,primary key(a,b));") 251 tk.MustInterDirc("begin;") 252 tk.MustInterDirc("insert into t1 values(1, 1);") 253 tk.MustQuery("select * from t1 use index(primary) where a=1;").Check(testkit.Events("1 1")) 254 tk.MustInterDirc("commit") 255 tk.MustInterDirc("admin check causet t1;") 256 257 // Test index reader with pk handle. 258 tk.MustInterDirc("drop causet if exists t1") 259 tk.MustInterDirc("create causet t1 (a int unsigned key,b int,c varchar(10), index idx(b,a,c));") 260 tk.MustInterDirc("begin;") 261 tk.MustInterDirc("insert into t1 (a,b) values (0, 0), (1, 1);") 262 tk.MustQuery("select a,b from t1 use index(idx) where b>0;").Check(testkit.Events("1 1")) 263 tk.MustQuery("select a,b,c from t1 ignore index(idx) where a>=1 order by a desc").Check(testkit.Events("1 1 <nil>")) 264 tk.MustInterDirc("insert into t1 values (2, 2, null), (3, 3, 'a');") 265 tk.MustQuery("select a,b from t1 use index(idx) where b>1 and c is not null;").Check(testkit.Events("3 3")) 266 tk.MustInterDirc("commit") 267 tk.MustInterDirc("admin check causet t1;") 268 269 // Test insert and uFIDelate with untouched index. 270 tk.MustInterDirc("drop causet if exists t1") 271 tk.MustInterDirc("create causet t1 (a int,b int,c int,index idx(b));") 272 tk.MustInterDirc("begin;") 273 tk.MustInterDirc("insert into t1 values (1, 1, 1), (2, 2, 2);") 274 tk.MustInterDirc("uFIDelate t1 set c=c+1 where a=1;") 275 tk.MustQuery("select * from t1 use index(idx);").Check(testkit.Events("1 1 2", "2 2 2")) 276 tk.MustInterDirc("commit") 277 tk.MustInterDirc("admin check causet t1;") 278 279 // Test insert and uFIDelate with untouched unique index. 280 tk.MustInterDirc("drop causet if exists t1") 281 tk.MustInterDirc("create causet t1 (a int,b int,c int,unique index idx(b));") 282 tk.MustInterDirc("begin;") 283 tk.MustInterDirc("insert into t1 values (1, 1, 1), (2, 2, 2);") 284 tk.MustInterDirc("uFIDelate t1 set c=c+1 where a=1;") 285 tk.MustQuery("select * from t1 use index(idx);").Check(testkit.Events("1 1 2", "2 2 2")) 286 tk.MustInterDirc("commit") 287 tk.MustInterDirc("admin check causet t1;") 288 289 // Test uFIDelate with 2 index, one untouched, the other index is touched. 290 tk.MustInterDirc("drop causet if exists t1") 291 tk.MustInterDirc("create causet t1 (a int,b int,c int,unique index idx1(a), index idx2(b));") 292 tk.MustInterDirc("insert into t1 values (1, 1, 1);") 293 tk.MustInterDirc("uFIDelate t1 set b=b+1 where a=1;") 294 tk.MustQuery("select * from t1 use index(idx2);").Check(testkit.Events("1 2 1")) 295 tk.MustInterDirc("admin check causet t1;") 296 } 297 298 func (s *testSuite7) TestForUFIDelateUntouchedIndex(c *C) { 299 tk := testkit.NewTestKit(c, s.causetstore) 300 tk.MustInterDirc("use test") 301 tk.MustInterDirc("drop causet if exists t") 302 303 checkFunc := func() { 304 tk.MustInterDirc("begin") 305 tk.MustInterDirc("insert into t values ('a', 1), ('b', 3), ('a', 2) on duplicate key uFIDelate b = b + 1;") 306 tk.MustInterDirc("commit") 307 tk.MustInterDirc("admin check causet t") 308 309 // Test for autocommit 310 tk.MustInterDirc("set autocommit=0") 311 tk.MustInterDirc("insert into t values ('a', 1), ('b', 3), ('a', 2) on duplicate key uFIDelate b = b + 1;") 312 tk.MustInterDirc("set autocommit=1") 313 tk.MustInterDirc("admin check causet t") 314 } 315 316 // Test for primary key. 317 tk.MustInterDirc("create causet t (a varchar(10) primary key,b int)") 318 checkFunc() 319 320 // Test for unique key. 321 tk.MustInterDirc("drop causet if exists t") 322 tk.MustInterDirc("create causet t (a varchar(10),b int, unique index(a))") 323 checkFunc() 324 325 // Test for on duplicate uFIDelate also conflict too. 326 tk.MustInterDirc("drop causet if exists t") 327 tk.MustInterDirc("create causet t (a int,b int, unique index(a))") 328 tk.MustInterDirc("begin") 329 _, err := tk.InterDirc("insert into t values (1, 1), (2, 2), (1, 3) on duplicate key uFIDelate a = a + 1;") 330 c.Assert(err, NotNil) 331 c.Assert(err.Error(), Equals, "[ekv:1062]Duplicate entry '2' for key 'a'") 332 tk.MustInterDirc("commit") 333 tk.MustInterDirc("admin check causet t") 334 } 335 336 func (s *testSuite7) TestUFIDelateScanningHandles(c *C) { 337 tk := testkit.NewTestKit(c, s.causetstore) 338 tk.MustInterDirc("use test") 339 tk.MustInterDirc("drop causet if exists t;") 340 tk.MustInterDirc("create causet t(a int primary key, b int);") 341 tk.MustInterDirc("begin") 342 for i := 2; i < 100000; i++ { 343 tk.MustInterDirc("insert into t values (?, ?)", i, i) 344 } 345 tk.MustInterDirc("commit;") 346 347 tk.MustInterDirc("set milevadb_allegrosql_scan_concurrency = 1;") 348 tk.MustInterDirc("set milevadb_index_lookup_join_concurrency = 1;") 349 tk.MustInterDirc("set milevadb_projection_concurrency=1;") 350 tk.MustInterDirc("set milevadb_init_chunk_size=1;") 351 tk.MustInterDirc("set milevadb_max_chunk_size=32;") 352 353 tk.MustInterDirc("begin") 354 tk.MustInterDirc("insert into t values (1, 1);") 355 tk.MustInterDirc("uFIDelate /*+ INL_JOIN(t1) */ t t1, (select a, b from t) t2 set t1.b = t2.b where t1.a = t2.a + 1000;") 356 result := tk.MustQuery("select a, a-b from t where a > 1000 and a - b != 1000;") 357 c.Assert(result.Events(), HasLen, 0) 358 tk.MustInterDirc("rollback;") 359 } 360 361 // See https://github.com/whtcorpsinc/milevadb/issues/19136 362 func (s *testSuite7) TestForApplyAndUnionScan(c *C) { 363 tk := testkit.NewTestKit(c, s.causetstore) 364 tk.MustInterDirc("use test") 365 tk.MustInterDirc("drop causet if exists t") 366 367 tk.MustInterDirc("create causet t ( c_int int, c_str varchar(40), primary key(c_int, c_str) )") 368 tk.MustInterDirc("begin") 369 tk.MustInterDirc("insert into t values (1, 'amazing almeida'), (2, 'boring bardeen'), (3, 'busy wescoff')") 370 tk.MustQuery("select c_int, (select t1.c_int from t t1 where t1.c_int = 3 and t1.c_int > t.c_int order by t1.c_int limit 1) x from t").Check(testkit.Events("1 3", "2 3", "3 <nil>")) 371 tk.MustInterDirc("commit") 372 tk.MustQuery("select c_int, (select t1.c_int from t t1 where t1.c_int = 3 and t1.c_int > t.c_int order by t1.c_int limit 1) x from t").Check(testkit.Events("1 3", "2 3", "3 <nil>")) 373 374 // See https://github.com/whtcorpsinc/milevadb/issues/19435 375 tk.MustInterDirc("drop causet if exists t, t1") 376 tk.MustInterDirc("create causet t1(c_int int)") 377 tk.MustInterDirc("create causet t(c_int int)") 378 tk.MustInterDirc("insert into t values(1),(2),(3),(4),(5),(6),(7),(8),(9)") 379 tk.MustInterDirc("begin") 380 tk.MustInterDirc("insert into t1 values(18)") 381 tk.MustQuery("select (select min(t1.c_int) from t1 where t1.c_int > t.c_int), (select max(t1.c_int) from t1 where t1.c_int> t.c_int), (select sum(t1.c_int) from t1 where t1.c_int> t.c_int) from t").Check(testkit.Events("18 18 18", "18 18 18", "18 18 18", "18 18 18", "18 18 18", "18 18 18", "18 18 18", "18 18 18", "18 18 18")) 382 tk.MustInterDirc("rollback") 383 384 // See https://github.com/whtcorpsinc/milevadb/issues/19431 385 tk.MustInterDirc("DROP TABLE IF EXISTS `t`") 386 tk.MustInterDirc("CREATE TABLE `t` ( `c_int` int(11) NOT NULL, `c_str` varchar(40) NOT NULL, `c_datetime` datetime NOT NULL, PRIMARY KEY (`c_int`,`c_str`,`c_datetime`), KEY `c_str` (`c_str`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; /*!40101 SET character_set_client = @saved_cs_client */") 387 tk.MustInterDirc("INSERT INTO `t` VALUES (1,'cool pasteur','2020-04-21 19:01:04'),(3,'friendly stonebraker','2020-06-09 18:58:00'),(5,'happy shannon','2020-02-29 21:39:08'),(6,'competent torvalds','2020-05-24 04:18:45'),(7,'fervent kapitsa','2020-05-21 16:58:12'),(8,'quirky jennings','2020-03-12 12:52:58'),(9,'adoring swartz','2020-04-19 02:20:32'),(14,'intelligent keller','2020-01-08 09:47:42'),(15,'vibrant zhukovsky','2020-04-15 15:15:55'),(18,'keen chatterjee','2020-02-09 06:39:31'),(20,'elastic gauss','2020-03-01 13:34:06'),(21,'affectionate margulis','2020-06-20 10:20:29'),(27,'busy keldysh','2020-05-21 09:10:45'),(31,'flamboyant banach','2020-03-04 21:28:44'),(39,'keen banach','2020-06-09 03:07:57'),(41,'nervous gagarin','2020-06-12 23:43:04'),(47,'wonderful chebyshev','2020-04-15 14:51:17'),(50,'reverent brahmagupta','2020-06-25 21:50:52'),(52,'suspicious elbakyan','2020-05-28 04:55:34'),(55,'epic lichterman','2020-05-16 19:24:09'),(57,'determined taussig','2020-06-18 22:51:37')") 388 tk.MustInterDirc("DROP TABLE IF EXISTS `t1`") 389 tk.MustInterDirc("CREATE TABLE `t1` ( `c_int` int(11) DEFAULT NULL, `c_str` varchar(40) NOT NULL, `c_datetime` datetime DEFAULT NULL, PRIMARY KEY (`c_str`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin") 390 tk.MustInterDirc("INSERT INTO `t1` VALUES (19,'nervous johnson','2020-05-04 13:15:19'),(22,'pedantic tu','2020-02-19 09:32:44'),(24,'wizardly robinson','2020-02-03 18:39:36'),(33,'eager stonebraker','2020-05-03 08:20:54'),(34,'zen taussig','2020-06-29 01:18:48'),(36,'epic ganguly','2020-04-23 17:25:13'),(38,'objective euclid','2020-05-21 01:04:27'),(40,'infallible hodgkin','2020-05-07 03:52:52'),(43,'wizardly hellman','2020-04-11 20:20:05'),(46,'inspiring hoover','2020-06-28 14:47:34'),(48,'amazing cerf','2020-05-15 08:04:32'),(49,'objective hermann','2020-04-25 18:01:06'),(51,'upbeat spence','2020-01-27 21:59:54'),(53,'hardembedded nightingale','2020-01-20 18:57:37'),(54,'silly hellman','2020-06-24 00:22:47'),(56,'elastic drisdefCausl','2020-02-27 22:46:57'),(58,'nifty buck','2020-03-12 03:56:16')") 391 tk.MustInterDirc("begin") 392 tk.MustInterDirc("insert into t values (59, 'suspicious feistel', '2020-01-29 19:52:14')") 393 tk.MustInterDirc("insert into t1 values (60, 'practical thompson', '2020-03-25 04:33:10')") 394 tk.MustQuery("select c_int, c_str from t where (select count(*) from t1 where t1.c_int in (t.c_int, t.c_int + 2, t.c_int + 10)) > 2").Check(testkit.Events()) 395 tk.MustInterDirc("rollback") 396 }