1# The results where created without innodb persistent stats. 2SET @old_innodb_stats_persistent= @@global.innodb_stats_persistent; 3SET @@global.innodb_stats_persistent= 0; 4# Original tests for WL#4443 5# Must have InnoDB as engine to get the same statistics results. 6# embedded uses MyISAM as default. CREATE SELECT uses the default engine. 7SET @old_default_storage_engine = @@default_storage_engine; 8SET @@default_storage_engine = 'InnoDB'; 9CREATE TABLE t1 (a int PRIMARY KEY, b varchar(128), KEY (b)) 10ENGINE = InnoDB 11PARTITION BY HASH (a) PARTITIONS 13; 12CREATE TABLE t2 (a int PRIMARY KEY AUTO_INCREMENT, b varchar(128)) 13ENGINE = InnoDB 14PARTITION BY HASH (a) PARTITIONS 13; 15# 16# 17# Test how INSERT prune locks 18# First test, no defaults 19# 20FLUSH STATUS; 21INSERT INTO t1 VALUES (1, 'First row, p1'); 22SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 23WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 24VARIABLE_NAME VARIABLE_VALUE 25HANDLER_COMMIT 1 26HANDLER_EXTERNAL_LOCK 2 27HANDLER_WRITE 18 28# 1 commit 29FLUSH STATUS; 30INSERT INTO t1 VALUES (1, 'First row, duplicate'); 31ERROR 23000: Duplicate entry '1' for key 'PRIMARY' 32SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 33WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 34VARIABLE_NAME VARIABLE_VALUE 35HANDLER_EXTERNAL_LOCK 2 36HANDLER_ROLLBACK 1 37HANDLER_WRITE 18 38# 1 rollback 39FLUSH STATUS; 40INSERT INTO t1 VALUES (0, 'First row, p0'), (2, 'First row, p2'), 41(3, 'First row, p3'), (4, 'First row, p4'); 42SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 43WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 44VARIABLE_NAME VARIABLE_VALUE 45HANDLER_COMMIT 1 46HANDLER_EXTERNAL_LOCK 2 47HANDLER_WRITE 21 48# 1 commit 49FLUSH STATUS; 50INSERT INTO t1 VALUES (1 * 13, 'Second row, p0'), (2 * 13, 'Third row, p0'), 51(3 * 13, 'Fourth row, p0'), (4 * 13, 'Fifth row, p0'); 52SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 53WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 54VARIABLE_NAME VARIABLE_VALUE 55HANDLER_COMMIT 1 56HANDLER_EXTERNAL_LOCK 2 57HANDLER_WRITE 21 58# 1 commit 59# 60# INSERT with auto increment, lock pruning 61# 62FLUSH STATUS; 63INSERT INTO t2 VALUES (NULL, 'First auto-inc row'); 64SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 65WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 66VARIABLE_NAME VARIABLE_VALUE 67HANDLER_COMMIT 1 68HANDLER_EXTERNAL_LOCK 2 69HANDLER_WRITE 18 70# Auto increment value is not known until write. 71# 1 commit 72FLUSH STATUS; 73INSERT INTO t2 (b) VALUES ('Second auto-inc row'); 74SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 75WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 76VARIABLE_NAME VARIABLE_VALUE 77HANDLER_COMMIT 1 78HANDLER_EXTERNAL_LOCK 2 79HANDLER_WRITE 18 80# Auto increment value is not known until write. 81# 1 commit 82FLUSH STATUS; 83INSERT INTO t2 VALUES (10, "First row, p10"); 84SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 85WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 86VARIABLE_NAME VARIABLE_VALUE 87HANDLER_COMMIT 1 88HANDLER_EXTERNAL_LOCK 2 89HANDLER_WRITE 18 90# Insert pruning on tables with auto increment is not yet supported 91# 1 commit 92# 93# UPDATE with auto increment, lock pruning 94# 95FLUSH STATUS; 96UPDATE t2 SET b = CONCAT(b, ", UPDATED") WHERE a = 10; 97SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 98WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 99VARIABLE_NAME VARIABLE_VALUE 100HANDLER_COMMIT 1 101HANDLER_EXTERNAL_LOCK 2 102HANDLER_READ_KEY 1 103HANDLER_UPDATE 1 104HANDLER_WRITE 17 105# 1 read_key + 1 update + 1 commit 106# 107# Test of pruning with secondary column auto_inc INSERT 108# 109CREATE TABLE t3 (a INT, b INT AUTO_INCREMENT, PRIMARY KEY (a, b)) 110ENGINE = MyISAM 111PARTITION BY HASH (a) PARTITIONS 5; 112Warnings: 113Warning 1287 The partition engine, used by table 'test.t3', is deprecated and will be removed in a future release. Please use native partitioning instead. 114FLUSH STATUS; 115INSERT INTO t3 VALUES (1, 1); 116Warnings: 117Warning 1287 The partition engine, used by table 'test.t3', is deprecated and will be removed in a future release. Please use native partitioning instead. 118SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 119WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 120VARIABLE_NAME VARIABLE_VALUE 121HANDLER_EXTERNAL_LOCK 4 122HANDLER_WRITE 18 123# 4 locks (table + partition lock/unlock) 124# No commits, since MyISAM! 125FLUSH STATUS; 126INSERT INTO t3 VALUES (1, NULL); 127SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 128WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 129VARIABLE_NAME VARIABLE_VALUE 130HANDLER_EXTERNAL_LOCK 4 131HANDLER_WRITE 18 132# 4 locks (table + partition lock/unlock) 133SELECT @@sql_mode; 134@@sql_mode 135ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 136SET @old_sql_mode = @@sql_mode; 137SET @@sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; 138Warnings: 139Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 140SELECT @@sql_mode; 141@@sql_mode 142NO_AUTO_VALUE_ON_ZERO 143FLUSH STATUS; 144INSERT INTO t3 VALUES (1, 0); 145SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 146WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 147VARIABLE_NAME VARIABLE_VALUE 148HANDLER_EXTERNAL_LOCK 4 149HANDLER_WRITE 18 150# 4 locks (table + partition lock/unlock) 151SET @@sql_mode = @old_sql_mode; 152Warnings: 153Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 154SELECT @@sql_mode; 155@@sql_mode 156ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 157FLUSH STATUS; 158INSERT INTO t3 VALUES (1, 0); 159SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 160WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 161VARIABLE_NAME VARIABLE_VALUE 162HANDLER_EXTERNAL_LOCK 4 163HANDLER_WRITE 18 164# 4 locks (table + partition lock/unlock) 165SELECT * FROM t3; 166a b 1671 0 1681 1 1691 2 1701 3 171DROP TABLE t3; 172# 173# Test handling of INSERT INTO <table> VALUES (<all fields specified>) 174# 175CREATE TABLE t3 (a INT, b CHAR(10)) PARTITION BY HASH (a) PARTITIONS 2; 176FLUSH STATUS; 177INSERT INTO t3 VALUES (1, "Test 1"); 178SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 179WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 180VARIABLE_NAME VARIABLE_VALUE 181HANDLER_COMMIT 1 182HANDLER_EXTERNAL_LOCK 2 183HANDLER_WRITE 18 184FLUSH STATUS; 185INSERT INTO t3 VALUES (2, "Test 2"), (3, "Test 3"), (4, "Test 4"); 186SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 187WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 188VARIABLE_NAME VARIABLE_VALUE 189HANDLER_COMMIT 1 190HANDLER_EXTERNAL_LOCK 2 191HANDLER_WRITE 20 192FLUSH STATUS; 193INSERT INTO t3 VALUES (6, "Test 6"), (8, "Test 8"), (10, "Test 10"); 194SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 195WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 196VARIABLE_NAME VARIABLE_VALUE 197HANDLER_COMMIT 1 198HANDLER_EXTERNAL_LOCK 2 199HANDLER_WRITE 20 200FLUSH STATUS; 201INSERT INTO t3 VALUES (5, "Test 5"), (7, "Test 7"), (9, "Test 9"); 202SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 203WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 204VARIABLE_NAME VARIABLE_VALUE 205HANDLER_COMMIT 1 206HANDLER_EXTERNAL_LOCK 2 207HANDLER_WRITE 20 208FLUSH STATUS; 209INSERT INTO t3 VALUES (0, "Test 0"); 210SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 211WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 212VARIABLE_NAME VARIABLE_VALUE 213HANDLER_COMMIT 1 214HANDLER_EXTERNAL_LOCK 2 215HANDLER_WRITE 18 216FLUSH STATUS; 217INSERT INTO t3 (a, b) VALUES (1, "Test 1"); 218SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 219WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 220VARIABLE_NAME VARIABLE_VALUE 221HANDLER_COMMIT 1 222HANDLER_EXTERNAL_LOCK 2 223HANDLER_WRITE 18 224FLUSH STATUS; 225INSERT INTO t3 (a, b) VALUES (2, "Test 2"), (3, "Test 3"), (4, "Test 4"); 226SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 227WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 228VARIABLE_NAME VARIABLE_VALUE 229HANDLER_COMMIT 1 230HANDLER_EXTERNAL_LOCK 2 231HANDLER_WRITE 20 232FLUSH STATUS; 233INSERT INTO t3 (a, b) VALUES (6, "Test 6"), (8, "Test 8"), (10, "Test 10"); 234SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 235WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 236VARIABLE_NAME VARIABLE_VALUE 237HANDLER_COMMIT 1 238HANDLER_EXTERNAL_LOCK 2 239HANDLER_WRITE 20 240FLUSH STATUS; 241INSERT INTO t3 (a, b) VALUES (5, "Test 5"), (7, "Test 7"), (9, "Test 9"); 242SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 243WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 244VARIABLE_NAME VARIABLE_VALUE 245HANDLER_COMMIT 1 246HANDLER_EXTERNAL_LOCK 2 247HANDLER_WRITE 20 248FLUSH STATUS; 249INSERT INTO t3 (a, b) VALUES (0, "Test 0"); 250SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 251WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 252VARIABLE_NAME VARIABLE_VALUE 253HANDLER_COMMIT 1 254HANDLER_EXTERNAL_LOCK 2 255HANDLER_WRITE 18 256# 257# Test handling of 258# INSERT INTO <table> VALUES (<not all fields specified>) 259# 260FLUSH STATUS; 261INSERT INTO t3 (a) VALUES (1); 262SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 263WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 264VARIABLE_NAME VARIABLE_VALUE 265HANDLER_COMMIT 1 266HANDLER_EXTERNAL_LOCK 2 267HANDLER_WRITE 18 268FLUSH STATUS; 269INSERT INTO t3 (a) VALUES (2), (3), (4); 270SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 271WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 272VARIABLE_NAME VARIABLE_VALUE 273HANDLER_COMMIT 1 274HANDLER_EXTERNAL_LOCK 2 275HANDLER_WRITE 20 276FLUSH STATUS; 277INSERT INTO t3 (a) VALUES (6), (8), (10); 278SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 279WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 280VARIABLE_NAME VARIABLE_VALUE 281HANDLER_COMMIT 1 282HANDLER_EXTERNAL_LOCK 2 283HANDLER_WRITE 20 284FLUSH STATUS; 285INSERT INTO t3 (a) VALUES (5), (7), (9); 286SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 287WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 288VARIABLE_NAME VARIABLE_VALUE 289HANDLER_COMMIT 1 290HANDLER_EXTERNAL_LOCK 2 291HANDLER_WRITE 20 292FLUSH STATUS; 293INSERT INTO t3 (b) VALUES ("Only b 1"); 294SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 295WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 296VARIABLE_NAME VARIABLE_VALUE 297HANDLER_COMMIT 1 298HANDLER_EXTERNAL_LOCK 2 299HANDLER_WRITE 18 300FLUSH STATUS; 301INSERT INTO t3 (b) VALUES ("Only b 2"), ("Only b 3"); 302SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 303WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 304VARIABLE_NAME VARIABLE_VALUE 305HANDLER_COMMIT 1 306HANDLER_EXTERNAL_LOCK 2 307HANDLER_WRITE 19 308SELECT * FROM t3 ORDER BY a, b; 309a b 310NULL Only b 1 311NULL Only b 2 312NULL Only b 3 3130 Test 0 3140 Test 0 3151 NULL 3161 Test 1 3171 Test 1 3182 NULL 3192 Test 2 3202 Test 2 3213 NULL 3223 Test 3 3233 Test 3 3244 NULL 3254 Test 4 3264 Test 4 3275 NULL 3285 Test 5 3295 Test 5 3306 NULL 3316 Test 6 3326 Test 6 3337 NULL 3347 Test 7 3357 Test 7 3368 NULL 3378 Test 8 3388 Test 8 3399 NULL 3409 Test 9 3419 Test 9 34210 NULL 34310 Test 10 34410 Test 10 345DROP TABLE t3; 346# 347# Test of insert pruning with subpartitions 348# 349# I've placed the varchar column before the int column for better 350# distribution by LINEAR KEY. 351CREATE TABLE t3 352(a int DEFAULT 10, 353b varchar(64) DEFAULT "Default", 354c varchar(64) DEFAULT "Default", 355d int unsigned DEFAULT 9, 356e varchar(255) DEFAULT "Default-filler.filler.filler.", 357PRIMARY KEY (a,b,c,d)) 358PARTITION BY RANGE COLUMNS (a, b) 359SUBPARTITION BY LINEAR KEY (d, c) 360SUBPARTITIONS 4 361(PARTITION pNeg VALUES LESS THAN (0, ""), 362PARTITION `p0-9` VALUES LESS THAN (9, MAXVALUE), 363PARTITION p10 VALUES LESS THAN (10, MAXVALUE), 364PARTITION `p11-100` VALUES LESS THAN (99, MAXVALUE)); 365# 366# Test INSERT with 367# empty field specifier list and empty value list 368# 369FLUSH STATUS; 370INSERT INTO t3 () VALUES (); 371SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 372WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 373VARIABLE_NAME VARIABLE_VALUE 374HANDLER_COMMIT 1 375HANDLER_EXTERNAL_LOCK 2 376HANDLER_WRITE 18 377# 378# Test INSERT with 379# no field specifier list and full value list, including DEFAULT 380# specifier 381# 382FLUSH STATUS; 383INSERT IGNORE INTO t3 VALUES (-1, "ZZZzzzz", "yyyYYY", -1, DEFAULT); 384Warnings: 385Warning 1264 Out of range value for column 'd' at row 1 386SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 387WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 388VARIABLE_NAME VARIABLE_VALUE 389HANDLER_COMMIT 1 390HANDLER_EXTERNAL_LOCK 2 391HANDLER_WRITE 18 392# 393# Test INSERT with 394# empty field specifier list and full value list, including NULL 395# 396FLUSH STATUS; 397INSERT INTO t3 () VALUES (0, "", "", 0, NULL); 398SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 399WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 400VARIABLE_NAME VARIABLE_VALUE 401HANDLER_COMMIT 1 402HANDLER_EXTERNAL_LOCK 2 403HANDLER_WRITE 18 404# 405# Test INSERT with field specifier list for only some fields 406# 407FLUSH STATUS; 408INSERT INTO t3 (a) VALUES (1); 409SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 410WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 411VARIABLE_NAME VARIABLE_VALUE 412HANDLER_COMMIT 1 413HANDLER_EXTERNAL_LOCK 2 414HANDLER_WRITE 18 415FLUSH STATUS; 416INSERT INTO t3 (a, b) VALUES (1, "Part expr fulfilled"), 417(10, "Part expr fulfilled"); 418SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 419WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 420VARIABLE_NAME VARIABLE_VALUE 421HANDLER_COMMIT 1 422HANDLER_EXTERNAL_LOCK 2 423HANDLER_WRITE 19 424FLUSH STATUS; 425INSERT INTO t3 (d) VALUES (1), (2); 426SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 427WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 428VARIABLE_NAME VARIABLE_VALUE 429HANDLER_COMMIT 1 430HANDLER_EXTERNAL_LOCK 2 431HANDLER_WRITE 19 432FLUSH STATUS; 433INSERT INTO t3 (c, d) VALUES ("Subpart expr fulfilled", 1); 434SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 435WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 436VARIABLE_NAME VARIABLE_VALUE 437HANDLER_COMMIT 1 438HANDLER_EXTERNAL_LOCK 2 439HANDLER_WRITE 18 440FLUSH STATUS; 441INSERT INTO t3 (a, b, d) VALUES (10, "Full part, half subpart", 1), 442(12, "Full part, half subpart", 1), 443(12, "Full part, half subpart", 2), 444(12, "Full part, half subpart", 3), 445(12, "Full part, half subpart", 4), 446(12, "Full part, half subpart", 0); 447SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 448WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 449VARIABLE_NAME VARIABLE_VALUE 450HANDLER_COMMIT 1 451HANDLER_EXTERNAL_LOCK 2 452HANDLER_WRITE 23 453# d = 0 and d = 4 goes to the same subpart! 454FLUSH STATUS; 455INSERT INTO t3 (a, b, c) VALUES (1, "Full part", "Half subpart"); 456SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 457WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 458VARIABLE_NAME VARIABLE_VALUE 459HANDLER_COMMIT 1 460HANDLER_EXTERNAL_LOCK 2 461HANDLER_WRITE 18 462# Adding 'Default' as padding to see if LINEAR KEY uses different parts. 463FLUSH STATUS; 464INSERT INTO t3 (a, c, d) VALUES (12, "Half part, full subpart", 1), 465(12, "Half part, full subpartDefault", 1), 466(12, "Half part, full subpart Default", 1); 467SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 468WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 469VARIABLE_NAME VARIABLE_VALUE 470HANDLER_COMMIT 1 471HANDLER_EXTERNAL_LOCK 2 472HANDLER_WRITE 20 473# First and last row goes to the same subpartition. 474FLUSH STATUS; 475INSERT INTO t3 (b, c, d) VALUES ("Half part", "Full subpart", 1); 476SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 477WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 478VARIABLE_NAME VARIABLE_VALUE 479HANDLER_COMMIT 1 480HANDLER_EXTERNAL_LOCK 2 481HANDLER_WRITE 18 482FLUSH STATUS; 483# 484# Test INSERT with full field specifier list and full value list 485# 486INSERT INTO t3 (a, b, c, d) VALUES (1, "Full part", "Full subpart", 1); 487SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 488WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 489VARIABLE_NAME VARIABLE_VALUE 490HANDLER_COMMIT 1 491HANDLER_EXTERNAL_LOCK 2 492HANDLER_WRITE 18 493# 494# Test INSERT with no field specifier list and empty value list 495# (need to delete previous inserted default row first...) 496# 497DELETE FROM t3 WHERE a = 10 AND b = 'Default' AND c = 'Default' AND D = 9; 498FLUSH STATUS; 499INSERT INTO t3 VALUES (); 500SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 501WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 502VARIABLE_NAME VARIABLE_VALUE 503HANDLER_COMMIT 1 504HANDLER_EXTERNAL_LOCK 2 505HANDLER_WRITE 18 506# 507# Verifing result 508# 509SELECT * FROM t3; 510a b c d e 511-1 ZZZzzzz yyyYYY 0 Default-filler.filler.filler. 5120 0 NULL 5131 Default Default 9 Default-filler.filler.filler. 5141 Full part Full subpart 1 Default-filler.filler.filler. 5151 Full part Half subpart 9 Default-filler.filler.filler. 5161 Part expr fulfilled Default 9 Default-filler.filler.filler. 51710 Default Default 1 Default-filler.filler.filler. 51810 Default Default 2 Default-filler.filler.filler. 51910 Default Default 9 Default-filler.filler.filler. 52010 Default Subpart expr fulfilled 1 Default-filler.filler.filler. 52110 Full part, half subpart Default 1 Default-filler.filler.filler. 52210 Half part Full subpart 1 Default-filler.filler.filler. 52310 Part expr fulfilled Default 9 Default-filler.filler.filler. 52412 Default Half part, full subpart 1 Default-filler.filler.filler. 52512 Default Half part, full subpart Default 1 Default-filler.filler.filler. 52612 Default Half part, full subpartDefault 1 Default-filler.filler.filler. 52712 Full part, half subpart Default 0 Default-filler.filler.filler. 52812 Full part, half subpart Default 1 Default-filler.filler.filler. 52912 Full part, half subpart Default 2 Default-filler.filler.filler. 53012 Full part, half subpart Default 3 Default-filler.filler.filler. 53112 Full part, half subpart Default 4 Default-filler.filler.filler. 532SELECT d, c FROM t3 PARTITION(`p11-100sp0`); 533d c 5340 Default 5354 Default 536SELECT d, c FROM t3 PARTITION(`p11-100sp1`); 537d c 5381 Default 5391 Half part, full subpart 5401 Half part, full subpart Default 541SELECT d, c FROM t3 PARTITION(`p11-100sp2`); 542d c 5431 Half part, full subpartDefault 5442 Default 545SELECT d, c FROM t3 PARTITION(`p11-100sp3`); 546d c 5473 Default 548# 549# Test with LOCK TABLES 550# 551LOCK TABLES t3 PARTITION (`p11-100sp0`) WRITE; 552ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITION (`p11-100sp0`) WRITE' at line 1 553FLUSH STATUS; 554LOCK TABLES t3 WRITE; 555SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 556WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 557VARIABLE_NAME VARIABLE_VALUE 558HANDLER_COMMIT 1 559HANDLER_EXTERNAL_LOCK 1 560HANDLER_WRITE 17 561# No further locks/unlocks until UNLOCK TABLES. 562# 563# Test INSERT with no field specifier list and empty value list 564# (need to delete previous inserted default row first...) 565# 566DELETE FROM t3 WHERE a = 10 AND b = 'Default' AND c = 'Default' AND D = 9; 567FLUSH STATUS; 568INSERT INTO t3 VALUES (); 569SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 570WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 571VARIABLE_NAME VARIABLE_VALUE 572HANDLER_COMMIT 1 573HANDLER_WRITE 18 574FLUSH STATUS; 575# 576# Test INSERT with field specifier list for only some fields 577# (need to delete previous inserted default row first...) 578# 579DELETE FROM t3 580WHERE a = 10 AND b = "Default" AND c = "Default" AND d = 9; 581SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 582WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 583VARIABLE_NAME VARIABLE_VALUE 584HANDLER_COMMIT 1 585HANDLER_DELETE 1 586HANDLER_READ_KEY 1 587HANDLER_WRITE 17 588FLUSH STATUS; 589INSERT INTO t3 (b, d, e) VALUES (DEFAULT, DEFAULT, "All default!"); 590SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 591WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 592VARIABLE_NAME VARIABLE_VALUE 593HANDLER_COMMIT 1 594HANDLER_WRITE 18 595FLUSH STATUS; 596# 597# Test UPDATE of non PK field in default row 598# 599UPDATE t3 600SET e = CONCAT(e, ", updated") 601WHERE a = 10 AND b = "Default" AND c = "Default" AND d = 9; 602SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 603WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 604VARIABLE_NAME VARIABLE_VALUE 605HANDLER_COMMIT 1 606HANDLER_READ_KEY 1 607HANDLER_UPDATE 1 608HANDLER_WRITE 17 609FLUSH STATUS; 610# 611# Test UPDATE of PK field + non PK field in default row 612# 613UPDATE t3 614SET a = DEFAULT, b = "Not DEFAULT!", e = CONCAT(e, ", updated2") 615WHERE a = 10 AND b = "Default" AND c = "Default" AND d = 9; 616SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 617WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 618VARIABLE_NAME VARIABLE_VALUE 619HANDLER_COMMIT 1 620HANDLER_READ_KEY 2 621HANDLER_READ_RND 1 622HANDLER_UPDATE 1 623HANDLER_WRITE 17 624FLUSH STATUS; 625# 626# Test REPLACE of default row (INSERT, since not duplicate) 627# 628REPLACE INTO t3 (e) VALUES ("New default row"); 629SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 630WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 631VARIABLE_NAME VARIABLE_VALUE 632HANDLER_COMMIT 1 633HANDLER_WRITE 18 634FLUSH STATUS; 635SELECT * FROM t3 636WHERE a = 10 AND b = "Default" AND c = "Default" AND d = 9; 637a b c d e 63810 Default Default 9 New default row 639SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 640WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 641VARIABLE_NAME VARIABLE_VALUE 642HANDLER_COMMIT 1 643HANDLER_READ_KEY 1 644HANDLER_WRITE 17 645FLUSH STATUS; 646EXPLAIN PARTITIONS SELECT * FROM t3 647WHERE a = 10 AND b = "Default" AND c = "Default" AND d = 9; 648id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6491 SIMPLE t3 p10_p10sp1 const PRIMARY PRIMARY 140 const,const,const,const # 100.00 NULL 650Warnings: 651Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 652Note 1003 /* select#1 */ select '10' AS `a`,'Default' AS `b`,'Default' AS `c`,'9' AS `d`,'New default row' AS `e` from `test`.`t3` where 1 653SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 654WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 655VARIABLE_NAME VARIABLE_VALUE 656HANDLER_COMMIT 1 657HANDLER_READ_KEY 1 658HANDLER_WRITE 17 659FLUSH STATUS; 660# 661# Test REPLACE of default row (REPLACE, since duplicate exists) 662# 663REPLACE INTO t3 (e) VALUES ("Newest default row"); 664SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 665WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 666VARIABLE_NAME VARIABLE_VALUE 667HANDLER_COMMIT 1 668HANDLER_READ_KEY 1 669HANDLER_UPDATE 1 670HANDLER_WRITE 18 671# 672# Test SELECT with explicit partition selection 673# 674FLUSH STATUS; 675SELECT * FROM t3 PARTITION (p10); 676a b c d e 67710 Default Default 1 Default-filler.filler.filler. 67810 Default Default 2 Default-filler.filler.filler. 67910 Default Default 9 Newest default row 68010 Default Subpart expr fulfilled 1 Default-filler.filler.filler. 68110 Full part, half subpart Default 1 Default-filler.filler.filler. 68210 Half part Full subpart 1 Default-filler.filler.filler. 68310 Not DEFAULT! Default 9 All default!, updated, updated2 68410 Part expr fulfilled Default 9 Default-filler.filler.filler. 685SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 686WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 687VARIABLE_NAME VARIABLE_VALUE 688HANDLER_COMMIT 1 689HANDLER_READ_FIRST 4 690HANDLER_READ_KEY 4 691HANDLER_READ_RND_NEXT 8 692HANDLER_WRITE 17 693FLUSH STATUS; 694EXPLAIN PARTITIONS SELECT * FROM t3 PARTITION (p10); 695id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6961 SIMPLE t3 p10_p10sp0,p10_p10sp1,p10_p10sp2,p10_p10sp3 ALL NULL NULL NULL NULL # 100.00 NULL 697Warnings: 698Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 699Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t3`.`d` AS `d`,`test`.`t3`.`e` AS `e` from `test`.`t3` PARTITION (`p10`) 700SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 701WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 702VARIABLE_NAME VARIABLE_VALUE 703HANDLER_COMMIT 1 704HANDLER_WRITE 17 705FLUSH STATUS; 706UNLOCK TABLES; 707SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 708WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 709VARIABLE_NAME VARIABLE_VALUE 710HANDLER_EXTERNAL_LOCK 1 711HANDLER_WRITE 17 712DROP TABLE t3; 713# 714# End of LOCK TABLE test. 715# 716# 717# Test INSERT with timestamp column NO default function 718# 719SELECT UNIX_TIMESTAMP('2011-01-01 00:00:00') as time_t, 720UNIX_TIMESTAMP('2011-01-01 00:00:00') % 3 as part, 7211234567890 % 3 as part2; 722time_t part part2 7231293829200 0 0 724SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; 725Warnings: 726Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 727CREATE TABLE t3 728(a timestamp DEFAULT 0, 729b char(10), 730PRIMARY KEY (a)) 731PARTITION BY HASH (UNIX_TIMESTAMP(a)) PARTITIONS 3; 732SHOW CREATE TABLE t3; 733Table Create Table 734t3 CREATE TABLE `t3` ( 735 `a` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', 736 `b` char(10) DEFAULT NULL, 737 PRIMARY KEY (`a`) 738) ENGINE=InnoDB DEFAULT CHARSET=latin1 739/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) 740PARTITIONS 3 */ 741FLUSH STATUS; 742SET TIMESTAMP = 1234567890; 743INSERT INTO t3 (a) VALUES (NULL); 744SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 745WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 746VARIABLE_NAME VARIABLE_VALUE 747HANDLER_COMMIT 1 748HANDLER_EXTERNAL_LOCK 2 749HANDLER_WRITE 18 750FLUSH STATUS; 751SET TIMESTAMP = 1234567891; 752INSERT INTO t3 VALUES (); 753SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 754WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 755VARIABLE_NAME VARIABLE_VALUE 756HANDLER_COMMIT 1 757HANDLER_EXTERNAL_LOCK 2 758HANDLER_WRITE 18 759FLUSH STATUS; 760INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 761SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 762WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 763VARIABLE_NAME VARIABLE_VALUE 764HANDLER_COMMIT 1 765HANDLER_EXTERNAL_LOCK 2 766HANDLER_WRITE 18 767FLUSH STATUS; 768INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 769SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 770WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 771VARIABLE_NAME VARIABLE_VALUE 772HANDLER_COMMIT 1 773HANDLER_EXTERNAL_LOCK 2 774HANDLER_WRITE 18 775FLUSH STATUS; 776INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 777SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 778WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 779VARIABLE_NAME VARIABLE_VALUE 780HANDLER_COMMIT 1 781HANDLER_EXTERNAL_LOCK 2 782HANDLER_WRITE 19 783# 2 writes 784FLUSH STATUS; 785SET TIMESTAMP = 1234567892; 786INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 787ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 788SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 789WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 790VARIABLE_NAME VARIABLE_VALUE 791HANDLER_COMMIT 1 792HANDLER_EXTERNAL_LOCK 2 793HANDLER_READ_KEY 1 794HANDLER_UPDATE 1 795HANDLER_WRITE 18 796# 1 read_key + 1 update (same partition) 797# 1 (failed) write 798FLUSH STATUS; 799INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 800ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 801SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 802WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 803VARIABLE_NAME VARIABLE_VALUE 804HANDLER_COMMIT 1 805HANDLER_DELETE 1 806HANDLER_EXTERNAL_LOCK 2 807HANDLER_READ_KEY 1 808HANDLER_WRITE 19 809# No pruning due to updating partitioning field. 810# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 811# 1 delete + 1 write due to moved to different partition 812FLUSH STATUS; 813SET TIMESTAMP = 1234567893; 814UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 815SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 816WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 817VARIABLE_NAME VARIABLE_VALUE 818HANDLER_COMMIT 1 819HANDLER_EXTERNAL_LOCK 2 820HANDLER_READ_KEY 1 821HANDLER_UPDATE 1 822HANDLER_WRITE 17 823# 1 read_key + 1 update (same partition) 824# 1 (failed) write 825FLUSH STATUS; 826REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 827SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 828WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 829VARIABLE_NAME VARIABLE_VALUE 830HANDLER_COMMIT 1 831HANDLER_EXTERNAL_LOCK 2 832HANDLER_WRITE 18 833FLUSH STATUS; 834REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 835SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 836WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 837VARIABLE_NAME VARIABLE_VALUE 838HANDLER_COMMIT 1 839HANDLER_EXTERNAL_LOCK 2 840HANDLER_READ_KEY 1 841HANDLER_UPDATE 1 842HANDLER_WRITE 18 843# 1 read_key + 1 update + 1 failed write 844# 845# Test of replace of default PK (delete might be needed first) 846# 847DELETE FROM t3 WHERE a = 0; 848FLUSH STATUS; 849SET TIMESTAMP = 1234567894; 850REPLACE INTO t3 (b) VALUES ('Replace3'); 851SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 852WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 853VARIABLE_NAME VARIABLE_VALUE 854HANDLER_COMMIT 1 855HANDLER_EXTERNAL_LOCK 2 856HANDLER_WRITE 18 857FLUSH STATUS; 858SET TIMESTAMP = 1234567894; 859REPLACE INTO t3 (b) VALUES ('Replace4'); 860SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 861WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 862VARIABLE_NAME VARIABLE_VALUE 863HANDLER_COMMIT 1 864HANDLER_EXTERNAL_LOCK 2 865HANDLER_READ_KEY 1 866HANDLER_UPDATE 1 867HANDLER_WRITE 18 868# 1 read_key + 1 update + 1 failed write 869SELECT * FROM t3; 870a b 8710000-00-00 00:00:00 Replace4 8722009-02-14 02:31:30 NULL 8732011-01-01 00:00:00 DUP_KEY 8742011-01-01 00:00:02 Updated 8752011-01-01 00:00:03 NULL 8762011-01-01 00:00:04 Replace2 8772011-01-01 00:00:05 DUP_KEY2 878DROP TABLE t3; 879# 880# Test INSERT with timestamp column DEFAULT INSERT + UPDATE 881# 882CREATE TABLE t3 883(a timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 884b char(10), 885PRIMARY KEY (a)) 886PARTITION BY HASH (UNIX_TIMESTAMP(a)) PARTITIONS 3; 887SHOW CREATE TABLE t3; 888Table Create Table 889t3 CREATE TABLE `t3` ( 890 `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 891 `b` char(10) DEFAULT NULL, 892 PRIMARY KEY (`a`) 893) ENGINE=InnoDB DEFAULT CHARSET=latin1 894/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) 895PARTITIONS 3 */ 896FLUSH STATUS; 897SET TIMESTAMP = 1234567890; 898INSERT INTO t3 (a) VALUES (NULL); 899SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 900WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 901VARIABLE_NAME VARIABLE_VALUE 902HANDLER_COMMIT 1 903HANDLER_EXTERNAL_LOCK 2 904HANDLER_WRITE 18 905FLUSH STATUS; 906SET TIMESTAMP = 1234567891; 907INSERT INTO t3 VALUES (); 908SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 909WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 910VARIABLE_NAME VARIABLE_VALUE 911HANDLER_COMMIT 1 912HANDLER_EXTERNAL_LOCK 2 913HANDLER_WRITE 18 914FLUSH STATUS; 915INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 916SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 917WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 918VARIABLE_NAME VARIABLE_VALUE 919HANDLER_COMMIT 1 920HANDLER_EXTERNAL_LOCK 2 921HANDLER_WRITE 18 922FLUSH STATUS; 923INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 924SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 925WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 926VARIABLE_NAME VARIABLE_VALUE 927HANDLER_COMMIT 1 928HANDLER_EXTERNAL_LOCK 2 929HANDLER_WRITE 18 930FLUSH STATUS; 931INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 932SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 933WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 934VARIABLE_NAME VARIABLE_VALUE 935HANDLER_COMMIT 1 936HANDLER_EXTERNAL_LOCK 2 937HANDLER_WRITE 19 938# 2 writes 939FLUSH STATUS; 940SET TIMESTAMP = 1234567892; 941INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 942ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 943SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 944WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 945VARIABLE_NAME VARIABLE_VALUE 946HANDLER_COMMIT 1 947HANDLER_DELETE 1 948HANDLER_EXTERNAL_LOCK 2 949HANDLER_READ_KEY 1 950HANDLER_WRITE 19 951# No pruning due to DEFAULT function on partitioning column 952# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 953# 1 delete + 1 write due to moved to different partition 954FLUSH STATUS; 955INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 956ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 957SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 958WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 959VARIABLE_NAME VARIABLE_VALUE 960HANDLER_COMMIT 1 961HANDLER_DELETE 1 962HANDLER_EXTERNAL_LOCK 2 963HANDLER_READ_KEY 1 964HANDLER_WRITE 19 965# No pruning due to updating partitioning field. 966# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 967# 1 delete + 1 write due to moved to different partition 968FLUSH STATUS; 969SET TIMESTAMP = 1234567893; 970UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 971SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 972WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 973VARIABLE_NAME VARIABLE_VALUE 974HANDLER_COMMIT 1 975HANDLER_DELETE 1 976HANDLER_EXTERNAL_LOCK 2 977HANDLER_READ_KEY 2 978HANDLER_READ_RND 1 979HANDLER_WRITE 18 980# No pruning due to DEFAULT function on partitioning column 981# 2 read_key + 1 read_rnd (1 read_key due to index lookup, 982# 1 read_rnd + 1 read_key due to positioning before update) 983# 1 delete + 1 write due to moved to different partition 984# + 1 (failed) write 985FLUSH STATUS; 986REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 987SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 988WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 989VARIABLE_NAME VARIABLE_VALUE 990HANDLER_COMMIT 1 991HANDLER_EXTERNAL_LOCK 2 992HANDLER_WRITE 18 993FLUSH STATUS; 994REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 995SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 996WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 997VARIABLE_NAME VARIABLE_VALUE 998HANDLER_COMMIT 1 999HANDLER_EXTERNAL_LOCK 2 1000HANDLER_READ_KEY 1 1001HANDLER_UPDATE 1 1002HANDLER_WRITE 18 1003# 1 read_key + 1 update + 1 failed write 1004# 1005# Test of replace of default PK (delete might be needed first) 1006# 1007DELETE FROM t3 WHERE a = 0; 1008FLUSH STATUS; 1009SET TIMESTAMP = 1234567894; 1010REPLACE INTO t3 (b) VALUES ('Replace3'); 1011SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1012WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1013VARIABLE_NAME VARIABLE_VALUE 1014HANDLER_COMMIT 1 1015HANDLER_EXTERNAL_LOCK 2 1016HANDLER_WRITE 18 1017FLUSH STATUS; 1018SET TIMESTAMP = 1234567894; 1019REPLACE INTO t3 (b) VALUES ('Replace4'); 1020SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1021WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1022VARIABLE_NAME VARIABLE_VALUE 1023HANDLER_COMMIT 1 1024HANDLER_EXTERNAL_LOCK 2 1025HANDLER_READ_KEY 1 1026HANDLER_UPDATE 1 1027HANDLER_WRITE 18 1028# 1 read_key + 1 update + 1 failed write 1029SELECT * FROM t3; 1030a b 10312009-02-14 02:31:30 NULL 10322009-02-14 02:31:31 NULL 10332009-02-14 02:31:32 DUP_KEY 10342009-02-14 02:31:33 Updated 10352009-02-14 02:31:34 Replace4 10362011-01-01 00:00:03 NULL 10372011-01-01 00:00:04 Replace2 10382011-01-01 00:00:05 DUP_KEY2 1039DROP TABLE t3; 1040# 1041# Test INSERT with timestamp column DEFAULT UPDATE 1042# 1043CREATE TABLE t3 1044(a timestamp DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP, 1045b char(10), 1046PRIMARY KEY (a)) 1047PARTITION BY HASH (UNIX_TIMESTAMP(a)) PARTITIONS 3; 1048SHOW CREATE TABLE t3; 1049Table Create Table 1050t3 CREATE TABLE `t3` ( 1051 `a` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, 1052 `b` char(10) DEFAULT NULL, 1053 PRIMARY KEY (`a`) 1054) ENGINE=InnoDB DEFAULT CHARSET=latin1 1055/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) 1056PARTITIONS 3 */ 1057FLUSH STATUS; 1058SET TIMESTAMP = 1234567890; 1059INSERT INTO t3 (a) VALUES (NULL); 1060SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1061WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1062VARIABLE_NAME VARIABLE_VALUE 1063HANDLER_COMMIT 1 1064HANDLER_EXTERNAL_LOCK 2 1065HANDLER_WRITE 18 1066FLUSH STATUS; 1067SET TIMESTAMP = 1234567891; 1068INSERT INTO t3 VALUES (); 1069SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1070WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1071VARIABLE_NAME VARIABLE_VALUE 1072HANDLER_COMMIT 1 1073HANDLER_EXTERNAL_LOCK 2 1074HANDLER_WRITE 18 1075FLUSH STATUS; 1076INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1077SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1078WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1079VARIABLE_NAME VARIABLE_VALUE 1080HANDLER_COMMIT 1 1081HANDLER_EXTERNAL_LOCK 2 1082HANDLER_WRITE 18 1083FLUSH STATUS; 1084INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1085SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1086WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1087VARIABLE_NAME VARIABLE_VALUE 1088HANDLER_COMMIT 1 1089HANDLER_EXTERNAL_LOCK 2 1090HANDLER_WRITE 18 1091FLUSH STATUS; 1092INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1093SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1094WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1095VARIABLE_NAME VARIABLE_VALUE 1096HANDLER_COMMIT 1 1097HANDLER_EXTERNAL_LOCK 2 1098HANDLER_WRITE 19 1099# 2 writes 1100FLUSH STATUS; 1101SET TIMESTAMP = 1234567892; 1102INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1103ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1104SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1105WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1106VARIABLE_NAME VARIABLE_VALUE 1107HANDLER_COMMIT 1 1108HANDLER_DELETE 1 1109HANDLER_EXTERNAL_LOCK 2 1110HANDLER_READ_KEY 1 1111HANDLER_WRITE 19 1112# No pruning due to DEFAULT function on partitioning column 1113# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1114# 1 delete + 1 write due to moved to different partition 1115FLUSH STATUS; 1116INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1117ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1118SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1119WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1120VARIABLE_NAME VARIABLE_VALUE 1121HANDLER_COMMIT 1 1122HANDLER_DELETE 1 1123HANDLER_EXTERNAL_LOCK 2 1124HANDLER_READ_KEY 1 1125HANDLER_WRITE 19 1126# No pruning due to updating partitioning field. 1127# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1128# 1 delete + 1 write due to moved to different partition 1129FLUSH STATUS; 1130SET TIMESTAMP = 1234567893; 1131UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1132SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1133WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1134VARIABLE_NAME VARIABLE_VALUE 1135HANDLER_COMMIT 1 1136HANDLER_DELETE 1 1137HANDLER_EXTERNAL_LOCK 2 1138HANDLER_READ_KEY 2 1139HANDLER_READ_RND 1 1140HANDLER_WRITE 18 1141# No pruning due to DEFAULT function on partitioning column 1142# 2 read_key + 1 read_rnd (1 read_key due to index lookup, 1143# 1 read_rnd + 1 read_key due to positioning before update) 1144# 1 delete + 1 write due to moved to different partition 1145# + 1 (failed) write 1146FLUSH STATUS; 1147REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1148SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1149WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1150VARIABLE_NAME VARIABLE_VALUE 1151HANDLER_COMMIT 1 1152HANDLER_EXTERNAL_LOCK 2 1153HANDLER_WRITE 18 1154FLUSH STATUS; 1155REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1156SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1157WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1158VARIABLE_NAME VARIABLE_VALUE 1159HANDLER_COMMIT 1 1160HANDLER_EXTERNAL_LOCK 2 1161HANDLER_READ_KEY 1 1162HANDLER_UPDATE 1 1163HANDLER_WRITE 18 1164# 1 read_key + 1 update + 1 failed write 1165# 1166# Test of replace of default PK (delete might be needed first) 1167# 1168DELETE FROM t3 WHERE a = 0; 1169FLUSH STATUS; 1170SET TIMESTAMP = 1234567894; 1171REPLACE INTO t3 (b) VALUES ('Replace3'); 1172SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1173WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1174VARIABLE_NAME VARIABLE_VALUE 1175HANDLER_COMMIT 1 1176HANDLER_EXTERNAL_LOCK 2 1177HANDLER_WRITE 18 1178FLUSH STATUS; 1179SET TIMESTAMP = 1234567894; 1180REPLACE INTO t3 (b) VALUES ('Replace4'); 1181SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1182WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1183VARIABLE_NAME VARIABLE_VALUE 1184HANDLER_COMMIT 1 1185HANDLER_EXTERNAL_LOCK 2 1186HANDLER_READ_KEY 1 1187HANDLER_UPDATE 1 1188HANDLER_WRITE 18 1189# 1 read_key + 1 update + 1 failed write 1190SELECT * FROM t3; 1191a b 11920000-00-00 00:00:00 Replace4 11932009-02-14 02:31:30 NULL 11942009-02-14 02:31:32 DUP_KEY 11952009-02-14 02:31:33 Updated 11962011-01-01 00:00:03 NULL 11972011-01-01 00:00:04 Replace2 11982011-01-01 00:00:05 DUP_KEY2 1199DROP TABLE t3; 1200# 1201# Test INSERT with timestamp column DEFAULT INSERT 1202# 1203CREATE TABLE t3 1204(a timestamp DEFAULT CURRENT_TIMESTAMP, 1205b char(10), 1206PRIMARY KEY (a)) 1207PARTITION BY HASH (UNIX_TIMESTAMP(a)) PARTITIONS 3; 1208SHOW CREATE TABLE t3; 1209Table Create Table 1210t3 CREATE TABLE `t3` ( 1211 `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 1212 `b` char(10) DEFAULT NULL, 1213 PRIMARY KEY (`a`) 1214) ENGINE=InnoDB DEFAULT CHARSET=latin1 1215/*!50100 PARTITION BY HASH (UNIX_TIMESTAMP(a)) 1216PARTITIONS 3 */ 1217FLUSH STATUS; 1218SET TIMESTAMP = 1234567890; 1219INSERT INTO t3 (a) VALUES (NULL); 1220SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1221WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1222VARIABLE_NAME VARIABLE_VALUE 1223HANDLER_COMMIT 1 1224HANDLER_EXTERNAL_LOCK 2 1225HANDLER_WRITE 18 1226FLUSH STATUS; 1227SET TIMESTAMP = 1234567891; 1228INSERT INTO t3 VALUES (); 1229SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1230WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1231VARIABLE_NAME VARIABLE_VALUE 1232HANDLER_COMMIT 1 1233HANDLER_EXTERNAL_LOCK 2 1234HANDLER_WRITE 18 1235FLUSH STATUS; 1236INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1237SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1238WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1239VARIABLE_NAME VARIABLE_VALUE 1240HANDLER_COMMIT 1 1241HANDLER_EXTERNAL_LOCK 2 1242HANDLER_WRITE 18 1243FLUSH STATUS; 1244INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1245SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1246WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1247VARIABLE_NAME VARIABLE_VALUE 1248HANDLER_COMMIT 1 1249HANDLER_EXTERNAL_LOCK 2 1250HANDLER_WRITE 18 1251FLUSH STATUS; 1252INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1253SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1254WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1255VARIABLE_NAME VARIABLE_VALUE 1256HANDLER_COMMIT 1 1257HANDLER_EXTERNAL_LOCK 2 1258HANDLER_WRITE 19 1259# 2 writes 1260FLUSH STATUS; 1261SET TIMESTAMP = 1234567892; 1262INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1263ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1264SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1265WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1266VARIABLE_NAME VARIABLE_VALUE 1267HANDLER_COMMIT 1 1268HANDLER_EXTERNAL_LOCK 2 1269HANDLER_READ_KEY 1 1270HANDLER_UPDATE 1 1271HANDLER_WRITE 18 1272# 1 read_key + 1 update (same partition) 1273# 1 (failed) write 1274FLUSH STATUS; 1275INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1276ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1277SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1278WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1279VARIABLE_NAME VARIABLE_VALUE 1280HANDLER_COMMIT 1 1281HANDLER_DELETE 1 1282HANDLER_EXTERNAL_LOCK 2 1283HANDLER_READ_KEY 1 1284HANDLER_WRITE 19 1285# No pruning due to updating partitioning field. 1286# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1287# 1 delete + 1 write due to moved to different partition 1288FLUSH STATUS; 1289SET TIMESTAMP = 1234567893; 1290UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1291SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1292WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1293VARIABLE_NAME VARIABLE_VALUE 1294HANDLER_COMMIT 1 1295HANDLER_EXTERNAL_LOCK 2 1296HANDLER_READ_KEY 1 1297HANDLER_UPDATE 1 1298HANDLER_WRITE 17 1299# 1 read_key + 1 update (same partition) 1300# 1 (failed) write 1301FLUSH STATUS; 1302REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1303SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1304WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1305VARIABLE_NAME VARIABLE_VALUE 1306HANDLER_COMMIT 1 1307HANDLER_EXTERNAL_LOCK 2 1308HANDLER_WRITE 18 1309FLUSH STATUS; 1310REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1311SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1312WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1313VARIABLE_NAME VARIABLE_VALUE 1314HANDLER_COMMIT 1 1315HANDLER_EXTERNAL_LOCK 2 1316HANDLER_READ_KEY 1 1317HANDLER_UPDATE 1 1318HANDLER_WRITE 18 1319# 1 read_key + 1 update + 1 failed write 1320# 1321# Test of replace of default PK (delete might be needed first) 1322# 1323DELETE FROM t3 WHERE a = 0; 1324FLUSH STATUS; 1325SET TIMESTAMP = 1234567894; 1326REPLACE INTO t3 (b) VALUES ('Replace3'); 1327SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1328WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1329VARIABLE_NAME VARIABLE_VALUE 1330HANDLER_COMMIT 1 1331HANDLER_EXTERNAL_LOCK 2 1332HANDLER_WRITE 18 1333FLUSH STATUS; 1334SET TIMESTAMP = 1234567894; 1335REPLACE INTO t3 (b) VALUES ('Replace4'); 1336SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1337WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1338VARIABLE_NAME VARIABLE_VALUE 1339HANDLER_COMMIT 1 1340HANDLER_EXTERNAL_LOCK 2 1341HANDLER_READ_KEY 1 1342HANDLER_UPDATE 1 1343HANDLER_WRITE 18 1344# 1 read_key + 1 update + 1 failed write 1345SELECT * FROM t3; 1346a b 13472009-02-14 02:31:30 NULL 13482009-02-14 02:31:31 NULL 13492009-02-14 02:31:34 Replace4 13502011-01-01 00:00:00 DUP_KEY 13512011-01-01 00:00:02 Updated 13522011-01-01 00:00:03 NULL 13532011-01-01 00:00:04 Replace2 13542011-01-01 00:00:05 DUP_KEY2 1355DROP TABLE t3; 1356# 1357# Test INSERT with DATETIME column NO default function 1358# 1359CREATE TABLE t3 1360(a DATETIME DEFAULT 0, 1361b char(10), 1362PRIMARY KEY (a)) 1363PARTITION BY KEY (a) PARTITIONS 3; 1364SHOW CREATE TABLE t3; 1365Table Create Table 1366t3 CREATE TABLE `t3` ( 1367 `a` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 1368 `b` char(10) DEFAULT NULL, 1369 PRIMARY KEY (`a`) 1370) ENGINE=InnoDB DEFAULT CHARSET=latin1 1371/*!50100 PARTITION BY KEY (a) 1372PARTITIONS 3 */ 1373FLUSH STATUS; 1374SET TIMESTAMP = 1234567891; 1375INSERT INTO t3 VALUES (); 1376SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1377WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1378VARIABLE_NAME VARIABLE_VALUE 1379HANDLER_COMMIT 1 1380HANDLER_EXTERNAL_LOCK 2 1381HANDLER_WRITE 18 1382FLUSH STATUS; 1383INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1384SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1385WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1386VARIABLE_NAME VARIABLE_VALUE 1387HANDLER_COMMIT 1 1388HANDLER_EXTERNAL_LOCK 2 1389HANDLER_WRITE 18 1390FLUSH STATUS; 1391INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1392SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1393WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1394VARIABLE_NAME VARIABLE_VALUE 1395HANDLER_COMMIT 1 1396HANDLER_EXTERNAL_LOCK 2 1397HANDLER_WRITE 18 1398FLUSH STATUS; 1399INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1400SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1401WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1402VARIABLE_NAME VARIABLE_VALUE 1403HANDLER_COMMIT 1 1404HANDLER_EXTERNAL_LOCK 2 1405HANDLER_WRITE 19 1406# 2 writes 1407FLUSH STATUS; 1408SET TIMESTAMP = 1234567892; 1409INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1410ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1411SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1412WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1413VARIABLE_NAME VARIABLE_VALUE 1414HANDLER_COMMIT 1 1415HANDLER_EXTERNAL_LOCK 2 1416HANDLER_READ_KEY 1 1417HANDLER_UPDATE 1 1418HANDLER_WRITE 18 1419# 1 read_key + 1 update (same partition) 1420# 1 (failed) write 1421FLUSH STATUS; 1422INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1423ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1424SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1425WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1426VARIABLE_NAME VARIABLE_VALUE 1427HANDLER_COMMIT 1 1428HANDLER_DELETE 1 1429HANDLER_EXTERNAL_LOCK 2 1430HANDLER_READ_KEY 1 1431HANDLER_WRITE 19 1432# No pruning due to updating partitioning field. 1433# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1434# 1 delete + 1 write due to moved to different partition 1435FLUSH STATUS; 1436SET TIMESTAMP = 1234567893; 1437UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1438SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1439WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1440VARIABLE_NAME VARIABLE_VALUE 1441HANDLER_COMMIT 1 1442HANDLER_EXTERNAL_LOCK 2 1443HANDLER_READ_KEY 1 1444HANDLER_UPDATE 1 1445HANDLER_WRITE 17 1446# 1 read_key + 1 update (same partition) 1447# 1 (failed) write 1448FLUSH STATUS; 1449REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1450SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1451WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1452VARIABLE_NAME VARIABLE_VALUE 1453HANDLER_COMMIT 1 1454HANDLER_EXTERNAL_LOCK 2 1455HANDLER_WRITE 18 1456FLUSH STATUS; 1457REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1458SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1459WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1460VARIABLE_NAME VARIABLE_VALUE 1461HANDLER_COMMIT 1 1462HANDLER_EXTERNAL_LOCK 2 1463HANDLER_READ_KEY 1 1464HANDLER_UPDATE 1 1465HANDLER_WRITE 18 1466# 1 read_key + 1 update + 1 failed write 1467# 1468# Test of replace of default PK (delete might be needed first) 1469# 1470DELETE FROM t3 WHERE a = 0; 1471FLUSH STATUS; 1472SET TIMESTAMP = 1234567894; 1473REPLACE INTO t3 (b) VALUES ('Replace3'); 1474SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1475WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1476VARIABLE_NAME VARIABLE_VALUE 1477HANDLER_COMMIT 1 1478HANDLER_EXTERNAL_LOCK 2 1479HANDLER_WRITE 18 1480FLUSH STATUS; 1481SET TIMESTAMP = 1234567894; 1482REPLACE INTO t3 (b) VALUES ('Replace4'); 1483SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1484WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1485VARIABLE_NAME VARIABLE_VALUE 1486HANDLER_COMMIT 1 1487HANDLER_EXTERNAL_LOCK 2 1488HANDLER_READ_KEY 1 1489HANDLER_UPDATE 1 1490HANDLER_WRITE 18 1491# 1 read_key + 1 update + 1 failed write 1492SELECT * FROM t3; 1493a b 14940000-00-00 00:00:00 Replace4 14952011-01-01 00:00:00 DUP_KEY 14962011-01-01 00:00:02 Updated 14972011-01-01 00:00:03 NULL 14982011-01-01 00:00:04 Replace2 14992011-01-01 00:00:05 DUP_KEY2 1500DROP TABLE t3; 1501# 1502# Test INSERT with DATETIME column DEFAULT INSERT + UPDATE 1503# 1504CREATE TABLE t3 1505(a DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 1506b char(10), 1507PRIMARY KEY (a)) 1508PARTITION BY KEY (a) PARTITIONS 3; 1509SHOW CREATE TABLE t3; 1510Table Create Table 1511t3 CREATE TABLE `t3` ( 1512 `a` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 1513 `b` char(10) DEFAULT NULL, 1514 PRIMARY KEY (`a`) 1515) ENGINE=InnoDB DEFAULT CHARSET=latin1 1516/*!50100 PARTITION BY KEY (a) 1517PARTITIONS 3 */ 1518FLUSH STATUS; 1519SET TIMESTAMP = 1234567891; 1520INSERT INTO t3 VALUES (); 1521SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1522WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1523VARIABLE_NAME VARIABLE_VALUE 1524HANDLER_COMMIT 1 1525HANDLER_EXTERNAL_LOCK 2 1526HANDLER_WRITE 18 1527FLUSH STATUS; 1528INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1529SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1530WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1531VARIABLE_NAME VARIABLE_VALUE 1532HANDLER_COMMIT 1 1533HANDLER_EXTERNAL_LOCK 2 1534HANDLER_WRITE 18 1535FLUSH STATUS; 1536INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1537SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1538WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1539VARIABLE_NAME VARIABLE_VALUE 1540HANDLER_COMMIT 1 1541HANDLER_EXTERNAL_LOCK 2 1542HANDLER_WRITE 18 1543FLUSH STATUS; 1544INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1545SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1546WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1547VARIABLE_NAME VARIABLE_VALUE 1548HANDLER_COMMIT 1 1549HANDLER_EXTERNAL_LOCK 2 1550HANDLER_WRITE 19 1551# 2 writes 1552FLUSH STATUS; 1553SET TIMESTAMP = 1234567892; 1554INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1555ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1556SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1557WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1558VARIABLE_NAME VARIABLE_VALUE 1559HANDLER_COMMIT 1 1560HANDLER_DELETE 1 1561HANDLER_EXTERNAL_LOCK 2 1562HANDLER_READ_KEY 1 1563HANDLER_WRITE 19 1564# No pruning due to DEFAULT function on partitioning column 1565# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1566# 1 delete + 1 write due to moved to different partition 1567FLUSH STATUS; 1568INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1569ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1570SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1571WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1572VARIABLE_NAME VARIABLE_VALUE 1573HANDLER_COMMIT 1 1574HANDLER_DELETE 1 1575HANDLER_EXTERNAL_LOCK 2 1576HANDLER_READ_KEY 1 1577HANDLER_WRITE 19 1578# No pruning due to updating partitioning field. 1579# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1580# 1 delete + 1 write due to moved to different partition 1581FLUSH STATUS; 1582SET TIMESTAMP = 1234567893; 1583UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1584SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1585WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1586VARIABLE_NAME VARIABLE_VALUE 1587HANDLER_COMMIT 1 1588HANDLER_EXTERNAL_LOCK 2 1589HANDLER_READ_KEY 2 1590HANDLER_READ_RND 1 1591HANDLER_UPDATE 1 1592HANDLER_WRITE 17 1593# No pruning due to DEFAULT function on partitioning column 1594# 2 read_key + 1 read_rnd (1 read_key due to index lookup, 1595# 1 read_rnd + 1 read_key due to positioning before update) 1596# 1 delete + 1 write due to moved to different partition 1597# + 1 (failed) write 1598FLUSH STATUS; 1599REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1600SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1601WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1602VARIABLE_NAME VARIABLE_VALUE 1603HANDLER_COMMIT 1 1604HANDLER_EXTERNAL_LOCK 2 1605HANDLER_WRITE 18 1606FLUSH STATUS; 1607REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1608SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1609WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1610VARIABLE_NAME VARIABLE_VALUE 1611HANDLER_COMMIT 1 1612HANDLER_EXTERNAL_LOCK 2 1613HANDLER_READ_KEY 1 1614HANDLER_UPDATE 1 1615HANDLER_WRITE 18 1616# 1 read_key + 1 update + 1 failed write 1617# 1618# Test of replace of default PK (delete might be needed first) 1619# 1620DELETE FROM t3 WHERE a = 0; 1621FLUSH STATUS; 1622SET TIMESTAMP = 1234567894; 1623REPLACE INTO t3 (b) VALUES ('Replace3'); 1624SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1625WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1626VARIABLE_NAME VARIABLE_VALUE 1627HANDLER_COMMIT 1 1628HANDLER_EXTERNAL_LOCK 2 1629HANDLER_WRITE 18 1630FLUSH STATUS; 1631SET TIMESTAMP = 1234567894; 1632REPLACE INTO t3 (b) VALUES ('Replace4'); 1633SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1634WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1635VARIABLE_NAME VARIABLE_VALUE 1636HANDLER_COMMIT 1 1637HANDLER_EXTERNAL_LOCK 2 1638HANDLER_READ_KEY 1 1639HANDLER_UPDATE 1 1640HANDLER_WRITE 18 1641# 1 read_key + 1 update + 1 failed write 1642SELECT * FROM t3; 1643a b 16442009-02-14 02:31:31 NULL 16452009-02-14 02:31:32 DUP_KEY 16462009-02-14 02:31:33 Updated 16472009-02-14 02:31:34 Replace4 16482011-01-01 00:00:03 NULL 16492011-01-01 00:00:04 Replace2 16502011-01-01 00:00:05 DUP_KEY2 1651DROP TABLE t3; 1652# 1653# Test INSERT with DATETIME column DEFAULT UPDATE 1654# 1655CREATE TABLE t3 1656(a DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP, 1657b char(10), 1658PRIMARY KEY (a)) 1659PARTITION BY KEY (a) PARTITIONS 3; 1660SHOW CREATE TABLE t3; 1661Table Create Table 1662t3 CREATE TABLE `t3` ( 1663 `a` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, 1664 `b` char(10) DEFAULT NULL, 1665 PRIMARY KEY (`a`) 1666) ENGINE=InnoDB DEFAULT CHARSET=latin1 1667/*!50100 PARTITION BY KEY (a) 1668PARTITIONS 3 */ 1669FLUSH STATUS; 1670SET TIMESTAMP = 1234567891; 1671INSERT INTO t3 VALUES (); 1672SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1673WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1674VARIABLE_NAME VARIABLE_VALUE 1675HANDLER_COMMIT 1 1676HANDLER_EXTERNAL_LOCK 2 1677HANDLER_WRITE 18 1678FLUSH STATUS; 1679INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1680SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1681WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1682VARIABLE_NAME VARIABLE_VALUE 1683HANDLER_COMMIT 1 1684HANDLER_EXTERNAL_LOCK 2 1685HANDLER_WRITE 18 1686FLUSH STATUS; 1687INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1688SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1689WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1690VARIABLE_NAME VARIABLE_VALUE 1691HANDLER_COMMIT 1 1692HANDLER_EXTERNAL_LOCK 2 1693HANDLER_WRITE 18 1694FLUSH STATUS; 1695INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1696SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1697WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1698VARIABLE_NAME VARIABLE_VALUE 1699HANDLER_COMMIT 1 1700HANDLER_EXTERNAL_LOCK 2 1701HANDLER_WRITE 19 1702# 2 writes 1703FLUSH STATUS; 1704SET TIMESTAMP = 1234567892; 1705INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1706ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1707SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1708WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1709VARIABLE_NAME VARIABLE_VALUE 1710HANDLER_COMMIT 1 1711HANDLER_DELETE 1 1712HANDLER_EXTERNAL_LOCK 2 1713HANDLER_READ_KEY 1 1714HANDLER_WRITE 19 1715# No pruning due to DEFAULT function on partitioning column 1716# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1717# 1 delete + 1 write due to moved to different partition 1718FLUSH STATUS; 1719INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1720ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1721SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1722WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1723VARIABLE_NAME VARIABLE_VALUE 1724HANDLER_COMMIT 1 1725HANDLER_DELETE 1 1726HANDLER_EXTERNAL_LOCK 2 1727HANDLER_READ_KEY 1 1728HANDLER_WRITE 19 1729# No pruning due to updating partitioning field. 1730# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1731# 1 delete + 1 write due to moved to different partition 1732FLUSH STATUS; 1733SET TIMESTAMP = 1234567893; 1734UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1735SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1736WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1737VARIABLE_NAME VARIABLE_VALUE 1738HANDLER_COMMIT 1 1739HANDLER_EXTERNAL_LOCK 2 1740HANDLER_READ_KEY 2 1741HANDLER_READ_RND 1 1742HANDLER_UPDATE 1 1743HANDLER_WRITE 17 1744# No pruning due to DEFAULT function on partitioning column 1745# 2 read_key + 1 read_rnd (1 read_key due to index lookup, 1746# 1 read_rnd + 1 read_key due to positioning before update) 1747# 1 delete + 1 write due to moved to different partition 1748# + 1 (failed) write 1749FLUSH STATUS; 1750REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1751SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1752WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1753VARIABLE_NAME VARIABLE_VALUE 1754HANDLER_COMMIT 1 1755HANDLER_EXTERNAL_LOCK 2 1756HANDLER_WRITE 18 1757FLUSH STATUS; 1758REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1759SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1760WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1761VARIABLE_NAME VARIABLE_VALUE 1762HANDLER_COMMIT 1 1763HANDLER_EXTERNAL_LOCK 2 1764HANDLER_READ_KEY 1 1765HANDLER_UPDATE 1 1766HANDLER_WRITE 18 1767# 1 read_key + 1 update + 1 failed write 1768# 1769# Test of replace of default PK (delete might be needed first) 1770# 1771DELETE FROM t3 WHERE a = 0; 1772FLUSH STATUS; 1773SET TIMESTAMP = 1234567894; 1774REPLACE INTO t3 (b) VALUES ('Replace3'); 1775SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1776WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1777VARIABLE_NAME VARIABLE_VALUE 1778HANDLER_COMMIT 1 1779HANDLER_EXTERNAL_LOCK 2 1780HANDLER_WRITE 18 1781FLUSH STATUS; 1782SET TIMESTAMP = 1234567894; 1783REPLACE INTO t3 (b) VALUES ('Replace4'); 1784SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1785WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1786VARIABLE_NAME VARIABLE_VALUE 1787HANDLER_COMMIT 1 1788HANDLER_EXTERNAL_LOCK 2 1789HANDLER_READ_KEY 1 1790HANDLER_UPDATE 1 1791HANDLER_WRITE 18 1792# 1 read_key + 1 update + 1 failed write 1793SELECT * FROM t3; 1794a b 17950000-00-00 00:00:00 Replace4 17962009-02-14 02:31:32 DUP_KEY 17972009-02-14 02:31:33 Updated 17982011-01-01 00:00:03 NULL 17992011-01-01 00:00:04 Replace2 18002011-01-01 00:00:05 DUP_KEY2 1801DROP TABLE t3; 1802# 1803# Test INSERT with DATETIME column DEFAULT INSERT 1804# 1805CREATE TABLE t3 1806(a DATETIME DEFAULT CURRENT_TIMESTAMP, 1807b char(10), 1808PRIMARY KEY (a)) 1809PARTITION BY KEY (a) PARTITIONS 3; 1810SHOW CREATE TABLE t3; 1811Table Create Table 1812t3 CREATE TABLE `t3` ( 1813 `a` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 1814 `b` char(10) DEFAULT NULL, 1815 PRIMARY KEY (`a`) 1816) ENGINE=InnoDB DEFAULT CHARSET=latin1 1817/*!50100 PARTITION BY KEY (a) 1818PARTITIONS 3 */ 1819FLUSH STATUS; 1820SET TIMESTAMP = 1234567891; 1821INSERT INTO t3 VALUES (); 1822SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1823WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1824VARIABLE_NAME VARIABLE_VALUE 1825HANDLER_COMMIT 1 1826HANDLER_EXTERNAL_LOCK 2 1827HANDLER_WRITE 18 1828FLUSH STATUS; 1829INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00'); 1830SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1831WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1832VARIABLE_NAME VARIABLE_VALUE 1833HANDLER_COMMIT 1 1834HANDLER_EXTERNAL_LOCK 2 1835HANDLER_WRITE 18 1836FLUSH STATUS; 1837INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01'); 1838SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1839WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1840VARIABLE_NAME VARIABLE_VALUE 1841HANDLER_COMMIT 1 1842HANDLER_EXTERNAL_LOCK 2 1843HANDLER_WRITE 18 1844FLUSH STATUS; 1845INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:02'), ('2011-01-01 00:00:03'); 1846SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1847WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1848VARIABLE_NAME VARIABLE_VALUE 1849HANDLER_COMMIT 1 1850HANDLER_EXTERNAL_LOCK 2 1851HANDLER_WRITE 19 1852# 2 writes 1853FLUSH STATUS; 1854SET TIMESTAMP = 1234567892; 1855INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:00') 1856ON DUPLICATE KEY UPDATE b = "DUP_KEY"; 1857SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1858WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1859VARIABLE_NAME VARIABLE_VALUE 1860HANDLER_COMMIT 1 1861HANDLER_EXTERNAL_LOCK 2 1862HANDLER_READ_KEY 1 1863HANDLER_UPDATE 1 1864HANDLER_WRITE 18 1865# 1 read_key + 1 update (same partition) 1866# 1 (failed) write 1867FLUSH STATUS; 1868INSERT INTO t3 (a) VALUES ('2011-01-01 00:00:01') 1869ON DUPLICATE KEY UPDATE a = '2011-01-01 00:00:05', b = "DUP_KEY2"; 1870SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1871WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1872VARIABLE_NAME VARIABLE_VALUE 1873HANDLER_COMMIT 1 1874HANDLER_DELETE 1 1875HANDLER_EXTERNAL_LOCK 2 1876HANDLER_READ_KEY 1 1877HANDLER_WRITE 19 1878# No pruning due to updating partitioning field. 1879# 1 read_key + 1 delete + 2 write (1 failed + 1 ok) 1880# 1 delete + 1 write due to moved to different partition 1881FLUSH STATUS; 1882SET TIMESTAMP = 1234567893; 1883UPDATE t3 SET b = 'Updated' WHERE a = '2011-01-01 00:00:02'; 1884SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1885WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1886VARIABLE_NAME VARIABLE_VALUE 1887HANDLER_COMMIT 1 1888HANDLER_EXTERNAL_LOCK 2 1889HANDLER_READ_KEY 1 1890HANDLER_UPDATE 1 1891HANDLER_WRITE 17 1892# 1 read_key + 1 update (same partition) 1893# 1 (failed) write 1894FLUSH STATUS; 1895REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace1'); 1896SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1897WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1898VARIABLE_NAME VARIABLE_VALUE 1899HANDLER_COMMIT 1 1900HANDLER_EXTERNAL_LOCK 2 1901HANDLER_WRITE 18 1902FLUSH STATUS; 1903REPLACE INTO t3 VALUES ('2011-01-01 00:00:04', 'Replace2'); 1904SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1905WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1906VARIABLE_NAME VARIABLE_VALUE 1907HANDLER_COMMIT 1 1908HANDLER_EXTERNAL_LOCK 2 1909HANDLER_READ_KEY 1 1910HANDLER_UPDATE 1 1911HANDLER_WRITE 18 1912# 1 read_key + 1 update + 1 failed write 1913# 1914# Test of replace of default PK (delete might be needed first) 1915# 1916DELETE FROM t3 WHERE a = 0; 1917FLUSH STATUS; 1918SET TIMESTAMP = 1234567894; 1919REPLACE INTO t3 (b) VALUES ('Replace3'); 1920SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1921WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1922VARIABLE_NAME VARIABLE_VALUE 1923HANDLER_COMMIT 1 1924HANDLER_EXTERNAL_LOCK 2 1925HANDLER_WRITE 18 1926FLUSH STATUS; 1927SET TIMESTAMP = 1234567894; 1928REPLACE INTO t3 (b) VALUES ('Replace4'); 1929SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1930WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1931VARIABLE_NAME VARIABLE_VALUE 1932HANDLER_COMMIT 1 1933HANDLER_EXTERNAL_LOCK 2 1934HANDLER_READ_KEY 1 1935HANDLER_UPDATE 1 1936HANDLER_WRITE 18 1937# 1 read_key + 1 update + 1 failed write 1938SELECT * FROM t3; 1939a b 19402009-02-14 02:31:31 NULL 19412009-02-14 02:31:34 Replace4 19422011-01-01 00:00:00 DUP_KEY 19432011-01-01 00:00:02 Updated 19442011-01-01 00:00:03 NULL 19452011-01-01 00:00:04 Replace2 19462011-01-01 00:00:05 DUP_KEY2 1947DROP TABLE t3; 1948SET sql_mode = default; 1949# 1950# Test INSERT SELECT 1951# 1952FLUSH STATUS; 1953TRUNCATE TABLE t2; 1954SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1955WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1956VARIABLE_NAME VARIABLE_VALUE 1957HANDLER_COMMIT 1 1958HANDLER_EXTERNAL_LOCK 2 1959HANDLER_WRITE 17 1960# All partitions needs to be locked 1961# 1 commit 1962FLUSH STATUS; 1963INSERT INTO t2 SELECT a, b FROM t1 WHERE a IN (1,4); 1964SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1965WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1966VARIABLE_NAME VARIABLE_VALUE 1967HANDLER_COMMIT 1 1968HANDLER_EXTERNAL_LOCK 4 1969HANDLER_READ_FIRST 2 1970HANDLER_READ_KEY 2 1971HANDLER_READ_NEXT 2 1972HANDLER_WRITE 19 1973# All partitions in t2 needs to be locked (no propagation from t1 yet). 1974# 2 partitions in t1 needs to be locked (for 1 and 4) 1975# 2 read_first, read_key and read_next. 1976# 1 commit 1977# 1978# Test TRUNCATE PARTITION 1979# 1980FLUSH STATUS; 1981ALTER TABLE t2 TRUNCATE PARTITION p1; 1982SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1983WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1984VARIABLE_NAME VARIABLE_VALUE 1985HANDLER_COMMIT 1 1986HANDLER_EXTERNAL_LOCK 2 1987HANDLER_WRITE 17 1988FLUSH STATUS; 1989INSERT INTO t2 SELECT a, b FROM t1 WHERE a = 1; 1990SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 1991WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 1992VARIABLE_NAME VARIABLE_VALUE 1993HANDLER_COMMIT 1 1994HANDLER_EXTERNAL_LOCK 4 1995HANDLER_READ_KEY 1 1996HANDLER_WRITE 18 1997# 1998# Test insert on duplicated key update 1999# 2000FLUSH STATUS; 2001INSERT INTO t1 VALUES (65, "No duplicate") 2002ON DUPLICATE KEY UPDATE b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE"); 2003SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2004WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2005VARIABLE_NAME VARIABLE_VALUE 2006HANDLER_COMMIT 1 2007HANDLER_EXTERNAL_LOCK 2 2008HANDLER_WRITE 18 2009# 1 write (insert) 2010# 1 commit 2011FLUSH STATUS; 2012INSERT INTO t1 VALUES (65, "No duplicate") 2013ON DUPLICATE KEY UPDATE b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE"); 2014SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2015WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2016VARIABLE_NAME VARIABLE_VALUE 2017HANDLER_COMMIT 1 2018HANDLER_EXTERNAL_LOCK 2 2019HANDLER_READ_KEY 1 2020HANDLER_UPDATE 1 2021HANDLER_WRITE 18 2022# 1 read_key 2023# 1 update 2024# 1 commit 2025FLUSH STATUS; 2026INSERT INTO t1 VALUES (78, "No duplicate") 2027ON DUPLICATE KEY UPDATE a = a + 13, b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE"); 2028SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2029WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2030VARIABLE_NAME VARIABLE_VALUE 2031HANDLER_COMMIT 1 2032HANDLER_EXTERNAL_LOCK 2 2033HANDLER_WRITE 18 2034# If a partitioning column is updated, no pruning 2035# 1 write (insert) 2036# 1 commit 2037FLUSH STATUS; 2038INSERT INTO t1 VALUES (78, "No duplicate") 2039ON DUPLICATE KEY UPDATE a = a + 13, b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE"); 2040SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2041WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2042VARIABLE_NAME VARIABLE_VALUE 2043HANDLER_COMMIT 1 2044HANDLER_EXTERNAL_LOCK 2 2045HANDLER_READ_KEY 1 2046HANDLER_UPDATE 1 2047HANDLER_WRITE 18 2048# If partitioning column is updated, no pruning 2049# 1 read_key 2050# 1 update 2051# 1 commit 2052# 2053# Test of insert on duplicate key with failed update 2054# 2055FLUSH STATUS; 2056INSERT INTO t1 VALUES (78, "No duplicate") 2057ON DUPLICATE KEY UPDATE a = a + 13, 2058b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE third"); 2059SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2060WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2061VARIABLE_NAME VARIABLE_VALUE 2062HANDLER_COMMIT 1 2063HANDLER_EXTERNAL_LOCK 2 2064HANDLER_WRITE 18 2065# If partitioning column is updated, no pruning 2066# 1 commit 2067FLUSH STATUS; 2068INSERT INTO t1 VALUES (78, "No duplicate") 2069ON DUPLICATE KEY UPDATE a = a + 13, 2070b = CONCAT(b, ", INSERT_DUP_KEY_UPDATE fail?"); 2071ERROR 23000: Duplicate entry '91' for key 'PRIMARY' 2072SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2073WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2074VARIABLE_NAME VARIABLE_VALUE 2075HANDLER_EXTERNAL_LOCK 2 2076HANDLER_READ_KEY 1 2077HANDLER_ROLLBACK 1 2078HANDLER_UPDATE 1 2079HANDLER_WRITE 18 2080# If partitioning column is updated, no pruning 2081# 1 read_key 2082# 1 update 2083# 1 rollback 2084# 2085# Test of insert on duplicate key with update to different partition 2086# 2087FLUSH STATUS; 2088INSERT INTO t1 VALUES (104, "No duplicate") 2089ON DUPLICATE KEY UPDATE a = a + 1; 2090SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2091WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2092VARIABLE_NAME VARIABLE_VALUE 2093HANDLER_COMMIT 1 2094HANDLER_EXTERNAL_LOCK 2 2095HANDLER_WRITE 18 2096# If partitioning column is updated, no pruning 2097# 1 write 2098# 1 commit 2099FLUSH STATUS; 2100INSERT INTO t1 VALUES (104, "No duplicate") 2101ON DUPLICATE KEY UPDATE a = a + 1; 2102SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2103WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2104VARIABLE_NAME VARIABLE_VALUE 2105HANDLER_COMMIT 1 2106HANDLER_DELETE 1 2107HANDLER_EXTERNAL_LOCK 2 2108HANDLER_READ_KEY 1 2109HANDLER_WRITE 19 2110# If partitioning column is updated, no pruning 2111# 1 delete 2112# 1 write 2113# 1 read_key 2114# 1 commit 2115FLUSH STATUS; 2116INSERT INTO t1 VALUES (104, "No duplicate 104") 2117ON DUPLICATE KEY UPDATE a = a + 1; 2118SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2119WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2120VARIABLE_NAME VARIABLE_VALUE 2121HANDLER_COMMIT 1 2122HANDLER_EXTERNAL_LOCK 2 2123HANDLER_WRITE 18 2124# If partitioning column is updated, no pruning 2125# 1 write 2126# 1 commit 2127# 2128# Test of insert on duplicate key with failed update to different 2129# partition 2130# 2131FLUSH STATUS; 2132INSERT INTO t1 VALUES (104, "No duplicate 104 + 1") 2133ON DUPLICATE KEY UPDATE a = a + 1; 2134ERROR 23000: Duplicate entry '105' for key 'PRIMARY' 2135SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2136WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2137VARIABLE_NAME VARIABLE_VALUE 2138HANDLER_EXTERNAL_LOCK 2 2139HANDLER_READ_KEY 1 2140HANDLER_ROLLBACK 1 2141HANDLER_WRITE 19 2142# If partitioning column is updated, no pruning 2143# 1 write 2144# 1 read_key 2145# 1 rollback 2146# 2147# Test replace 2148# 2149FLUSH STATUS; 2150REPLACE INTO t1 VALUES (5, "REPLACE first"); 2151SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2152WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2153VARIABLE_NAME VARIABLE_VALUE 2154HANDLER_COMMIT 1 2155HANDLER_EXTERNAL_LOCK 2 2156HANDLER_WRITE 18 2157# 1 write 2158# 1 commit 2159FLUSH STATUS; 2160REPLACE INTO t1 VALUES (5, "REPLACE second"); 2161SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2162WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2163VARIABLE_NAME VARIABLE_VALUE 2164HANDLER_COMMIT 1 2165HANDLER_EXTERNAL_LOCK 2 2166HANDLER_READ_KEY 1 2167HANDLER_UPDATE 1 2168HANDLER_WRITE 18 2169# 1 write 2170# 1 read_key 2171# 1 update (NOTE: write_record() may cheat instead of delete/insert!) 2172# 1 rollback 2173# 2174# Test SELECT 2175# 2176FLUSH STATUS; 2177SELECT * FROM t1 ORDER BY a; 2178a b 21790 First row, p0 21801 First row, p1 21812 First row, p2 21823 First row, p3 21834 First row, p4 21845 REPLACE second 218513 Second row, p0 218626 Third row, p0 218739 Fourth row, p0 218852 Fifth row, p0 218965 No duplicate, INSERT_DUP_KEY_UPDATE 219078 No duplicate 219191 No duplicate, INSERT_DUP_KEY_UPDATE 2192104 No duplicate 104 2193105 No duplicate 2194SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2195WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2196VARIABLE_NAME VARIABLE_VALUE 2197HANDLER_COMMIT 1 2198HANDLER_EXTERNAL_LOCK 2 2199HANDLER_READ_FIRST 13 2200HANDLER_READ_KEY 13 2201HANDLER_READ_NEXT 15 2202HANDLER_WRITE 17 2203# 13 read_first 2204# 13 read_key 2205# 15 read_next 2206FLUSH STATUS; 2207SELECT * FROM t1 WHERE a IN (0, 1, 4) ORDER BY a; 2208a b 22090 First row, p0 22101 First row, p1 22114 First row, p4 2212SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2213WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2214VARIABLE_NAME VARIABLE_VALUE 2215HANDLER_COMMIT 1 2216HANDLER_EXTERNAL_LOCK 2 2217HANDLER_READ_FIRST 3 2218HANDLER_READ_KEY 3 2219HANDLER_READ_NEXT 12 2220HANDLER_WRITE 17 2221# 3 read_first, read_key 2222# 12 read_next 2223FLUSH STATUS; 2224SELECT * FROM t1 WHERE a IN (13, 26, 39, 52); 2225a b 222613 Second row, p0 222726 Third row, p0 222839 Fourth row, p0 222952 Fifth row, p0 2230SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2231WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2232VARIABLE_NAME VARIABLE_VALUE 2233HANDLER_COMMIT 1 2234HANDLER_EXTERNAL_LOCK 2 2235HANDLER_READ_FIRST 1 2236HANDLER_READ_KEY 1 2237HANDLER_READ_NEXT 9 2238HANDLER_WRITE 17 2239# 1 read_first, read_key 2240# 9 read_next 2241FLUSH STATUS; 2242SELECT * FROM t1 WHERE a = 3; 2243a b 22443 First row, p3 2245SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2246WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2247VARIABLE_NAME VARIABLE_VALUE 2248HANDLER_COMMIT 1 2249HANDLER_EXTERNAL_LOCK 2 2250HANDLER_READ_KEY 1 2251HANDLER_WRITE 17 2252# 1 read_key 2253FLUSH STATUS; 2254SELECT * FROM t1 WHERE b LIKE 'First%' ORDER BY a; 2255a b 22560 First row, p0 22571 First row, p1 22582 First row, p2 22593 First row, p3 22604 First row, p4 2261SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2262WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2263VARIABLE_NAME VARIABLE_VALUE 2264HANDLER_COMMIT 1 2265HANDLER_EXTERNAL_LOCK 2 2266HANDLER_READ_KEY 13 2267HANDLER_READ_NEXT 5 2268HANDLER_WRITE 17 2269# 13 read_key 2270# 5 read_next 2271# 2272# Test EXPLAIN SELECT 2273# 2274FLUSH STATUS; 2275EXPLAIN PARTITIONS SELECT * FROM t1; 2276id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22771 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 index NULL b 131 NULL # 100.00 Using index 2278Warnings: 2279Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2280Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` 2281SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2282WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2283VARIABLE_NAME VARIABLE_VALUE 2284HANDLER_COMMIT 1 2285HANDLER_EXTERNAL_LOCK 2 2286HANDLER_WRITE 17 2287FLUSH STATUS; 2288EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a IN (0, 1, 4) ORDER BY a; 2289id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22901 SIMPLE t1 p0,p1,p4 index PRIMARY PRIMARY 4 NULL # 25.00 Using where 2291Warnings: 2292Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2293Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,4)) order by `test`.`t1`.`a` 2294SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2295WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2296VARIABLE_NAME VARIABLE_VALUE 2297HANDLER_COMMIT 1 2298HANDLER_EXTERNAL_LOCK 2 2299HANDLER_WRITE 17 2300FLUSH STATUS; 2301EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a IN (13, 26, 39, 52); 2302id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23031 SIMPLE t1 p0 index PRIMARY b 131 NULL # 44.44 Using where; Using index 2304Warnings: 2305Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2306Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (13,26,39,52)) 2307SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2308WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2309VARIABLE_NAME VARIABLE_VALUE 2310HANDLER_COMMIT 1 2311HANDLER_EXTERNAL_LOCK 2 2312HANDLER_WRITE 17 2313FLUSH STATUS; 2314EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 3; 2315id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23161 SIMPLE t1 p3 const PRIMARY PRIMARY 4 const # 100.00 NULL 2317Warnings: 2318Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2319Note 1003 /* select#1 */ select '3' AS `a`,'First row, p3' AS `b` from `test`.`t1` where 1 2320SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2321WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2322VARIABLE_NAME VARIABLE_VALUE 2323HANDLER_COMMIT 1 2324HANDLER_EXTERNAL_LOCK 2 2325HANDLER_READ_KEY 1 2326HANDLER_WRITE 17 2327FLUSH STATUS; 2328EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b LIKE 'First%' ORDER BY a; 2329id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23301 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 range b b 131 NULL # 100.00 Using where; Using index; Using filesort 2331Warnings: 2332Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2333Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'First%') order by `test`.`t1`.`a` 2334SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2335WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2336VARIABLE_NAME VARIABLE_VALUE 2337HANDLER_COMMIT 1 2338HANDLER_EXTERNAL_LOCK 2 2339HANDLER_WRITE 17 2340# 2341# Test pruning of non static values 2342# They will need to lock all partitions, but will allow scan pruning 2343# due to a second pruning call in optimize. 2344# 2345CREATE TABLE t3 (a INT); 2346INSERT INTO t3 VALUES (1); 2347FLUSH STATUS; 2348SELECT * FROM t1 WHERE a = (SELECT a FROM t3); 2349a b 23501 First row, p1 2351SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2352WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2353VARIABLE_NAME VARIABLE_VALUE 2354HANDLER_COMMIT 1 2355HANDLER_EXTERNAL_LOCK 4 2356HANDLER_READ_FIRST 1 2357HANDLER_READ_KEY 2 2358HANDLER_READ_RND_NEXT 2 2359HANDLER_WRITE 17 2360# 1 read_first (NOTE only reads from one partition!) 2361# 2 read_key 2362# 2 read_rnd_next 2363FLUSH STATUS; 2364SELECT t1.a FROM t1 INNER JOIN t3 ON t1.a = t3.a; 2365a 23661 2367SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2368WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2369VARIABLE_NAME VARIABLE_VALUE 2370HANDLER_COMMIT 1 2371HANDLER_EXTERNAL_LOCK 4 2372HANDLER_READ_FIRST 1 2373HANDLER_READ_KEY 2 2374HANDLER_READ_RND_NEXT 2 2375HANDLER_WRITE 17 2376# 1 read_first (NOTE only reads from one partition!) 2377# 2 read_key 2378FLUSH STATUS; 2379EXPLAIN PARTITIONS SELECT t1.a, t1.b FROM t1 INNER JOIN t3 ON t1.a = t3.a; 2380id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23811 SIMPLE t3 NULL ALL NULL NULL NULL NULL # 100.00 Using where 23821 SIMPLE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 eq_ref PRIMARY PRIMARY 4 test.t3.a # 100.00 NULL 2383Warnings: 2384Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2385Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`a` = `test`.`t3`.`a`) 2386SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2387WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2388VARIABLE_NAME VARIABLE_VALUE 2389HANDLER_COMMIT 1 2390HANDLER_EXTERNAL_LOCK 4 2391HANDLER_WRITE 17 2392FLUSH STATUS; 2393EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = (SELECT a FROM t3); 2394id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23951 PRIMARY t1 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 23962 SUBQUERY t3 NULL ALL NULL NULL NULL NULL # 100.00 NULL 2397Warnings: 2398Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2399Note 1003 /* select#1 */ select '1' AS `a`,'First row, p1' AS `b` from `test`.`t1` where 1 2400SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2401WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2402VARIABLE_NAME VARIABLE_VALUE 2403HANDLER_COMMIT 1 2404HANDLER_EXTERNAL_LOCK 4 2405HANDLER_READ_FIRST 1 2406HANDLER_READ_KEY 2 2407HANDLER_READ_RND_NEXT 2 2408HANDLER_WRITE 17 2409FLUSH STATUS; 2410SELECT * FROM t1 WHERE a = 1; 2411a b 24121 First row, p1 2413SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2414WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2415VARIABLE_NAME VARIABLE_VALUE 2416HANDLER_COMMIT 1 2417HANDLER_EXTERNAL_LOCK 2 2418HANDLER_READ_KEY 1 2419HANDLER_WRITE 17 2420# 1 read_key 2421FLUSH STATUS; 2422SELECT * FROM t1 WHERE a = (SELECT COUNT(*) FROM t3); 2423a b 24241 First row, p1 2425SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2426WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2427VARIABLE_NAME VARIABLE_VALUE 2428HANDLER_COMMIT 1 2429HANDLER_EXTERNAL_LOCK 4 2430HANDLER_READ_FIRST 1 2431HANDLER_READ_KEY 2 2432HANDLER_READ_RND_NEXT 2 2433HANDLER_WRITE 17 2434# 1 read_first 2435# 2 read_key, read_rnd_next 2436# 2437# Test of non indexed partition column 2438# 2439CREATE TABLE t4 SELECT a, b FROM t1; 2440ALTER TABLE t4 PARTITION BY HASH (a) PARTITIONS 5; 2441FLUSH STATUS; 2442SELECT * FROM t4 WHERE a = (SELECT a FROM t3); 2443a b 24441 First row, p1 2445SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2446WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2447VARIABLE_NAME VARIABLE_VALUE 2448HANDLER_COMMIT 1 2449HANDLER_EXTERNAL_LOCK 4 2450HANDLER_READ_FIRST 2 2451HANDLER_READ_KEY 2 2452HANDLER_READ_RND_NEXT 5 2453HANDLER_WRITE 17 2454# 2 read_first, read_key 2455FLUSH STATUS; 2456EXPLAIN PARTITIONS SELECT * FROM t4 WHERE a = (SELECT a FROM t3); 2457id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24581 PRIMARY t4 p1 ALL NULL NULL NULL NULL # 33.33 Using where 24592 SUBQUERY t3 NULL ALL NULL NULL NULL NULL # 100.00 NULL 2460Warnings: 2461Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2462Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t4` where (`test`.`t4`.`a` = (/* select#2 */ select `test`.`t3`.`a` from `test`.`t3`)) 2463SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2464WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2465VARIABLE_NAME VARIABLE_VALUE 2466HANDLER_COMMIT 1 2467HANDLER_EXTERNAL_LOCK 4 2468HANDLER_READ_FIRST 1 2469HANDLER_READ_KEY 1 2470HANDLER_READ_RND_NEXT 2 2471HANDLER_WRITE 17 2472INSERT INTO t3 VALUES (3); 2473SELECT * FROM t4 WHERE a = (SELECT a FROM t3); 2474ERROR 21000: Subquery returns more than 1 row 2475EXPLAIN PARTITIONS SELECT * FROM t4 WHERE a = (SELECT a FROM t3); 2476ERROR 21000: Subquery returns more than 1 row 2477EXPLAIN PARTITIONS SELECT * FROM t4 WHERE a = (SELECT a FROM t3 LIMIT 1); 2478id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24791 PRIMARY t4 p1 ALL NULL NULL NULL NULL # 33.33 Using where 24802 SUBQUERY t3 NULL ALL NULL NULL NULL NULL # 100.00 NULL 2481Warnings: 2482Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2483Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t4` where (`test`.`t4`.`a` = (/* select#2 */ select `test`.`t3`.`a` from `test`.`t3` limit 1)) 2484EXPLAIN PARTITIONS SELECT * FROM t4 WHERE a = (SELECT MAX(a) FROM t3); 2485id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24861 PRIMARY t4 p3 ALL NULL NULL NULL NULL # 33.33 Using where 24872 SUBQUERY t3 NULL ALL NULL NULL NULL NULL # 100.00 NULL 2488Warnings: 2489Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2490Note 1003 /* select#1 */ select `test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t4` where (`test`.`t4`.`a` = (/* select#2 */ select max(`test`.`t3`.`a`) from `test`.`t3`)) 2491DROP TABLE t3; 2492DROP TABLE t4; 2493# 2494# Test derived tables like SELECT * FROM (SELECT * FROM ...) 2495# 2496set @optimizer_switch_saved=@@optimizer_switch; 2497set optimizer_switch='derived_merge=off'; 2498FLUSH STATUS; 2499SELECT * FROM (SELECT * FROM t1 WHERE a IN (0,2,3,13,26)) t3; 2500a b 25010 First row, p0 250213 Second row, p0 250326 Third row, p0 25042 First row, p2 25053 First row, p3 2506SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2507WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2508VARIABLE_NAME VARIABLE_VALUE 2509HANDLER_COMMIT 1 2510HANDLER_EXTERNAL_LOCK 2 2511HANDLER_READ_FIRST 3 2512HANDLER_READ_KEY 3 2513HANDLER_READ_NEXT 11 2514HANDLER_READ_RND_NEXT 6 2515HANDLER_WRITE 22 2516# 3 read_first, read_key 2517# 11 read_next 2518# 6 read_rnd_next (tmp table) 2519FLUSH STATUS; 2520SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0,2,3,13,26)) t3) t4; 2521a b 25220 First row, p0 252313 Second row, p0 252426 Third row, p0 25252 First row, p2 25263 First row, p3 2527SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2528WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2529VARIABLE_NAME VARIABLE_VALUE 2530HANDLER_COMMIT 1 2531HANDLER_EXTERNAL_LOCK 2 2532HANDLER_READ_FIRST 3 2533HANDLER_READ_KEY 3 2534HANDLER_READ_NEXT 11 2535HANDLER_READ_RND_NEXT 12 2536HANDLER_WRITE 27 2537# 3 read_first, read_key 2538# 11 read_next 2539# 12 read_rnd_next (tmp table) 2540# 2541# Test EXPLAIN SELECT * FROM (SELECT * FROM ...) 2542# 2543FLUSH STATUS; 2544EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM t1 WHERE a IN (0,2,3,13,26)) t3; 2545id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25461 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 25472 DERIVED t1 p0,p2,p3 index PRIMARY b 131 NULL # 45.45 Using where; Using index 2548Warnings: 2549Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2550Note 1003 /* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,2,3,13,26))) `t3` 2551SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2552WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2553VARIABLE_NAME VARIABLE_VALUE 2554HANDLER_COMMIT 1 2555HANDLER_EXTERNAL_LOCK 2 2556HANDLER_WRITE 17 2557FLUSH STATUS; 2558EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0,2,3,13,26)) t3) t4; 2559id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25601 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 25612 DERIVED <derived3> NULL ALL NULL NULL NULL NULL # 100.00 NULL 25623 DERIVED t1 p0,p2,p3 index PRIMARY b 131 NULL # 45.45 Using where; Using index 2563Warnings: 2564Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2565Note 1003 /* select#1 */ select `t4`.`a` AS `a`,`t4`.`b` AS `b` from (/* select#2 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,2,3,13,26))) `t3`) `t4` 2566SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2567WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2568VARIABLE_NAME VARIABLE_VALUE 2569HANDLER_COMMIT 1 2570HANDLER_EXTERNAL_LOCK 2 2571HANDLER_WRITE 17 2572# 2573# Test SELECT ... UNION SELECT ... 2574# 2575FLUSH STATUS; 2576SELECT * FROM t1 UNION SELECT * FROM t2; 2577a b 25780 First row, p0 25791 First row, p1 2580104 No duplicate 104 2581105 No duplicate 258213 Second row, p0 25832 First row, p2 258426 Third row, p0 25853 First row, p3 258639 Fourth row, p0 25874 First row, p4 25885 REPLACE second 258952 Fifth row, p0 259065 No duplicate, INSERT_DUP_KEY_UPDATE 259178 No duplicate 259291 No duplicate, INSERT_DUP_KEY_UPDATE 2593SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2594WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2595VARIABLE_NAME VARIABLE_VALUE 2596HANDLER_COMMIT 1 2597HANDLER_EXTERNAL_LOCK 4 2598HANDLER_READ_FIRST 26 2599HANDLER_READ_KEY 26 2600HANDLER_READ_NEXT 15 2601HANDLER_READ_RND_NEXT 19 2602HANDLER_WRITE 34 2603FLUSH STATUS; 2604SELECT * FROM t1 WHERE a IN (0, 1, 13, 4) UNION SELECT * FROM t2; 2605a b 26060 First row, p0 260713 Second row, p0 26081 First row, p1 26094 First row, p4 2610SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2611WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2612VARIABLE_NAME VARIABLE_VALUE 2613HANDLER_COMMIT 1 2614HANDLER_EXTERNAL_LOCK 4 2615HANDLER_READ_FIRST 16 2616HANDLER_READ_KEY 16 2617HANDLER_READ_NEXT 12 2618HANDLER_READ_RND_NEXT 8 2619HANDLER_WRITE 23 2620FLUSH STATUS; 2621SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2; 2622a b 26230 First row, p0 262413 Second row, p0 26251 First row, p1 26264 First row, p4 2627SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2628WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2629VARIABLE_NAME VARIABLE_VALUE 2630HANDLER_COMMIT 1 2631HANDLER_EXTERNAL_LOCK 4 2632HANDLER_READ_FIRST 16 2633HANDLER_READ_KEY 16 2634HANDLER_READ_NEXT 12 2635HANDLER_READ_RND_NEXT 13 2636HANDLER_WRITE 27 2637FLUSH STATUS; 2638SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4) UNION SELECT * FROM t2) t3) t4; 2639a b 26400 First row, p0 264113 Second row, p0 26421 First row, p1 26434 First row, p4 2644SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2645WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2646VARIABLE_NAME VARIABLE_VALUE 2647HANDLER_COMMIT 1 2648HANDLER_EXTERNAL_LOCK 4 2649HANDLER_READ_FIRST 16 2650HANDLER_READ_KEY 16 2651HANDLER_READ_NEXT 12 2652HANDLER_READ_RND_NEXT 18 2653HANDLER_WRITE 31 2654FLUSH STATUS; 2655SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2) t4; 2656a b 26570 First row, p0 265813 Second row, p0 26591 First row, p1 26604 First row, p4 2661SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2662WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2663VARIABLE_NAME VARIABLE_VALUE 2664HANDLER_COMMIT 1 2665HANDLER_EXTERNAL_LOCK 4 2666HANDLER_READ_FIRST 16 2667HANDLER_READ_KEY 16 2668HANDLER_READ_NEXT 12 2669HANDLER_READ_RND_NEXT 18 2670HANDLER_WRITE 31 2671FLUSH STATUS; 2672SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3) t4 UNION SELECT * FROM t2; 2673a b 26740 First row, p0 267513 Second row, p0 26761 First row, p1 26774 First row, p4 2678SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2679WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2680VARIABLE_NAME VARIABLE_VALUE 2681HANDLER_COMMIT 1 2682HANDLER_EXTERNAL_LOCK 4 2683HANDLER_READ_FIRST 16 2684HANDLER_READ_KEY 16 2685HANDLER_READ_NEXT 12 2686HANDLER_READ_RND_NEXT 18 2687HANDLER_WRITE 31 2688FLUSH STATUS; 2689SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2 WHERE a = 1) t4; 2690a b 26910 First row, p0 269213 Second row, p0 26931 First row, p1 26944 First row, p4 2695SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2696WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2697VARIABLE_NAME VARIABLE_VALUE 2698HANDLER_COMMIT 1 2699HANDLER_EXTERNAL_LOCK 4 2700HANDLER_READ_FIRST 3 2701HANDLER_READ_KEY 4 2702HANDLER_READ_NEXT 12 2703HANDLER_READ_RND_NEXT 16 2704HANDLER_WRITE 30 2705# 2706# Test EXPLAIN SELECT ... UNION SELECT ... 2707# 2708FLUSH STATUS; 2709EXPLAIN PARTITIONS SELECT * FROM t1 UNION SELECT * FROM t2; 2710id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27111 PRIMARY t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 index NULL b 131 NULL # 100.00 Using index 27122 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2713NULL UNION RESULT <union1,2> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2714Warnings: 2715Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2716Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` 2717SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2718WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2719VARIABLE_NAME VARIABLE_VALUE 2720HANDLER_COMMIT 1 2721HANDLER_EXTERNAL_LOCK 4 2722HANDLER_WRITE 17 2723FLUSH STATUS; 2724EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a IN (0, 1, 13, 4) UNION SELECT * FROM t2; 2725id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27261 PRIMARY t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 27272 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2728NULL UNION RESULT <union1,2> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2729Warnings: 2730Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2731Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4)) union /* select#2 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` 2732SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2733WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2734VARIABLE_NAME VARIABLE_VALUE 2735HANDLER_COMMIT 1 2736HANDLER_EXTERNAL_LOCK 4 2737HANDLER_WRITE 17 2738FLUSH STATUS; 2739EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2; 2740id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27411 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27422 DERIVED t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 27433 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2744NULL UNION RESULT <union1,3> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2745Warnings: 2746Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2747Note 1003 /* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4))) `t3` union /* select#3 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` 2748SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2749WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2750VARIABLE_NAME VARIABLE_VALUE 2751HANDLER_COMMIT 1 2752HANDLER_EXTERNAL_LOCK 4 2753HANDLER_WRITE 17 2754FLUSH STATUS; 2755EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4) UNION SELECT * FROM t2) t3) t4; 2756id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27571 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27582 DERIVED <derived3> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27593 DERIVED t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 27604 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2761NULL UNION RESULT <union3,4> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2762Warnings: 2763Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2764Note 1003 /* select#1 */ select `t4`.`a` AS `a`,`t4`.`b` AS `b` from (/* select#2 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4)) union /* select#4 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `t3`) `t4` 2765SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2766WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2767VARIABLE_NAME VARIABLE_VALUE 2768HANDLER_COMMIT 1 2769HANDLER_EXTERNAL_LOCK 4 2770HANDLER_WRITE 17 2771FLUSH STATUS; 2772EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2) t4; 2773id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27741 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27752 DERIVED <derived3> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27763 DERIVED t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 27774 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2778NULL UNION RESULT <union2,4> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2779Warnings: 2780Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2781Note 1003 /* select#1 */ select `t4`.`a` AS `a`,`t4`.`b` AS `b` from (/* select#2 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4))) `t3` union /* select#4 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2`) `t4` 2782SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2783WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2784VARIABLE_NAME VARIABLE_VALUE 2785HANDLER_COMMIT 1 2786HANDLER_EXTERNAL_LOCK 4 2787HANDLER_WRITE 17 2788FLUSH STATUS; 2789EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3) t4 UNION SELECT * FROM t2; 2790id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27911 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27922 DERIVED <derived3> NULL ALL NULL NULL NULL NULL # 100.00 NULL 27933 DERIVED t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 27944 UNION t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 100.00 NULL 2795NULL UNION RESULT <union1,4> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2796Warnings: 2797Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2798Note 1003 /* select#1 */ select `t4`.`a` AS `a`,`t4`.`b` AS `b` from (/* select#2 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4))) `t3`) `t4` union /* select#4 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` 2799SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2800WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2801VARIABLE_NAME VARIABLE_VALUE 2802HANDLER_COMMIT 1 2803HANDLER_EXTERNAL_LOCK 4 2804HANDLER_WRITE 17 2805FLUSH STATUS; 2806EXPLAIN PARTITIONS SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE a IN (0, 1, 13, 4)) t3 UNION SELECT * FROM t2 WHERE a = 1) t4; 2807id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28081 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL # 100.00 NULL 28092 DERIVED <derived3> NULL ALL NULL NULL NULL NULL # 100.00 NULL 28103 DERIVED t1 p0,p1,p4 index PRIMARY b 131 NULL # 33.33 Using where; Using index 28114 UNION t2 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 2812NULL UNION RESULT <union2,4> NULL ALL NULL NULL NULL NULL # NULL Using temporary 2813Warnings: 2814Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2815Note 1003 /* select#1 */ select `t4`.`a` AS `a`,`t4`.`b` AS `b` from (/* select#2 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from (/* select#3 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` in (0,1,13,4))) `t3` union /* select#4 */ select '1' AS `a`,'First row, p1' AS `b` from `test`.`t2` where 1) `t4` 2816SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2817WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2818VARIABLE_NAME VARIABLE_VALUE 2819HANDLER_COMMIT 1 2820HANDLER_EXTERNAL_LOCK 4 2821HANDLER_READ_KEY 1 2822HANDLER_WRITE 17 2823set @@optimizer_switch=@optimizer_switch_saved; 2824# 2825# Test UPDATE 2826# 2827SELECT * FROM t1 ORDER BY a; 2828a b 28290 First row, p0 28301 First row, p1 28312 First row, p2 28323 First row, p3 28334 First row, p4 28345 REPLACE second 283513 Second row, p0 283626 Third row, p0 283739 Fourth row, p0 283852 Fifth row, p0 283965 No duplicate, INSERT_DUP_KEY_UPDATE 284078 No duplicate 284191 No duplicate, INSERT_DUP_KEY_UPDATE 2842104 No duplicate 104 2843105 No duplicate 2844# This should be prunable (does not change the partitioning key) 2845FLUSH STATUS; 2846UPDATE t1 SET b = CONCAT(b, ", updated 1") WHERE a IN (13, 26, 39, 52); 2847SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2848WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2849VARIABLE_NAME VARIABLE_VALUE 2850HANDLER_COMMIT 1 2851HANDLER_EXTERNAL_LOCK 2 2852HANDLER_READ_KEY 4 2853HANDLER_UPDATE 4 2854HANDLER_WRITE 17 2855# 4 read_key 2856# 4 update 2857# 2858# This should not be prunable (only after implementing 'update pruning') 2859# i.e if all changed partitioning field is set to constant values, 2860# set lock_partitions to be a union of read_partition and the matching 2861# partition for the constants. Easy if all partitioning fields are set, 2862# probably needs a second round of prune_partitions() with these fields 2863# set to see if possible to prune locks. 2864FLUSH STATUS; 2865UPDATE t1 SET a = 99, b = CONCAT(b, ", updated 2 -> p8") WHERE a = 13; 2866SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2867WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2868VARIABLE_NAME VARIABLE_VALUE 2869HANDLER_COMMIT 1 2870HANDLER_DELETE 1 2871HANDLER_EXTERNAL_LOCK 2 2872HANDLER_READ_KEY 2 2873HANDLER_READ_RND 1 2874HANDLER_WRITE 18 2875# 2 read_key 2876# 1 read_rnd 2877# 1 delete (due to moved to another partition) 2878# 1 write 2879# 2880# This should use ha_update_row instead of ha_write_row + ha_delete_row 2881FLUSH STATUS; 2882UPDATE t1 SET a = 13 + 99, b = CONCAT(b, ", updated 3") WHERE a = 99; 2883SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2884WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2885VARIABLE_NAME VARIABLE_VALUE 2886HANDLER_COMMIT 1 2887HANDLER_EXTERNAL_LOCK 2 2888HANDLER_READ_KEY 2 2889HANDLER_READ_RND 1 2890HANDLER_UPDATE 1 2891HANDLER_WRITE 17 2892# 2 read_key 2893# 1 read_rnd 2894# 1 update 2895# 2896# This should not be prunable (only after implementing 2897# 'optimized update pruning', which will probably never happen, since 2898# it depends on which partitioning type is used (for this only hash is 2899# simple, but range and list is possible, key is very hard) 2900FLUSH STATUS; 2901UPDATE t1 SET a = a + 1, b = CONCAT(b, ", updated 4 -> p9") WHERE a = 112; 2902SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2903WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2904VARIABLE_NAME VARIABLE_VALUE 2905HANDLER_COMMIT 1 2906HANDLER_DELETE 1 2907HANDLER_EXTERNAL_LOCK 2 2908HANDLER_READ_KEY 2 2909HANDLER_READ_RND 1 2910HANDLER_WRITE 18 2911# 2 read_key 2912# 1 read_rnd 2913# 1 delete (due to moved to another partition) 2914# 1 write 2915FLUSH STATUS; 2916UPDATE t1 SET b = CONCAT(b, ", same as min(a) + 2 in t2") WHERE a = (SELECT MIN(a) + 2 FROM t2); 2917SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2918WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2919VARIABLE_NAME VARIABLE_VALUE 2920HANDLER_COMMIT 1 2921HANDLER_EXTERNAL_LOCK 4 2922HANDLER_READ_FIRST 13 2923HANDLER_READ_KEY 14 2924HANDLER_UPDATE 1 2925HANDLER_WRITE 17 2926FLUSH STATUS; 2927UPDATE t1 SET b = CONCAT(b, ", max(a) in t2: ", (SELECT MAX(a) FROM t2)) WHERE a = 5; 2928SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2929WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2930VARIABLE_NAME VARIABLE_VALUE 2931HANDLER_COMMIT 1 2932HANDLER_EXTERNAL_LOCK 4 2933HANDLER_READ_KEY 14 2934HANDLER_READ_LAST 13 2935HANDLER_UPDATE 1 2936HANDLER_WRITE 17 2937# 2938# Test multi table UPDATE 2939# 2940SELECT * FROM t1 ORDER BY a; 2941a b 29420 First row, p0 29431 First row, p1 29442 First row, p2 29453 First row, p3, same as min(a) + 2 in t2 29464 First row, p4 29475 REPLACE second, max(a) in t2: 4 294826 Third row, p0, updated 1 294939 Fourth row, p0, updated 1 295052 Fifth row, p0, updated 1 295165 No duplicate, INSERT_DUP_KEY_UPDATE 295278 No duplicate 295391 No duplicate, INSERT_DUP_KEY_UPDATE 2954104 No duplicate 104 2955105 No duplicate 2956113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 2957SELECT * FROM t2 ORDER BY a; 2958a b 29591 First row, p1 29604 First row, p4 2961FLUSH STATUS; 2962EXPLAIN PARTITIONS UPDATE t1, t2 2963SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b), 2964t2.b = CONCAT(t2.b, ", t1.b:", t1.b) 2965WHERE t2.b = t1.b and t2.a = 4; 2966id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29671 UPDATE t2 p4 const PRIMARY PRIMARY 4 const # 100.00 NULL 29681 UPDATE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref b b 131 const # 100.00 NULL 2969Warnings: 2970Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2971SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2972WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2973VARIABLE_NAME VARIABLE_VALUE 2974HANDLER_COMMIT 1 2975HANDLER_EXTERNAL_LOCK 4 2976HANDLER_READ_KEY 1 2977HANDLER_WRITE 17 2978FLUSH STATUS; 2979EXPLAIN PARTITIONS UPDATE t1, t2 2980SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b), 2981t2.b = CONCAT(t2.b, ", t1.b:", t1.b) 2982WHERE t2.b = t1.b and t2.a = 4; 2983id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29841 UPDATE t2 p4 const PRIMARY PRIMARY 4 const # 100.00 NULL 29851 UPDATE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref b b 131 const # 100.00 NULL 2986Warnings: 2987Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 2988SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 2989WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 2990VARIABLE_NAME VARIABLE_VALUE 2991HANDLER_COMMIT 1 2992HANDLER_EXTERNAL_LOCK 4 2993HANDLER_READ_KEY 1 2994HANDLER_WRITE 17 2995FLUSH STATUS; 2996UPDATE t1, t2 2997SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b), 2998t2.b = CONCAT(t2.b, ", t1.b:", t1.b) 2999WHERE t2.b = t1.b and t2.a = 4; 3000SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3001WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3002VARIABLE_NAME VARIABLE_VALUE 3003HANDLER_COMMIT 1 3004HANDLER_EXTERNAL_LOCK 4 3005HANDLER_READ_KEY 15 3006HANDLER_READ_NEXT 1 3007HANDLER_READ_RND 1 3008HANDLER_READ_RND_NEXT 2 3009HANDLER_UPDATE 2 3010HANDLER_WRITE 18 3011# 15 read_key 3012# 1 read_next, read_rnd 3013# 2 read_rnd_next 3014# 2 update 3015# 3016# Test of views 3017# 3018FLUSH STATUS; 3019CREATE VIEW v1_25 AS SELECT a, b FROM t1 PARTITION (p2, p5); 3020SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3021WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3022VARIABLE_NAME VARIABLE_VALUE 3023HANDLER_WRITE 17 3024# No locks! 3025FLUSH STATUS; 3026CREATE VIEW v1_25_check AS SELECT a, b FROM t1 PARTITION (p2, p5) t1_alias WITH CHECK OPTION; 3027SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3028WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3029VARIABLE_NAME VARIABLE_VALUE 3030HANDLER_WRITE 17 3031# No locks! 3032FLUSH STATUS; 3033CREATE VIEW v1_9 AS SELECT a, b FROM t1 WHERE a = 9; 3034SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3035WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3036VARIABLE_NAME VARIABLE_VALUE 3037HANDLER_WRITE 17 3038# No locks! 3039FLUSH STATUS; 3040CREATE VIEW v1_9_check AS SELECT a, b FROM t1 WHERE a = 9 WITH CHECK OPTION; 3041SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3042WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3043VARIABLE_NAME VARIABLE_VALUE 3044HANDLER_WRITE 17 3045# No locks! 3046FLUSH STATUS; 3047CREATE VIEW v1_all AS SELECT a, b FROM t1; 3048SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3049WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3050VARIABLE_NAME VARIABLE_VALUE 3051HANDLER_WRITE 17 3052# No locks! 3053SELECT TABLE_NAME, CHECK_OPTION, IS_UPDATABLE, VIEW_DEFINITION 3054FROM INFORMATION_SCHEMA.VIEWS 3055WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 'v1_%'; 3056TABLE_NAME CHECK_OPTION IS_UPDATABLE VIEW_DEFINITION 3057v1_25 NONE YES select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` PARTITION (`p2`,`p5`) 3058v1_25_check CASCADED YES select `t1_alias`.`a` AS `a`,`t1_alias`.`b` AS `b` from `test`.`t1` PARTITION (`p2`,`p5`) `t1_alias` 3059v1_9 NONE YES select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 9) 3060v1_9_check CASCADED YES select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 9) 3061v1_all NONE YES select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` 3062FLUSH STATUS; 3063INSERT INTO v1_all VALUES (23, "Insert in v1_all"); 3064SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3065WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3066VARIABLE_NAME VARIABLE_VALUE 3067HANDLER_COMMIT 1 3068HANDLER_EXTERNAL_LOCK 2 3069HANDLER_WRITE 18 3070FLUSH STATUS; 3071INSERT INTO v1_25 VALUES (18, "Insert in v1_25"); 3072SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3073WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3074VARIABLE_NAME VARIABLE_VALUE 3075HANDLER_COMMIT 1 3076HANDLER_EXTERNAL_LOCK 2 3077HANDLER_WRITE 18 3078FLUSH STATUS; 3079INSERT INTO v1_25 VALUES (17, "Insert in v1_25 fail"); 3080ERROR HY000: Found a row not matching the given partition set 3081SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3082WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3083VARIABLE_NAME VARIABLE_VALUE 3084HANDLER_EXTERNAL_LOCK 2 3085HANDLER_WRITE 17 3086FLUSH STATUS; 3087INSERT IGNORE INTO v1_25 VALUES (17, "Insert ignore in v1_25"); 3088Warnings: 3089Warning 1748 Found a row not matching the given partition set 3090SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3091WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3092VARIABLE_NAME VARIABLE_VALUE 3093HANDLER_EXTERNAL_LOCK 2 3094HANDLER_WRITE 17 3095FLUSH STATUS; 3096INSERT INTO v1_25_check VALUES (31, "Insert in v1_25_check"); 3097SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3098WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3099VARIABLE_NAME VARIABLE_VALUE 3100HANDLER_COMMIT 1 3101HANDLER_EXTERNAL_LOCK 2 3102HANDLER_WRITE 18 3103FLUSH STATUS; 3104INSERT INTO v1_25_check VALUES (30, "Insert in v1_25_check fail"); 3105ERROR HY000: Found a row not matching the given partition set 3106SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3107WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3108VARIABLE_NAME VARIABLE_VALUE 3109HANDLER_EXTERNAL_LOCK 2 3110HANDLER_WRITE 17 3111FLUSH STATUS; 3112INSERT IGNORE INTO v1_25_check VALUES (30, "Insert ignore in v1_25_check"); 3113Warnings: 3114Warning 1748 Found a row not matching the given partition set 3115SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3116WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3117VARIABLE_NAME VARIABLE_VALUE 3118HANDLER_EXTERNAL_LOCK 2 3119HANDLER_WRITE 17 3120FLUSH STATUS; 3121INSERT INTO v1_9 VALUES (9, "Insert in v1_9"); 3122SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3123WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3124VARIABLE_NAME VARIABLE_VALUE 3125HANDLER_COMMIT 1 3126HANDLER_EXTERNAL_LOCK 2 3127HANDLER_WRITE 18 3128FLUSH STATUS; 3129INSERT INTO v1_9 VALUES (8, "Insert in v1_9 NO CHECK!"); 3130SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3131WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3132VARIABLE_NAME VARIABLE_VALUE 3133HANDLER_COMMIT 1 3134HANDLER_EXTERNAL_LOCK 2 3135HANDLER_WRITE 18 3136SELECT * FROM t1 WHERE a = 8; 3137a b 31388 Insert in v1_9 NO CHECK! 3139# DELETE will not find row not in view 3140FLUSH STATUS; 3141DELETE FROM v1_9_check WHERE a = 8; 3142SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3143WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3144VARIABLE_NAME VARIABLE_VALUE 3145HANDLER_WRITE 17 3146# 0 locks, impossible where! 3147EXPLAIN PARTITIONS DELETE FROM v1_9_check WHERE a = 8; 3148id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31491 DELETE NULL NULL NULL NULL NULL NULL NULL # NULL No matching rows after partition pruning 3150Warnings: 3151Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3152EXPLAIN PARTITIONS SELECT * FROM v1_9_check WHERE a = 8; 3153id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31541 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 3155Warnings: 3156Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3157Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0 3158SELECT * FROM t1 WHERE a = 8; 3159a b 31608 Insert in v1_9 NO CHECK! 3161FLUSH STATUS; 3162INSERT INTO v1_9_check VALUES (10, "Insert in v1_9_check fail"); 3163ERROR HY000: CHECK OPTION failed 'test.v1_9_check' 3164SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3165WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3166VARIABLE_NAME VARIABLE_VALUE 3167HANDLER_EXTERNAL_LOCK 2 3168HANDLER_ROLLBACK 1 3169HANDLER_WRITE 17 3170SELECT * FROM t1 WHERE a = 9; 3171a b 31729 Insert in v1_9 3173FLUSH STATUS; 3174DELETE FROM v1_9_check WHERE a = 9; 3175SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3176WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3177VARIABLE_NAME VARIABLE_VALUE 3178HANDLER_COMMIT 1 3179HANDLER_DELETE 1 3180HANDLER_EXTERNAL_LOCK 2 3181HANDLER_READ_KEY 1 3182HANDLER_WRITE 17 3183FLUSH STATUS; 3184INSERT INTO v1_9_check VALUES (9, "Insert in v1_9_check"); 3185SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3186WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3187VARIABLE_NAME VARIABLE_VALUE 3188HANDLER_COMMIT 1 3189HANDLER_EXTERNAL_LOCK 2 3190HANDLER_WRITE 18 3191FLUSH STATUS; 3192SELECT * FROM v1_9; 3193a b 31949 Insert in v1_9_check 3195SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3196WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3197VARIABLE_NAME VARIABLE_VALUE 3198HANDLER_COMMIT 1 3199HANDLER_EXTERNAL_LOCK 2 3200HANDLER_READ_KEY 1 3201HANDLER_WRITE 17 3202FLUSH STATUS; 3203SELECT * FROM v1_25; 3204a b 320518 Insert in v1_25 32062 First row, p2 320731 Insert in v1_25_check 32085 REPLACE second, max(a) in t2: 4 3209SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3210WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3211VARIABLE_NAME VARIABLE_VALUE 3212HANDLER_COMMIT 1 3213HANDLER_EXTERNAL_LOCK 2 3214HANDLER_READ_FIRST 2 3215HANDLER_READ_KEY 2 3216HANDLER_READ_NEXT 4 3217HANDLER_WRITE 17 3218FLUSH STATUS; 3219SELECT * FROM v1_all; 3220a b 32210 First row, p0 32221 First row, p1 3223104 No duplicate 104 3224105 No duplicate 3225113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 322618 Insert in v1_25 32272 First row, p2 322823 Insert in v1_all 322926 Third row, p0, updated 1 32303 First row, p3, same as min(a) + 2 in t2 323131 Insert in v1_25_check 323239 Fourth row, p0, updated 1 32334 First row, p4, t2.b:First row, p4 32345 REPLACE second, max(a) in t2: 4 323552 Fifth row, p0, updated 1 323665 No duplicate, INSERT_DUP_KEY_UPDATE 323778 No duplicate 32388 Insert in v1_9 NO CHECK! 32399 Insert in v1_9_check 324091 No duplicate, INSERT_DUP_KEY_UPDATE 3241SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3242WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3243VARIABLE_NAME VARIABLE_VALUE 3244HANDLER_COMMIT 1 3245HANDLER_EXTERNAL_LOCK 2 3246HANDLER_READ_FIRST 13 3247HANDLER_READ_KEY 13 3248HANDLER_READ_NEXT 20 3249HANDLER_WRITE 17 3250DROP VIEW v1_all; 3251DROP VIEW v1_9, v1_9_check; 3252DROP VIEW v1_25, v1_25_check; 3253# 3254# Test CREATE SELECT 3255# 3256FLUSH STATUS; 3257CREATE TABLE t3 SELECT a, b FROM t1 WHERE a IN (0, 1, 13, 113); 3258SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3259WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3260VARIABLE_NAME VARIABLE_VALUE 3261HANDLER_COMMIT 1 3262HANDLER_EXTERNAL_LOCK 4 3263HANDLER_READ_FIRST 3 3264HANDLER_READ_KEY 3 3265HANDLER_READ_NEXT 12 3266HANDLER_WRITE 20 3267SELECT * FROM t3 ORDER BY a; 3268a b 32690 First row, p0 32701 First row, p1 3271113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 3272DROP TABLE t3; 3273FLUSH STATUS; 3274CREATE TABLE t3 SELECT a, b FROM t1 WHERE b LIKE 'First%'; 3275SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3276WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3277VARIABLE_NAME VARIABLE_VALUE 3278HANDLER_COMMIT 1 3279HANDLER_EXTERNAL_LOCK 4 3280HANDLER_READ_KEY 13 3281HANDLER_READ_NEXT 5 3282HANDLER_WRITE 22 3283SELECT * FROM t3 ORDER BY a; 3284a b 32850 First row, p0 32861 First row, p1 32872 First row, p2 32883 First row, p3, same as min(a) + 2 in t2 32894 First row, p4, t2.b:First row, p4 3290DROP TABLE t3; 3291# 3292# Test Stored procedures 3293# 3294CREATE PROCEDURE sp_insert(a INT, b CHAR(16)) 3295INSERT INTO test.t1 VALUES (a, b); 3296CREATE PROCEDURE sp_insert_partition(p CHAR(16), a INT, b CHAR(16)) 3297BEGIN 3298SET @str = CONCAT("INSERT INTO test.t1 PARTITION(", p, ") VALUES (?, ?)"); 3299SET @x = a, @y = b; 3300PREPARE stmt FROM @str; 3301EXECUTE stmt USING @x, @y; 3302DEALLOCATE PREPARE stmt; 3303END| 3304CREATE PROCEDURE sp_select_all() 3305SELECT * FROM test.t1; 3306CREATE PROCEDURE sp_select_exact(x INT) 3307SELECT * FROM test.t1 WHERE a = x; 3308CREATE PROCEDURE sp_select_partition(p CHAR(16)) 3309BEGIN 3310SET @str = CONCAT("SELECT * FROM test.t1 PARTITION(", p, ")"); 3311PREPARE stmt FROM @str; 3312EXECUTE stmt; 3313DEALLOCATE PREPARE stmt; 3314END| 3315CREATE PROCEDURE sp_select_range(x INT, y INT) 3316SELECT * FROM test.t1 WHERE a between x and y; 3317FLUSH STATUS; 3318CALL sp_insert(313,"Test313"); 3319SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3320WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3321VARIABLE_NAME VARIABLE_VALUE 3322HANDLER_COMMIT 1 3323HANDLER_EXTERNAL_LOCK 4 3324HANDLER_READ_KEY 1 3325HANDLER_WRITE 18 3326FLUSH STATUS; 3327CALL sp_insert_partition("p7", 98, "Test98"); 3328SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3329WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3330VARIABLE_NAME VARIABLE_VALUE 3331HANDLER_COMMIT 1 3332HANDLER_EXTERNAL_LOCK 4 3333HANDLER_READ_KEY 1 3334HANDLER_WRITE 18 3335FLUSH STATUS; 3336CALL sp_insert_partition("p8", 111, "Test111"); 3337ERROR HY000: Found a row not matching the given partition set 3338SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3339WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3340VARIABLE_NAME VARIABLE_VALUE 3341HANDLER_EXTERNAL_LOCK 2 3342HANDLER_WRITE 17 3343# no proc locking since already in proc cache. 3344FLUSH STATUS; 3345CALL sp_insert_partition("p7,p8", 111, "Test111"); 3346SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3347WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3348VARIABLE_NAME VARIABLE_VALUE 3349HANDLER_COMMIT 1 3350HANDLER_EXTERNAL_LOCK 2 3351HANDLER_WRITE 18 3352FLUSH STATUS; 3353CALL sp_select_all(); 3354a b 33550 First row, p0 33561 First row, p1 3357104 No duplicate 104 3358105 No duplicate 3359111 Test111 3360113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 336118 Insert in v1_25 33622 First row, p2 336323 Insert in v1_all 336426 Third row, p0, updated 1 33653 First row, p3, same as min(a) + 2 in t2 336631 Insert in v1_25_check 3367313 Test313 336839 Fourth row, p0, updated 1 33694 First row, p4, t2.b:First row, p4 33705 REPLACE second, max(a) in t2: 4 337152 Fifth row, p0, updated 1 337265 No duplicate, INSERT_DUP_KEY_UPDATE 337378 No duplicate 33748 Insert in v1_9 NO CHECK! 33759 Insert in v1_9_check 337691 No duplicate, INSERT_DUP_KEY_UPDATE 337798 Test98 3378SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3379WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3380VARIABLE_NAME VARIABLE_VALUE 3381HANDLER_COMMIT 1 3382HANDLER_EXTERNAL_LOCK 4 3383HANDLER_READ_FIRST 13 3384HANDLER_READ_KEY 14 3385HANDLER_READ_NEXT 23 3386HANDLER_WRITE 17 3387FLUSH STATUS; 3388CALL sp_select_exact(98); 3389a b 339098 Test98 3391SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3392WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3393VARIABLE_NAME VARIABLE_VALUE 3394HANDLER_COMMIT 1 3395HANDLER_EXTERNAL_LOCK 4 3396HANDLER_READ_KEY 2 3397HANDLER_WRITE 17 3398FLUSH STATUS; 3399CALL sp_select_partition("p7"); 3400a b 3401111 Test111 340298 Test98 3403SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3404WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3405VARIABLE_NAME VARIABLE_VALUE 3406HANDLER_COMMIT 1 3407HANDLER_EXTERNAL_LOCK 4 3408HANDLER_READ_FIRST 1 3409HANDLER_READ_KEY 2 3410HANDLER_READ_NEXT 2 3411HANDLER_WRITE 17 3412FLUSH STATUS; 3413CALL sp_select_partition("p8"); 3414a b 34158 Insert in v1_9 NO CHECK! 3416SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3417WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3418VARIABLE_NAME VARIABLE_VALUE 3419HANDLER_COMMIT 1 3420HANDLER_EXTERNAL_LOCK 2 3421HANDLER_READ_FIRST 1 3422HANDLER_READ_KEY 1 3423HANDLER_READ_NEXT 1 3424HANDLER_WRITE 17 3425# no proc locking since already in proc cache. 3426FLUSH STATUS; 3427CALL sp_select_partition("p7,p8"); 3428a b 3429111 Test111 34308 Insert in v1_9 NO CHECK! 343198 Test98 3432SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3433WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3434VARIABLE_NAME VARIABLE_VALUE 3435HANDLER_COMMIT 1 3436HANDLER_EXTERNAL_LOCK 2 3437HANDLER_READ_FIRST 2 3438HANDLER_READ_KEY 2 3439HANDLER_READ_NEXT 3 3440HANDLER_WRITE 17 3441FLUSH STATUS; 3442CALL sp_select_range(1,5); 3443a b 34441 First row, p1 34452 First row, p2 34463 First row, p3, same as min(a) + 2 in t2 34474 First row, p4, t2.b:First row, p4 34485 REPLACE second, max(a) in t2: 4 3449SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3450WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3451VARIABLE_NAME VARIABLE_VALUE 3452HANDLER_COMMIT 1 3453HANDLER_EXTERNAL_LOCK 4 3454HANDLER_READ_KEY 6 3455HANDLER_READ_NEXT 5 3456HANDLER_WRITE 17 3457DROP PROCEDURE sp_insert; 3458DROP PROCEDURE sp_insert_partition; 3459DROP PROCEDURE sp_select_all; 3460DROP PROCEDURE sp_select_partition; 3461DROP PROCEDURE sp_select_range; 3462DROP PROCEDURE sp_select_exact; 3463# 3464# Test EXPLAIN DELETE 3465# 3466SELECT * FROM t1 ORDER BY a; 3467a b 34680 First row, p0 34691 First row, p1 34702 First row, p2 34713 First row, p3, same as min(a) + 2 in t2 34724 First row, p4, t2.b:First row, p4 34735 REPLACE second, max(a) in t2: 4 34748 Insert in v1_9 NO CHECK! 34759 Insert in v1_9_check 347618 Insert in v1_25 347723 Insert in v1_all 347826 Third row, p0, updated 1 347931 Insert in v1_25_check 348039 Fourth row, p0, updated 1 348152 Fifth row, p0, updated 1 348265 No duplicate, INSERT_DUP_KEY_UPDATE 348378 No duplicate 348491 No duplicate, INSERT_DUP_KEY_UPDATE 348598 Test98 3486104 No duplicate 104 3487105 No duplicate 3488111 Test111 3489113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 3490313 Test313 3491FLUSH STATUS; 3492EXPLAIN PARTITIONS DELETE FROM t1 WHERE a = 105; 3493id select_type table partitions type possible_keys key key_len ref rows filtered Extra 34941 DELETE t1 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 3495Warnings: 3496Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3497SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3498WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3499VARIABLE_NAME VARIABLE_VALUE 3500HANDLER_COMMIT 1 3501HANDLER_EXTERNAL_LOCK 2 3502HANDLER_WRITE 17 3503FLUSH STATUS; 3504EXPLAIN PARTITIONS DELETE FROM t1 WHERE b = "No duplicate"; 3505id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35061 DELETE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 range b b 131 const # 100.00 Using where 3507Warnings: 3508Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3509SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3510WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3511VARIABLE_NAME VARIABLE_VALUE 3512HANDLER_COMMIT 1 3513HANDLER_EXTERNAL_LOCK 2 3514HANDLER_WRITE 17 3515FLUSH STATUS; 3516EXPLAIN PARTITIONS DELETE FROM t1 WHERE a = 105; 3517id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35181 DELETE t1 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 3519Warnings: 3520Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3521SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3522WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3523VARIABLE_NAME VARIABLE_VALUE 3524HANDLER_COMMIT 1 3525HANDLER_EXTERNAL_LOCK 2 3526HANDLER_WRITE 17 3527FLUSH STATUS; 3528EXPLAIN PARTITIONS DELETE FROM t1 WHERE b = "No duplicate"; 3529id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35301 DELETE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 range b b 131 const # 100.00 Using where 3531Warnings: 3532Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3533SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3534WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3535VARIABLE_NAME VARIABLE_VALUE 3536HANDLER_COMMIT 1 3537HANDLER_EXTERNAL_LOCK 2 3538HANDLER_WRITE 17 3539# 3540# Test DELETE 3541# 3542FLUSH STATUS; 3543DELETE FROM t1 WHERE a = 105; 3544SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3545WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3546VARIABLE_NAME VARIABLE_VALUE 3547HANDLER_COMMIT 1 3548HANDLER_DELETE 1 3549HANDLER_EXTERNAL_LOCK 2 3550HANDLER_READ_KEY 1 3551HANDLER_WRITE 17 3552# 1 read_key 3553# 1 delete 3554FLUSH STATUS; 3555DELETE FROM t1 WHERE b = "No duplicate"; 3556SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3557WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3558VARIABLE_NAME VARIABLE_VALUE 3559HANDLER_COMMIT 1 3560HANDLER_DELETE 1 3561HANDLER_EXTERNAL_LOCK 2 3562HANDLER_READ_KEY 13 3563HANDLER_READ_NEXT 1 3564HANDLER_WRITE 17 3565# 13 read_key 3566# 1 read_next (if more matches after the first match) 3567# 1 delete 3568FLUSH STATUS; 3569DELETE FROM t1 WHERE a = (SELECT a + 90 FROM t2 WHERE a = 1); 3570SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3571WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3572VARIABLE_NAME VARIABLE_VALUE 3573HANDLER_COMMIT 1 3574HANDLER_DELETE 1 3575HANDLER_EXTERNAL_LOCK 4 3576HANDLER_READ_KEY 2 3577HANDLER_WRITE 17 3578# 2 read_key 3579# 2 read_next (if more matches after the first match) 3580# 1 delete 3581EXPLAIN PARTITIONS DELETE FROM t1 WHERE a = (SELECT a + 90 FROM t2 WHERE a = 1); 3582id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35831 DELETE t1 p0 range PRIMARY PRIMARY 4 const # 100.00 Using where 35842 SUBQUERY t2 p1 const PRIMARY PRIMARY 4 const # 100.00 Using index 3585Warnings: 3586Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3587FLUSH STATUS; 3588DELETE FROM t1 PARTITION (p0) 3589WHERE a = (SELECT a + 2 FROM t2 WHERE a = 1); 3590SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3591WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3592VARIABLE_NAME VARIABLE_VALUE 3593HANDLER_COMMIT 1 3594HANDLER_EXTERNAL_LOCK 4 3595HANDLER_READ_KEY 1 3596HANDLER_WRITE 17 3597# Impossible delete, all partitions pruned away after locking! 3598# 1 read_key 3599EXPLAIN PARTITIONS DELETE FROM t1 PARTITION (p0) 3600WHERE a = (SELECT a + 2 FROM t2 WHERE a = 1); 3601id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36021 DELETE NULL NULL NULL NULL NULL NULL NULL # NULL No matching rows after partition pruning 36032 SUBQUERY t2 p1 const PRIMARY PRIMARY 4 const # 100.00 Using index 3604Warnings: 3605Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3606# 3607# Test multi table DELETE 3608# 3609SELECT * FROM t1 ORDER BY a; 3610a b 36110 First row, p0 36121 First row, p1 36132 First row, p2 36143 First row, p3, same as min(a) + 2 in t2 36154 First row, p4, t2.b:First row, p4 36165 REPLACE second, max(a) in t2: 4 36178 Insert in v1_9 NO CHECK! 36189 Insert in v1_9_check 361918 Insert in v1_25 362023 Insert in v1_all 362126 Third row, p0, updated 1 362231 Insert in v1_25_check 362339 Fourth row, p0, updated 1 362452 Fifth row, p0, updated 1 362565 No duplicate, INSERT_DUP_KEY_UPDATE 362698 Test98 3627104 No duplicate 104 3628111 Test111 3629113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 3630313 Test313 3631SELECT * FROM t2 ORDER BY a; 3632a b 36331 First row, p1 36344 First row, p4, t1.b:First row, p4 3635FLUSH STATUS; 3636EXPLAIN PARTITIONS DELETE t1, t2 FROM t1, t2 3637WHERE t1.a = t2.a AND t1.b = 'First row, p1'; 3638id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36391 DELETE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref PRIMARY,b b 131 const # 100.00 NULL 36401 DELETE t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 3641Warnings: 3642Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3643SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3644WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3645VARIABLE_NAME VARIABLE_VALUE 3646HANDLER_COMMIT 1 3647HANDLER_EXTERNAL_LOCK 4 3648HANDLER_WRITE 17 3649FLUSH STATUS; 3650EXPLAIN PARTITIONS DELETE FROM t2, t1 USING t2, t1 3651WHERE t1.b = t2.b AND t2.a = 4; 3652id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36531 DELETE t2 p4 const PRIMARY PRIMARY 4 const # 100.00 NULL 36541 DELETE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref b b 131 const # 100.00 NULL 3655Warnings: 3656Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3657SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3658WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3659VARIABLE_NAME VARIABLE_VALUE 3660HANDLER_COMMIT 1 3661HANDLER_EXTERNAL_LOCK 4 3662HANDLER_READ_KEY 1 3663HANDLER_WRITE 17 3664FLUSH STATUS; 3665DELETE t1, t2 FROM t1, t2 3666WHERE t1.a = t2.a AND t1.b = 'First row, p1'; 3667SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3668WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3669VARIABLE_NAME VARIABLE_VALUE 3670HANDLER_COMMIT 1 3671HANDLER_DELETE 2 3672HANDLER_EXTERNAL_LOCK 4 3673HANDLER_READ_KEY 15 3674HANDLER_READ_NEXT 1 3675HANDLER_READ_RND 1 3676HANDLER_WRITE 17 3677# 15 read_key 3678# 2 delete 3679FLUSH STATUS; 3680DELETE FROM t2, t1 USING t2, t1 3681WHERE t1.b = t2.b AND t2.a = 4; 3682SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3683WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3684VARIABLE_NAME VARIABLE_VALUE 3685HANDLER_COMMIT 1 3686HANDLER_EXTERNAL_LOCK 4 3687HANDLER_READ_KEY 14 3688HANDLER_WRITE 17 3689SELECT * FROM t1 ORDER BY a; 3690a b 36910 First row, p0 36922 First row, p2 36933 First row, p3, same as min(a) + 2 in t2 36944 First row, p4, t2.b:First row, p4 36955 REPLACE second, max(a) in t2: 4 36968 Insert in v1_9 NO CHECK! 36979 Insert in v1_9_check 369818 Insert in v1_25 369923 Insert in v1_all 370026 Third row, p0, updated 1 370131 Insert in v1_25_check 370239 Fourth row, p0, updated 1 370352 Fifth row, p0, updated 1 370465 No duplicate, INSERT_DUP_KEY_UPDATE 370598 Test98 3706104 No duplicate 104 3707111 Test111 3708113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 3709313 Test313 3710SELECT * FROM t2 ORDER BY a; 3711a b 37124 First row, p4, t1.b:First row, p4 3713# 3714# Test subquery IN expression 3715# 3716FLUSH STATUS; 3717EXPLAIN PARTITIONS SELECT count(*) FROM t1 p 3718WHERE a IN (1, 2, 9); 3719id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37201 SIMPLE p p1,p2,p9 index PRIMARY b 131 NULL 4 75.00 Using where; Using index 3721Warnings: 3722Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3723Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t1` `p` where (`test`.`p`.`a` in (1,2,9)) 3724SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3725WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3726VARIABLE_NAME VARIABLE_VALUE 3727HANDLER_COMMIT 1 3728HANDLER_EXTERNAL_LOCK 2 3729HANDLER_WRITE 17 3730FLUSH STATUS; 3731EXPLAIN PARTITIONS SELECT count(*) FROM t1 p 3732WHERE a IN 3733(SELECT a + 1 FROM t2 WHERE a = 4); 3734id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37351 SIMPLE p p5 const PRIMARY PRIMARY 4 const 1 100.00 Using index 37361 SIMPLE t2 p4 const PRIMARY PRIMARY 4 const 1 100.00 Using index 3737Warnings: 3738Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3739Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t2` join `test`.`t1` `p` where (('5' = 5)) 3740SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3741WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3742VARIABLE_NAME VARIABLE_VALUE 3743HANDLER_COMMIT 1 3744HANDLER_EXTERNAL_LOCK 4 3745HANDLER_READ_KEY 2 3746HANDLER_WRITE 17 3747# 3748# Test triggers 3749# Tables used in triggers cannot be pruned for locks. 3750# Tables with triggers cannot be pruned for locks if 3751# BEFORE INSERT/UPDATE trigger uses any partitioning columns. 3752# 3753CREATE TABLE t3 3754(old_a int, 3755new_a int, 3756old_b varchar(255), 3757new_b varchar(255), 3758key (new_a, new_b), 3759key(new_b)) 3760PARTITION BY HASH (new_a) PARTITIONS 5; 3761CREATE TRIGGER t1_after_insert AFTER INSERT 3762ON t1 FOR EACH ROW 3763INSERT INTO t3 VALUES (2, NEW.a, NULL, CONCAT("AI: ", NEW.b)); 3764CREATE TRIGGER t1_after_update AFTER UPDATE 3765ON t1 FOR EACH ROW 3766INSERT INTO t3 VALUES (OLD.a, NEW.a, CONCAT("AU: ", OLD.b), CONCAT("AU: ", NEW.b)); 3767FLUSH STATUS; 3768INSERT INTO t1 VALUES (2, "First row, p2") 3769ON DUPLICATE KEY UPDATE b = CONCAT(b, ", duplicate key 2"); 3770SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3771WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3772VARIABLE_NAME VARIABLE_VALUE 3773HANDLER_COMMIT 1 3774HANDLER_EXTERNAL_LOCK 6 3775HANDLER_READ_KEY 1 3776HANDLER_UPDATE 1 3777HANDLER_WRITE 19 3778# (t1 to insert, t3 after insert trigger, t3 after update trigger) 3779SELECT * FROM t1 WHERE a = 2; 3780a b 37812 First row, p2, duplicate key 2 3782FLUSH STATUS; 3783REPLACE INTO t1 VALUES (0, "First row, p0 REPLACED"); 3784SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3785WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3786VARIABLE_NAME VARIABLE_VALUE 3787HANDLER_COMMIT 1 3788HANDLER_EXTERNAL_LOCK 4 3789HANDLER_READ_KEY 1 3790HANDLER_UPDATE 1 3791HANDLER_WRITE 19 3792# (t1 to replace, t3 after insert trigger) 3793# Note that since there is no delete trigger, REPLACE cheats by 3794# doing update instead of delete+insert! 3795SELECT * FROM t1 WHERE a = 0; 3796a b 37970 First row, p0 REPLACED 3798FLUSH STATUS; 3799EXPLAIN PARTITIONS UPDATE t1 SET b = CONCAT(b, ", UPDATED2") WHERE a = 3; 3800id select_type table partitions type possible_keys key key_len ref rows filtered Extra 38011 UPDATE t1 p3 range PRIMARY PRIMARY 4 const # 100.00 Using where 3802Warnings: 3803Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3804SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3805WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3806VARIABLE_NAME VARIABLE_VALUE 3807HANDLER_COMMIT 1 3808HANDLER_EXTERNAL_LOCK 4 3809HANDLER_WRITE 17 3810# (t1 to insert, t3 after update trigger) 3811CREATE TRIGGER t1_after_delete AFTER DELETE 3812ON t1 FOR EACH ROW 3813INSERT INTO t3 VALUES (OLD.a, NULL, CONCAT("AD: ", OLD.b), NULL); 3814FLUSH STATUS; 3815REPLACE INTO t1 VALUES (0, "First row, p0 REPLACED2"); 3816SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3817WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3818VARIABLE_NAME VARIABLE_VALUE 3819HANDLER_COMMIT 1 3820HANDLER_DELETE 1 3821HANDLER_EXTERNAL_LOCK 6 3822HANDLER_READ_KEY 1 3823HANDLER_WRITE 21 3824# (t1 to replace, t3 after insert trigger, t3 after delete trigger) 3825# Note that now it does delete+insert instead, due to delete trigger! 3826SELECT * FROM t1 WHERE a = 0; 3827a b 38280 First row, p0 REPLACED2 3829CREATE TRIGGER t1_before_delete BEFORE DELETE 3830ON t1 FOR EACH ROW 3831INSERT INTO t3 VALUES (OLD.a, NULL, CONCAT("BD: ", OLD.b), NULL); 3832FLUSH STATUS; 3833REPLACE INTO t1 VALUES (0, "First row, p0 REPLACED3"); 3834SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3835WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3836VARIABLE_NAME VARIABLE_VALUE 3837HANDLER_COMMIT 1 3838HANDLER_DELETE 1 3839HANDLER_EXTERNAL_LOCK 8 3840HANDLER_READ_KEY 1 3841HANDLER_WRITE 22 3842# (t1 to replace, t3 after insert trigger, t3 before delete trigger, 3843# t3 after delete trigger) 3844SELECT * FROM t1 WHERE a = 0; 3845a b 38460 First row, p0 REPLACED3 3847CREATE TRIGGER t1_before_update BEFORE UPDATE 3848ON t1 FOR EACH ROW 3849INSERT INTO t3 VALUES (OLD.a, NEW.a, CONCAT("BU: ", OLD.b), CONCAT("BU: ", NEW.b)); 3850FLUSH STATUS; 3851INSERT INTO t1 VALUES (2, "First row, p2") 3852ON DUPLICATE KEY UPDATE b = CONCAT(b, ", duplicate key 2"); 3853SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3854WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3855VARIABLE_NAME VARIABLE_VALUE 3856HANDLER_COMMIT 1 3857HANDLER_EXTERNAL_LOCK 8 3858HANDLER_READ_KEY 1 3859HANDLER_UPDATE 1 3860HANDLER_WRITE 20 3861# No pruning possible, due to BEFORE UPDATE trigger 3862# t1, t3 after insert, t3 before update, t3 after update 3863SELECT * FROM t1 WHERE a = 2; 3864a b 38652 First row, p2, duplicate key 2, duplicate key 2 3866FLUSH STATUS; 3867REPLACE INTO t1 VALUES (0, "First row, p0 REPLACED4"); 3868SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3869WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3870VARIABLE_NAME VARIABLE_VALUE 3871HANDLER_COMMIT 1 3872HANDLER_DELETE 1 3873HANDLER_EXTERNAL_LOCK 8 3874HANDLER_READ_KEY 1 3875HANDLER_WRITE 22 3876# t1, t3 after insert, t3 before delete, t3 after delete 3877SELECT * FROM t1 WHERE a = 0; 3878a b 38790 First row, p0 REPLACED4 3880FLUSH STATUS; 3881EXPLAIN PARTITIONS UPDATE t1 SET b = CONCAT(b, ", UPDATED2") WHERE a = 3; 3882id select_type table partitions type possible_keys key key_len ref rows filtered Extra 38831 UPDATE t1 p3 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 3884Warnings: 3885Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3886SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3887WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3888VARIABLE_NAME VARIABLE_VALUE 3889HANDLER_COMMIT 1 3890HANDLER_EXTERNAL_LOCK 6 3891HANDLER_WRITE 17 3892# No pruning possible, due to BEFORE UPDATE trigger 3893# t1, before update, after update 3894SELECT * FROM t1 WHERE a = 3; 3895a b 38963 First row, p3, same as min(a) + 2 in t2 3897FLUSH STATUS; 3898UPDATE t1 SET b = CONCAT(b, ", UPDATED2") WHERE a = 3; 3899SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3900WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3901VARIABLE_NAME VARIABLE_VALUE 3902HANDLER_COMMIT 1 3903HANDLER_EXTERNAL_LOCK 6 3904HANDLER_READ_KEY 2 3905HANDLER_READ_RND 1 3906HANDLER_UPDATE 1 3907HANDLER_WRITE 19 3908# t1, before update, after update 3909SELECT * FROM t1 WHERE a = 3; 3910a b 39113 First row, p3, same as min(a) + 2 in t2, UPDATED2 3912EXPLAIN PARTITIONS INSERT INTO t1 VALUES (12, "First row, p12"); 3913id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39141 INSERT t1 p12 ALL NULL NULL NULL NULL NULL NULL NULL 3915Warnings: 3916Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3917FLUSH STATUS; 3918INSERT INTO t1 VALUES (12, "First row, p12"); 3919SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3920WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3921VARIABLE_NAME VARIABLE_VALUE 3922HANDLER_COMMIT 1 3923HANDLER_EXTERNAL_LOCK 4 3924HANDLER_WRITE 19 3925# t1, t3 after insert trigger 3926CREATE TRIGGER t1_before_insert BEFORE INSERT 3927ON t1 FOR EACH ROW 3928INSERT INTO t3 VALUES (1, NEW.a, NULL, CONCAT("BI: ", NEW.b)); 3929FLUSH STATUS; 3930INSERT INTO t1 VALUES (11, "First row, p11"); 3931SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3932WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3933VARIABLE_NAME VARIABLE_VALUE 3934HANDLER_COMMIT 1 3935HANDLER_EXTERNAL_LOCK 6 3936HANDLER_WRITE 20 3937# Nothing can be pruned, due to triggers. 3938# t1, t3 before insert, t3 after insert. 3939FLUSH STATUS; 3940EXPLAIN PARTITIONS DELETE FROM t1 WHERE a = 98; 3941id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39421 DELETE t1 p7 range PRIMARY PRIMARY 4 const # 100.00 Using where 3943Warnings: 3944Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 3945SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3946WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3947VARIABLE_NAME VARIABLE_VALUE 3948HANDLER_COMMIT 1 3949HANDLER_EXTERNAL_LOCK 6 3950HANDLER_WRITE 17 3951# t1, t3 before delete trigger, t3 after delete trigger 3952# part 7, part 0-4, part 0-4. 3953SELECT * FROM t1 ORDER BY a; 3954a b 39550 First row, p0 REPLACED4 39562 First row, p2, duplicate key 2, duplicate key 2 39573 First row, p3, same as min(a) + 2 in t2, UPDATED2 39584 First row, p4, t2.b:First row, p4 39595 REPLACE second, max(a) in t2: 4 39608 Insert in v1_9 NO CHECK! 39619 Insert in v1_9_check 396211 First row, p11 396312 First row, p12 396418 Insert in v1_25 396523 Insert in v1_all 396626 Third row, p0, updated 1 396731 Insert in v1_25_check 396839 Fourth row, p0, updated 1 396952 Fifth row, p0, updated 1 397065 No duplicate, INSERT_DUP_KEY_UPDATE 397198 Test98 3972104 No duplicate 104 3973111 Test111 3974113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 3975313 Test313 3976FLUSH STATUS; 3977DELETE FROM t1 WHERE a = 98; 3978SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 3979WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 3980VARIABLE_NAME VARIABLE_VALUE 3981HANDLER_COMMIT 1 3982HANDLER_DELETE 1 3983HANDLER_EXTERNAL_LOCK 6 3984HANDLER_READ_KEY 1 3985HANDLER_WRITE 19 3986# t1, t3 before delete trigger, t3 after delete trigger 3987SELECT * FROM t1 ORDER BY a; 3988a b 39890 First row, p0 REPLACED4 39902 First row, p2, duplicate key 2, duplicate key 2 39913 First row, p3, same as min(a) + 2 in t2, UPDATED2 39924 First row, p4, t2.b:First row, p4 39935 REPLACE second, max(a) in t2: 4 39948 Insert in v1_9 NO CHECK! 39959 Insert in v1_9_check 399611 First row, p11 399712 First row, p12 399818 Insert in v1_25 399923 Insert in v1_all 400026 Third row, p0, updated 1 400131 Insert in v1_25_check 400239 Fourth row, p0, updated 1 400352 Fifth row, p0, updated 1 400465 No duplicate, INSERT_DUP_KEY_UPDATE 4005104 No duplicate 104 4006111 Test111 4007113 Second row, p0, updated 1, updated 2 -> p8, updated 3, updated 4 -> p9 4008313 Test313 4009SELECT * FROM t2 ORDER BY a; 4010a b 40114 First row, p4, t1.b:First row, p4 4012SELECT * FROM t3 ORDER BY new_a; 4013old_a new_a old_b new_b 40140 NULL AD: First row, p0 REPLACED NULL 40150 NULL AD: First row, p0 REPLACED2 NULL 40160 NULL AD: First row, p0 REPLACED3 NULL 40170 NULL BD: First row, p0 REPLACED2 NULL 40180 NULL BD: First row, p0 REPLACED3 NULL 40191 11 NULL BI: First row, p11 40202 0 NULL AI: First row, p0 REPLACED 40212 0 NULL AI: First row, p0 REPLACED2 40222 0 NULL AI: First row, p0 REPLACED3 40232 0 NULL AI: First row, p0 REPLACED4 40242 11 NULL AI: First row, p11 40252 12 NULL AI: First row, p12 40262 2 AU: First row, p2 AU: First row, p2, duplicate key 2 40272 2 AU: First row, p2, duplicate key 2 AU: First row, p2, duplicate key 2, duplicate key 2 40282 2 BU: First row, p2, duplicate key 2 BU: First row, p2, duplicate key 2, duplicate key 2 40293 3 AU: First row, p3, same as min(a) + 2 in t2 AU: First row, p3, same as min(a) + 2 in t2, UPDATED2 40303 3 BU: First row, p3, same as min(a) + 2 in t2 BU: First row, p3, same as min(a) + 2 in t2, UPDATED2 403198 NULL AD: Test98 NULL 403298 NULL BD: Test98 NULL 4033TRUNCATE TABLE t1; 4034DROP TRIGGER t1_before_insert; 4035DROP TRIGGER t1_before_update; 4036DROP TRIGGER t1_before_delete; 4037DROP TRIGGER t1_after_insert; 4038DROP TRIGGER t1_after_update; 4039DROP TRIGGER t1_after_delete; 4040# 4041# Test BEFORE INSERT TRIGGER depending on partitioning column 4042# 4043CREATE TRIGGER t1_before_insert BEFORE INSERT 4044ON t1 FOR EACH ROW 4045SET NEW.b = CONCAT("b: ", NEW.b, " a: ", NEW.a); 4046FLUSH STATUS; 4047INSERT INTO t1 VALUES (0, "first row, p0"); 4048SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4049WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4050VARIABLE_NAME VARIABLE_VALUE 4051HANDLER_COMMIT 1 4052HANDLER_EXTERNAL_LOCK 2 4053HANDLER_WRITE 18 4054FLUSH STATUS; 4055INSERT INTO t1 VALUES (0, "Second row, p0") 4056ON DUPLICATE KEY UPDATE b = CONCAT(b, ", duplicate key"); 4057SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4058WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4059VARIABLE_NAME VARIABLE_VALUE 4060HANDLER_COMMIT 1 4061HANDLER_EXTERNAL_LOCK 2 4062HANDLER_READ_KEY 1 4063HANDLER_UPDATE 1 4064HANDLER_WRITE 18 4065FLUSH STATUS; 4066UPDATE t1 SET b = CONCAT(b, ", Updated") WHERE a = 0; 4067SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4068WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4069VARIABLE_NAME VARIABLE_VALUE 4070HANDLER_COMMIT 1 4071HANDLER_EXTERNAL_LOCK 2 4072HANDLER_READ_KEY 1 4073HANDLER_UPDATE 1 4074HANDLER_WRITE 17 4075FLUSH STATUS; 4076UPDATE t1 SET a = 1, b = CONCAT(b, ", a was 0") WHERE a = 0; 4077SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4078WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4079VARIABLE_NAME VARIABLE_VALUE 4080HANDLER_COMMIT 1 4081HANDLER_DELETE 1 4082HANDLER_EXTERNAL_LOCK 2 4083HANDLER_READ_KEY 2 4084HANDLER_READ_RND 1 4085HANDLER_WRITE 18 4086# Updating partitioning column, no lock pruning 4087# 4088# Test BEFORE INSERT TRIGGER not depending on partitioning column 4089# 4090DROP TRIGGER t1_before_insert; 4091CREATE TRIGGER t1_before_insert BEFORE INSERT 4092ON t1 FOR EACH ROW 4093SET NEW.b = CONCAT("b: ", NEW.b); 4094FLUSH STATUS; 4095INSERT INTO t1 VALUES (0, "first row, p0"); 4096SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4097WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4098VARIABLE_NAME VARIABLE_VALUE 4099HANDLER_COMMIT 1 4100HANDLER_EXTERNAL_LOCK 2 4101HANDLER_WRITE 18 4102FLUSH STATUS; 4103INSERT INTO t1 VALUES (0, "Second row, p0") 4104ON DUPLICATE KEY UPDATE b = CONCAT(b, ", duplicate key"); 4105SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4106WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4107VARIABLE_NAME VARIABLE_VALUE 4108HANDLER_COMMIT 1 4109HANDLER_EXTERNAL_LOCK 2 4110HANDLER_READ_KEY 1 4111HANDLER_UPDATE 1 4112HANDLER_WRITE 18 4113FLUSH STATUS; 4114UPDATE t1 SET b = CONCAT(b, ", Updated") WHERE a = 0; 4115SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4116WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4117VARIABLE_NAME VARIABLE_VALUE 4118HANDLER_COMMIT 1 4119HANDLER_EXTERNAL_LOCK 2 4120HANDLER_READ_KEY 1 4121HANDLER_UPDATE 1 4122HANDLER_WRITE 17 4123FLUSH STATUS; 4124UPDATE t1 SET a = 2, b = CONCAT(b, ", a was 0") WHERE a = 0; 4125SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4126WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4127VARIABLE_NAME VARIABLE_VALUE 4128HANDLER_COMMIT 1 4129HANDLER_DELETE 1 4130HANDLER_EXTERNAL_LOCK 2 4131HANDLER_READ_KEY 2 4132HANDLER_READ_RND 1 4133HANDLER_WRITE 18 4134# Updating partitioning column, no lock pruning 4135# 4136# Test BEFORE UPDATE TRIGGER OLD depending on partitioning column. 4137# Note that it does not update any partitioning column. 4138# 4139CREATE TRIGGER t1_before_update BEFORE UPDATE 4140ON t1 FOR EACH ROW 4141SET NEW.b = CONCAT("old a: ", OLD.a, " new b: ", NEW.b); 4142FLUSH STATUS; 4143INSERT INTO t1 VALUES (0, "1st p0"); 4144SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4145WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4146VARIABLE_NAME VARIABLE_VALUE 4147HANDLER_COMMIT 1 4148HANDLER_EXTERNAL_LOCK 2 4149HANDLER_WRITE 18 4150FLUSH STATUS; 4151INSERT INTO t1 VALUES (0, "2nd p0") 4152ON DUPLICATE KEY UPDATE b = CONCAT(b, ", dup key"); 4153SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4154WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4155VARIABLE_NAME VARIABLE_VALUE 4156HANDLER_COMMIT 1 4157HANDLER_EXTERNAL_LOCK 2 4158HANDLER_READ_KEY 1 4159HANDLER_UPDATE 1 4160HANDLER_WRITE 18 4161FLUSH STATUS; 4162UPDATE t1 SET b = CONCAT(b, ", Updated") WHERE a = 0; 4163SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4164WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4165VARIABLE_NAME VARIABLE_VALUE 4166HANDLER_COMMIT 1 4167HANDLER_EXTERNAL_LOCK 2 4168HANDLER_READ_KEY 1 4169HANDLER_UPDATE 1 4170HANDLER_WRITE 17 4171# Lock pruning possible! 4172FLUSH STATUS; 4173UPDATE t1 SET a = 3, b = CONCAT(b, ", a was 0") WHERE a = 0; 4174SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4175WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4176VARIABLE_NAME VARIABLE_VALUE 4177HANDLER_COMMIT 1 4178HANDLER_DELETE 1 4179HANDLER_EXTERNAL_LOCK 2 4180HANDLER_READ_KEY 2 4181HANDLER_READ_RND 1 4182HANDLER_WRITE 18 4183# Updating partitioning column, no lock pruning 4184# 4185# Test BEFORE UPDATE TRIGGER NEW depending on partitioning column. 4186# Note that it does not update any partitioning column. 4187# 4188DROP TRIGGER t1_before_update; 4189CREATE TRIGGER t1_before_update BEFORE UPDATE 4190ON t1 FOR EACH ROW 4191SET NEW.b = CONCAT("new a: ", NEW.a, " new b: ", NEW.b); 4192FLUSH STATUS; 4193INSERT INTO t1 VALUES (0, "1st p0"); 4194SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4195WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4196VARIABLE_NAME VARIABLE_VALUE 4197HANDLER_COMMIT 1 4198HANDLER_EXTERNAL_LOCK 2 4199HANDLER_WRITE 18 4200FLUSH STATUS; 4201INSERT INTO t1 VALUES (0, "2nd p0") 4202ON DUPLICATE KEY UPDATE b = CONCAT(b, ", dup key"); 4203SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4204WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4205VARIABLE_NAME VARIABLE_VALUE 4206HANDLER_COMMIT 1 4207HANDLER_EXTERNAL_LOCK 2 4208HANDLER_READ_KEY 1 4209HANDLER_UPDATE 1 4210HANDLER_WRITE 18 4211FLUSH STATUS; 4212UPDATE t1 SET b = CONCAT(b, ", Updated") WHERE a = 0; 4213SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4214WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4215VARIABLE_NAME VARIABLE_VALUE 4216HANDLER_COMMIT 1 4217HANDLER_EXTERNAL_LOCK 2 4218HANDLER_READ_KEY 2 4219HANDLER_READ_RND 1 4220HANDLER_UPDATE 1 4221HANDLER_WRITE 17 4222FLUSH STATUS; 4223UPDATE t1 SET a = 4, b = CONCAT(b, ", a was 0") WHERE a = 0; 4224SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4225WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4226VARIABLE_NAME VARIABLE_VALUE 4227HANDLER_COMMIT 1 4228HANDLER_DELETE 1 4229HANDLER_EXTERNAL_LOCK 2 4230HANDLER_READ_KEY 2 4231HANDLER_READ_RND 1 4232HANDLER_WRITE 18 4233# Updating partitioning column, no lock pruning 4234# 4235# Test BEFORE UPDATE TRIGGER not depending on partitioning column 4236# 4237DROP TRIGGER t1_before_update; 4238CREATE TRIGGER t1_before_update BEFORE UPDATE 4239ON t1 FOR EACH ROW 4240SET NEW.b = CONCAT("new b: ", NEW.b); 4241FLUSH STATUS; 4242INSERT INTO t1 VALUES (0, "1st p0"); 4243SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4244WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4245VARIABLE_NAME VARIABLE_VALUE 4246HANDLER_COMMIT 1 4247HANDLER_EXTERNAL_LOCK 2 4248HANDLER_WRITE 18 4249FLUSH STATUS; 4250INSERT INTO t1 VALUES (0, "2nd p0") 4251ON DUPLICATE KEY UPDATE b = CONCAT(b, ", dup key"); 4252SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4253WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4254VARIABLE_NAME VARIABLE_VALUE 4255HANDLER_COMMIT 1 4256HANDLER_EXTERNAL_LOCK 2 4257HANDLER_READ_KEY 1 4258HANDLER_UPDATE 1 4259HANDLER_WRITE 18 4260FLUSH STATUS; 4261UPDATE t1 SET b = CONCAT(b, ", Updated") WHERE a = 0; 4262SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4263WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4264VARIABLE_NAME VARIABLE_VALUE 4265HANDLER_COMMIT 1 4266HANDLER_EXTERNAL_LOCK 2 4267HANDLER_READ_KEY 1 4268HANDLER_UPDATE 1 4269HANDLER_WRITE 17 4270FLUSH STATUS; 4271UPDATE t1 SET a = 5, b = CONCAT(b, ", a was 0") WHERE a = 0; 4272SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4273WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4274VARIABLE_NAME VARIABLE_VALUE 4275HANDLER_COMMIT 1 4276HANDLER_DELETE 1 4277HANDLER_EXTERNAL_LOCK 2 4278HANDLER_READ_KEY 2 4279HANDLER_READ_RND 1 4280HANDLER_WRITE 18 4281# Updating partitioning column, no lock pruning 4282SELECT * FROM t1 ORDER BY a; 4283a b 42841 b: first row, p0 a: 0, duplicate key, Updated, a was 0 42852 b: first row, p0, duplicate key, Updated, a was 0 42863 old a: 0 new b: old a: 0 new b: old a: 0 new b: b: 1st p0, dup key, Updated, a was 0 42874 new a: 4 new b: new a: 0 new b: new a: 0 new b: b: 1st p0, dup key, Updated, a was 0 42885 new b: new b: new b: b: 1st p0, dup key, Updated, a was 0 4289DROP TABLE t1, t2, t3; 4290# 4291# Test of BEFORE UPDATE triggers and multi UPDATE 4292# 4293CREATE TABLE t1 (a int, b varchar(128), KEY (b)) 4294ENGINE = InnoDB 4295PARTITION BY HASH (a) PARTITIONS 13; 4296CREATE TABLE t2 (a int PRIMARY KEY, b varchar(128)) 4297ENGINE = InnoDB 4298PARTITION BY HASH (a) PARTITIONS 13; 4299INSERT INTO t1 VALUES (1, "MultiUpdate1"); 4300INSERT INTO t1 VALUES (2, "MultiUpdate2"); 4301INSERT INTO t2 VALUES (1, "MultiUpdate1"); 4302INSERT INTO t2 VALUES (2, "MultiUpdate2"); 4303CREATE TRIGGER t1_before_update BEFORE UPDATE 4304ON t1 FOR EACH ROW 4305SET NEW.b = CONCAT("new1 b: ", NEW.b); 4306CREATE TRIGGER t2_before_update BEFORE UPDATE 4307ON t2 FOR EACH ROW 4308SET NEW.b = CONCAT("new2 a: ", NEW.a, " new2 b: ", NEW.b); 4309FLUSH STATUS; 4310EXPLAIN EXTENDED UPDATE t1, t2 4311SET t1.b = CONCAT(t1.b, ",(1) t2.b:", t2.b), 4312t2.b = CONCAT(t2.b, ",(1) t1.b:", t1.b) 4313WHERE t2.b = t1.b and t1.a = 1; 4314id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43151 UPDATE t1 p1 ALL b NULL NULL NULL # 100.00 Using where 43161 UPDATE t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 50.00 Using where 4317Warnings: 4318Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4319SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4320WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4321VARIABLE_NAME VARIABLE_VALUE 4322HANDLER_COMMIT 1 4323HANDLER_EXTERNAL_LOCK 4 4324HANDLER_WRITE 17 4325FLUSH STATUS; 4326EXPLAIN PARTITIONS UPDATE t1, t2 4327SET t1.b = CONCAT(t1.b, ",(1) t2.b:", t2.b), 4328t2.b = CONCAT(t2.b, ",(1) t1.b:", t1.b) 4329WHERE t2.b = t1.b and t1.a = 1; 4330id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43311 UPDATE t1 p1 ALL b NULL NULL NULL # 100.00 Using where 43321 UPDATE t2 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ALL NULL NULL NULL NULL # 50.00 Using where 4333Warnings: 4334Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4335SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4336WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4337VARIABLE_NAME VARIABLE_VALUE 4338HANDLER_COMMIT 1 4339HANDLER_EXTERNAL_LOCK 4 4340HANDLER_WRITE 17 4341FLUSH STATUS; 4342UPDATE t1, t2 4343SET t1.b = CONCAT(t1.b, ",(1) t2.b:", t2.b), 4344t2.b = CONCAT(t2.b, ",(1) t1.b:", t1.b) 4345WHERE t2.b = t1.b and t1.a = 1; 4346SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4347WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4348VARIABLE_NAME VARIABLE_VALUE 4349HANDLER_COMMIT 1 4350HANDLER_EXTERNAL_LOCK 4 4351HANDLER_READ_FIRST 14 4352HANDLER_READ_KEY 16 4353HANDLER_READ_RND 2 4354HANDLER_READ_RND_NEXT 7 4355HANDLER_UPDATE 2 4356HANDLER_WRITE 19 4357# 14 read_first 4358# 16 read_key 4359# 2 read_rnd 4360# 2 update 4361FLUSH STATUS; 4362EXPLAIN EXTENDED UPDATE t1, t2 4363SET t1.b = CONCAT(t1.b, ",(2) t2.b:", t2.b), 4364t2.b = CONCAT(t2.b, ",(2) t1.b:", t1.b) 4365WHERE t1.b = t2.b and t2.a = 2; 4366id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43671 UPDATE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 43681 UPDATE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref b b 131 const # 100.00 NULL 4369Warnings: 4370Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4371SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4372WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4373VARIABLE_NAME VARIABLE_VALUE 4374HANDLER_COMMIT 1 4375HANDLER_EXTERNAL_LOCK 4 4376HANDLER_READ_KEY 1 4377HANDLER_WRITE 17 4378# Trigger touches partitioning column, unable to prune locks 4379FLUSH STATUS; 4380EXPLAIN PARTITIONS UPDATE t1, t2 4381SET t1.b = CONCAT(t1.b, ",(2) t2.b:", t2.b), 4382t2.b = CONCAT(t2.b, ",(2) t1.b:", t1.b) 4383WHERE t1.b = t2.b and t2.a = 2; 4384id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43851 UPDATE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 43861 UPDATE t1 p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ref b b 131 const # 100.00 NULL 4387Warnings: 4388Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4389SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4390WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4391VARIABLE_NAME VARIABLE_VALUE 4392HANDLER_COMMIT 1 4393HANDLER_EXTERNAL_LOCK 4 4394HANDLER_READ_KEY 1 4395HANDLER_WRITE 17 4396# Trigger touches partitioning column, unable to prune locks 4397FLUSH STATUS; 4398UPDATE t1, t2 4399SET t1.b = CONCAT(t1.b, ",(2) t2.b:", t2.b), 4400t2.b = CONCAT(t2.b, ",(2) t1.b:", t1.b) 4401WHERE t1.b = t2.b and t2.a = 2; 4402SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4403WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4404VARIABLE_NAME VARIABLE_VALUE 4405HANDLER_COMMIT 1 4406HANDLER_EXTERNAL_LOCK 4 4407HANDLER_READ_KEY 15 4408HANDLER_READ_NEXT 1 4409HANDLER_READ_RND 1 4410HANDLER_READ_RND_NEXT 2 4411HANDLER_UPDATE 2 4412HANDLER_WRITE 18 4413# Due to the BEFORE UPDATE trigger on t2 that looks at 'a', 4414# no locks can be pruned. 4415# 15 read_key 4416# 1 read_next, read_rnd 4417# 2 read_rnd_next 4418# 2 update 4419SELECT * FROM t1 ORDER BY a; 4420a b 44211 new1 b: MultiUpdate1,(1) t2.b:MultiUpdate1 44222 new1 b: MultiUpdate2,(2) t2.b:MultiUpdate2 4423SELECT * FROM t2 ORDER BY a; 4424a b 44251 new2 a: 1 new2 b: MultiUpdate1,(1) t1.b:MultiUpdate1 44262 new2 a: 2 new2 b: MultiUpdate2,(2) t1.b:MultiUpdate2 4427DROP TABLE t1, t2; 4428# 4429# Test constant propagation in WHERE clause 4430# (Currently no propagation is done before locking). 4431CREATE TABLE t1 (a int, b varchar(128), KEY (b)) 4432ENGINE = InnoDB 4433PARTITION BY RANGE (a) 4434(PARTITION pNeg VALUES LESS THAN (0), 4435PARTITION p0 VALUES LESS THAN (1), 4436PARTITION p1 VALUES LESS THAN (2), 4437PARTITION p2 VALUES LESS THAN (3), 4438PARTITION p3 VALUES LESS THAN (4), 4439PARTITION pMax VALUES LESS THAN MAXVALUE); 4440CREATE TABLE t2 (a int PRIMARY KEY, b varchar(128)) 4441ENGINE = InnoDB 4442PARTITION BY RANGE (a) 4443(PARTITION pNeg VALUES LESS THAN (0), 4444PARTITION p0 VALUES LESS THAN (1), 4445PARTITION p1 VALUES LESS THAN (2), 4446PARTITION p2 VALUES LESS THAN (3), 4447PARTITION p3 VALUES LESS THAN (4), 4448PARTITION pMax VALUES LESS THAN MAXVALUE); 4449INSERT INTO t1 VALUES (1, "Const1"); 4450INSERT INTO t2 VALUES (1, "Const1"); 4451INSERT INTO t1 VALUES (2, "Const2"); 4452INSERT INTO t2 VALUES (2, "Const2"); 4453INSERT INTO t1 VALUES (3, "Const3"); 4454INSERT INTO t2 VALUES (3, "Const3"); 4455# Test simple '=' propagation 4456FLUSH STATUS; 4457SELECT * FROM t1, t2 4458WHERE t1.a = t2.a AND t2.a = 1; 4459a b a b 44601 Const1 1 Const1 4461SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4462WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4463VARIABLE_NAME VARIABLE_VALUE 4464HANDLER_COMMIT 1 4465HANDLER_EXTERNAL_LOCK 4 4466HANDLER_READ_FIRST 1 4467HANDLER_READ_KEY 2 4468HANDLER_READ_RND_NEXT 1 4469HANDLER_WRITE 17 4470FLUSH STATUS; 4471SELECT * FROM t1, t2 4472WHERE t1.a = t2.a AND t1.a = 1; 4473a b a b 44741 Const1 1 Const1 4475SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4476WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4477VARIABLE_NAME VARIABLE_VALUE 4478HANDLER_COMMIT 1 4479HANDLER_EXTERNAL_LOCK 4 4480HANDLER_READ_FIRST 1 4481HANDLER_READ_KEY 2 4482HANDLER_READ_RND_NEXT 1 4483HANDLER_WRITE 17 4484# Test OR propagation 4485FLUSH STATUS; 4486SELECT * FROM t1, t2 4487WHERE t1.a = t2.a AND (t2.a = 1 OR t2.a = 2); 4488a b a b 44891 Const1 1 Const1 44902 Const2 2 Const2 4491SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4492WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4493VARIABLE_NAME VARIABLE_VALUE 4494HANDLER_COMMIT 1 4495HANDLER_EXTERNAL_LOCK 4 4496HANDLER_READ_FIRST 2 4497HANDLER_READ_KEY 4 4498HANDLER_READ_RND_NEXT 2 4499HANDLER_WRITE 17 4500# But it will be scanned pruned! 4501EXPLAIN PARTITIONS SELECT * FROM t1, t2 4502WHERE t1.a = t2.a AND (t1.a = 1 OR t1.a = 2); 4503id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45041 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL # 75.00 Using where 45051 SIMPLE t2 p1,p2 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 4506Warnings: 4507Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4508Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t1`.`a` = 1) or (`test`.`t1`.`a` = 2))) 4509# Test closed range propagation 4510FLUSH STATUS; 4511SELECT * FROM t1, t2 4512WHERE t1.a = t2.a AND t1.a >= 1 AND t1.a <=3; 4513a b a b 45141 Const1 1 Const1 45152 Const2 2 Const2 45163 Const3 3 Const3 4517SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4518WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4519VARIABLE_NAME VARIABLE_VALUE 4520HANDLER_COMMIT 1 4521HANDLER_EXTERNAL_LOCK 4 4522HANDLER_READ_FIRST 3 4523HANDLER_READ_KEY 6 4524HANDLER_READ_RND_NEXT 3 4525HANDLER_WRITE 17 4526# But it will be scanned pruned! 4527EXPLAIN PARTITIONS SELECT * FROM t1, t2 4528WHERE t1.a = t2.a AND t1.a >= 1 AND t1.a <=3; 4529id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45301 SIMPLE t1 p1,p2,p3 ALL NULL NULL NULL NULL # 33.33 Using where 45311 SIMPLE t2 p1,p2,p3 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 4532Warnings: 4533Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4534Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` >= 1) and (`test`.`t1`.`a` <= 3)) 4535# Test open range propagation 4536FLUSH STATUS; 4537SELECT * FROM t1, t2 4538WHERE t1.a = t2.a AND t2.a >= 1; 4539a b a b 45401 Const1 1 Const1 45412 Const2 2 Const2 45423 Const3 3 Const3 4543SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4544WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4545VARIABLE_NAME VARIABLE_VALUE 4546HANDLER_COMMIT 1 4547HANDLER_EXTERNAL_LOCK 4 4548HANDLER_READ_FIRST 4 4549HANDLER_READ_KEY 8 4550HANDLER_READ_NEXT 3 4551HANDLER_READ_RND_NEXT 3 4552HANDLER_WRITE 17 4553# But is scanned pruned! 4554EXPLAIN PARTITIONS SELECT * FROM t1, t2 4555WHERE t1.a = t2.a AND t2.a >= 1; 4556id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45571 SIMPLE t2 p1,p2,p3,pMax range PRIMARY PRIMARY 4 NULL # 100.00 Using where 45581 SIMPLE t1 p1,p2,p3,pMax ALL NULL NULL NULL NULL # 33.33 Using where; Using join buffer (Block Nested Loop) 4559Warnings: 4560Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4561Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t2`.`a` >= 1)) 4562FLUSH STATUS; 4563SELECT * FROM t1, t2 4564WHERE t1.a = t2.a AND t2.a <= 1; 4565a b a b 45661 Const1 1 Const1 4567SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4568WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4569VARIABLE_NAME VARIABLE_VALUE 4570HANDLER_COMMIT 1 4571HANDLER_EXTERNAL_LOCK 4 4572HANDLER_READ_FIRST 3 4573HANDLER_READ_KEY 4 4574HANDLER_READ_RND_NEXT 1 4575HANDLER_WRITE 17 4576# But is scanned pruned! 4577EXPLAIN PARTITIONS SELECT * FROM t1, t2 4578WHERE t1.a = t2.a AND t2.a <= 1; 4579id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45801 SIMPLE t1 pNeg,p0,p1 ALL NULL NULL NULL NULL # 100.00 Using where 45811 SIMPLE t2 pNeg,p0,p1 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 4582Warnings: 4583Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4584Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` <= 1)) 4585# Test IN propagation 4586FLUSH STATUS; 4587SELECT * FROM t1, t2 4588WHERE t1.a = t2.a and t2.a IN (1, 3); 4589a b a b 45901 Const1 1 Const1 45913 Const3 3 Const3 4592SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4593WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4594VARIABLE_NAME VARIABLE_VALUE 4595HANDLER_COMMIT 1 4596HANDLER_EXTERNAL_LOCK 4 4597HANDLER_READ_FIRST 2 4598HANDLER_READ_KEY 4 4599HANDLER_READ_RND_NEXT 2 4600HANDLER_WRITE 17 4601# But is scanned pruned! 4602EXPLAIN PARTITIONS SELECT * FROM t1, t2 4603WHERE t1.a = t2.a AND t1.a IN (1, 3); 4604id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46051 SIMPLE t1 p1,p3 ALL NULL NULL NULL NULL # 50.00 Using where 46061 SIMPLE t2 p1,p3 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 4607Warnings: 4608Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4609Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` in (1,3))) 4610# Same for UPDATE 4611FLUSH STATUS; 4612UPDATE t1, t2 4613SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b) 4614WHERE t1.a = t2.a and t2.a IN (2, 3); 4615SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4616WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4617VARIABLE_NAME VARIABLE_VALUE 4618HANDLER_COMMIT 1 4619HANDLER_EXTERNAL_LOCK 4 4620HANDLER_READ_FIRST 2 4621HANDLER_READ_KEY 4 4622HANDLER_READ_RND_NEXT 2 4623HANDLER_UPDATE 2 4624HANDLER_WRITE 17 4625# But is scanned pruned! 4626EXPLAIN PARTITIONS UPDATE t1, t2 4627SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b) 4628WHERE t1.a = t2.a and t2.a IN (2, 3); 4629id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46301 UPDATE t1 p2,p3 ALL NULL NULL NULL NULL # 100.00 Using where 46311 SIMPLE t2 p2,p3 eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 NULL 4632Warnings: 4633Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4634FLUSH STATUS; 4635UPDATE t1, t2 4636SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b), 4637t2.b = CONCAT(t2.b, ", t1.b:", t1.b) 4638WHERE t1.a = t2.a and t2.a = 1; 4639SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4640WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4641VARIABLE_NAME VARIABLE_VALUE 4642HANDLER_COMMIT 1 4643HANDLER_EXTERNAL_LOCK 4 4644HANDLER_READ_FIRST 1 4645HANDLER_READ_KEY 3 4646HANDLER_READ_RND 1 4647HANDLER_READ_RND_NEXT 3 4648HANDLER_UPDATE 2 4649HANDLER_WRITE 18 4650FLUSH STATUS; 4651UPDATE t1, t2 4652SET t1.b = CONCAT(t1.b, ", t2.b:", t2.b), 4653t2.b = CONCAT(t2.b, ", t1.b:", t1.b) 4654WHERE t1.a = t2.a and t1.a = 2; 4655SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4656WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4657VARIABLE_NAME VARIABLE_VALUE 4658HANDLER_COMMIT 1 4659HANDLER_EXTERNAL_LOCK 4 4660HANDLER_READ_FIRST 1 4661HANDLER_READ_KEY 3 4662HANDLER_READ_RND 1 4663HANDLER_READ_RND_NEXT 3 4664HANDLER_UPDATE 2 4665HANDLER_WRITE 18 4666SELECT * FROM t1 ORDER BY a; 4667a b 46681 Const1, t2.b:Const1 46692 Const2, t2.b:Const2, t2.b:Const2 46703 Const3, t2.b:Const3 4671SELECT * FROM t2 ORDER BY a; 4672a b 46731 Const1, t1.b:Const1 46742 Const2, t1.b:Const2, t2.b:Const2 46753 Const3 4676# Same for DELETE 4677FLUSH STATUS; 4678DELETE t1 FROM t1, t2 4679WHERE t1.a = t2.a AND t2.a IN (1, 9); 4680SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4681WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4682VARIABLE_NAME VARIABLE_VALUE 4683HANDLER_COMMIT 1 4684HANDLER_DELETE 1 4685HANDLER_EXTERNAL_LOCK 4 4686HANDLER_READ_FIRST 2 4687HANDLER_READ_KEY 3 4688HANDLER_READ_RND_NEXT 1 4689HANDLER_WRITE 17 4690# But is scanned pruned! 4691EXPLAIN PARTITIONS DELETE t1 FROM t1, t2 4692WHERE t1.a = t2.a AND t2.a IN (1, 9); 4693id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46941 DELETE t1 p1,pMax ALL NULL NULL NULL NULL # 100.00 Using where 46951 SIMPLE t2 p1,pMax eq_ref PRIMARY PRIMARY 4 test.t1.a # 100.00 Using index 4696Warnings: 4697Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4698SELECT * FROM t1 ORDER BY a; 4699a b 47002 Const2, t2.b:Const2, t2.b:Const2 47013 Const3, t2.b:Const3 4702FLUSH STATUS; 4703DELETE t1 FROM t1, t2 4704WHERE t1.a = t2.a and t2.a = 2; 4705SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4706WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4707VARIABLE_NAME VARIABLE_VALUE 4708HANDLER_COMMIT 1 4709HANDLER_DELETE 1 4710HANDLER_EXTERNAL_LOCK 4 4711HANDLER_READ_FIRST 1 4712HANDLER_READ_KEY 2 4713HANDLER_READ_RND_NEXT 1 4714HANDLER_WRITE 17 4715FLUSH STATUS; 4716DELETE t1 FROM t1, t2 4717WHERE t1.a = t2.a and t1.a = 1; 4718SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4719WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4720VARIABLE_NAME VARIABLE_VALUE 4721HANDLER_COMMIT 1 4722HANDLER_EXTERNAL_LOCK 4 4723HANDLER_READ_FIRST 1 4724HANDLER_READ_KEY 2 4725HANDLER_WRITE 17 4726SELECT * FROM t1 ORDER BY a; 4727a b 47283 Const3, t2.b:Const3 4729SELECT * FROM t2 ORDER BY a; 4730a b 47311 Const1, t1.b:Const1 47322 Const2, t1.b:Const2, t2.b:Const2 47333 Const3 4734FLUSH STATUS; 4735DELETE t1, t2 FROM t1, t2 4736WHERE t1.a = t2.a and t2.a = 3; 4737SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4738WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4739VARIABLE_NAME VARIABLE_VALUE 4740HANDLER_COMMIT 1 4741HANDLER_DELETE 2 4742HANDLER_EXTERNAL_LOCK 4 4743HANDLER_READ_FIRST 1 4744HANDLER_READ_KEY 2 4745HANDLER_READ_RND_NEXT 1 4746HANDLER_WRITE 17 4747SELECT * FROM t1 ORDER BY a; 4748a b 4749SELECT * FROM t2 ORDER BY a; 4750a b 47511 Const1, t1.b:Const1 47522 Const2, t1.b:Const2, t2.b:Const2 4753DROP TABLE t1, t2; 4754# 4755# DO is not supported by WL#4443 !!! 4756# Test of DO (eg. SELECT without returning values) 4757# 4758CREATE TABLE t1 (a INT, b VARCHAR(66)) 4759PARTITION BY HASH (a) PARTITIONS 3; 4760INSERT INTO t1 VALUES (1, "One"), (2, "Two"), (3, "Three"), (4, "Four"), (5, "Five"), (6, "Six"), (0, "Zero"); 4761DO (SELECT a FROM t1); 4762ERROR 21000: Subquery returns more than 1 row 4763FLUSH STATUS; 4764DO (SELECT @x:= b FROM t1 WHERE a = 5); 4765SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4766WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4767VARIABLE_NAME VARIABLE_VALUE 4768HANDLER_COMMIT 1 4769HANDLER_EXTERNAL_LOCK 2 4770HANDLER_READ_FIRST 1 4771HANDLER_READ_KEY 1 4772HANDLER_READ_RND_NEXT 2 4773HANDLER_WRITE 17 4774SELECT @x; 4775@x 4776Five 4777FLUSH STATUS; 4778DO (SELECT @x:= b FROM t1 WHERE a = 5 or a = 1 ORDER BY b LIMIT 1); 4779SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4780WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4781VARIABLE_NAME VARIABLE_VALUE 4782HANDLER_COMMIT 1 4783HANDLER_EXTERNAL_LOCK 2 4784HANDLER_READ_FIRST 2 4785HANDLER_READ_KEY 2 4786HANDLER_READ_RND_NEXT 4 4787HANDLER_WRITE 17 4788SELECT @x; 4789@x 4790Five 4791# 4792# SET is not supported by WL#4443 !!! 4793# Test of SET (eg. SELECT only setting an internal variable from 4794# the returning value) 4795# 4796FLUSH STATUS; 4797SET @x = (SELECT a FROM t1 WHERE a = 5); 4798SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4799WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4800VARIABLE_NAME VARIABLE_VALUE 4801HANDLER_COMMIT 1 4802HANDLER_EXTERNAL_LOCK 2 4803HANDLER_READ_FIRST 1 4804HANDLER_READ_KEY 1 4805HANDLER_READ_RND_NEXT 2 4806HANDLER_WRITE 17 4807SELECT @x; 4808@x 48095 4810FLUSH STATUS; 4811SET @y = (SELECT @x:= b FROM t1 WHERE a = 5); 4812SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4813WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4814VARIABLE_NAME VARIABLE_VALUE 4815HANDLER_COMMIT 1 4816HANDLER_EXTERNAL_LOCK 2 4817HANDLER_READ_FIRST 1 4818HANDLER_READ_KEY 1 4819HANDLER_READ_RND_NEXT 2 4820HANDLER_WRITE 17 4821SELECT @x, @y; 4822@x @y 4823Five Five 4824FLUSH STATUS; 4825SET @y = (SELECT @x:= b FROM t1 WHERE a = 5 or a = 1 ORDER BY b LIMIT 1); 4826SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4827WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4828VARIABLE_NAME VARIABLE_VALUE 4829HANDLER_COMMIT 1 4830HANDLER_EXTERNAL_LOCK 2 4831HANDLER_READ_FIRST 2 4832HANDLER_READ_KEY 2 4833HANDLER_READ_RND_NEXT 4 4834HANDLER_WRITE 17 4835SELECT @x, @y; 4836@x @y 4837Five Five 4838# 4839# LOAD DATA is not supported by WL#4443 !!! 4840# 4841FLUSH STATUS; 4842SELECT * FROM t1 WHERE a IN (1, 4) 4843INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1.part1'; 4844SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4845WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4846VARIABLE_NAME VARIABLE_VALUE 4847HANDLER_COMMIT 1 4848HANDLER_EXTERNAL_LOCK 2 4849HANDLER_READ_FIRST 1 4850HANDLER_READ_KEY 1 4851HANDLER_READ_RND_NEXT 2 4852HANDLER_WRITE 17 4853DELETE FROM t1 WHERE a IN (1, 4); 4854SELECT * FROM t1 ORDER BY a, b; 4855a b 48560 Zero 48572 Two 48583 Three 48595 Five 48606 Six 4861FLUSH STATUS; 4862LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.part1' INTO TABLE t1; 4863SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4864WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4865VARIABLE_NAME VARIABLE_VALUE 4866HANDLER_COMMIT 1 4867HANDLER_EXTERNAL_LOCK 2 4868HANDLER_WRITE 19 4869SELECT * FROM t1 ORDER BY a, b; 4870a b 48710 Zero 48721 One 48732 Two 48743 Three 48754 Four 48765 Five 48776 Six 4878DELETE FROM t1 WHERE a IN (1, 4); 4879SELECT * FROM t1 ORDER BY a, b; 4880a b 48810 Zero 48822 Two 48833 Three 48845 Five 48856 Six 4886# It is possible to avoid locking with explicit partitioning selection! 4887FLUSH STATUS; 4888LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.part1' INTO TABLE t1 PARTITION(p1); 4889SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4890WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4891VARIABLE_NAME VARIABLE_VALUE 4892HANDLER_COMMIT 1 4893HANDLER_EXTERNAL_LOCK 2 4894HANDLER_WRITE 19 4895SELECT * FROM t1 ORDER BY a, b; 4896a b 48970 Zero 48981 One 48992 Two 49003 Three 49014 Four 49025 Five 49036 Six 4904DROP TABLE t1; 4905# 4906# Test EXCHANGE PARTITION to only lock exchanged partition 4907# 4908CREATE TABLE t1 (a INT, b VARCHAR(44)); 4909CREATE TABLE t2 (a INT, b VARCHAR(44)) 4910PARTITION BY HASH (a) PARTITIONS 3; 4911INSERT INTO t1 VALUES (10, "Ten"), (13, "Thirteen"), (16, "Sixteen"); 4912INSERT INTO t2 VALUES (0, "Zero"), (1, "One"), (2, "Two"), 4913(3, "Three"), (4, "Four"), (5, "Five"), 4914(6, "Six"), (7, "Seven"), (8, "Eight"); 4915FLUSH STATUS; 4916ALTER TABLE t2 EXCHANGE PARTITION p1 WITH TABLE t1; 4917SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4918WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4919VARIABLE_NAME VARIABLE_VALUE 4920HANDLER_COMMIT 1 4921HANDLER_EXTERNAL_LOCK 4 4922HANDLER_READ_FIRST 1 4923HANDLER_READ_KEY 1 4924HANDLER_READ_RND_NEXT 4 4925HANDLER_WRITE 17 4926SELECT * FROM t1 ORDER BY a; 4927a b 49281 One 49294 Four 49307 Seven 4931SELECT * FROM t2 ORDER BY a; 4932a b 49330 Zero 49342 Two 49353 Three 49365 Five 49376 Six 49388 Eight 493910 Ten 494013 Thirteen 494116 Sixteen 4942DROP TABLE t1, t2; 4943# 4944# Prepared statement 4945# 4946CREATE TABLE t1 (N int, M tinyint) 4947PARTITION BY HASH (N) PARTITIONS 3; 4948INSERT INTO t1 VALUES (1,0),(1,0),(2,0),(2,0),(3,0); 4949PREPARE stmt FROM 'UPDATE t1 AS P1 INNER JOIN (SELECT N FROM t1 GROUP BY N HAVING COUNT(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2'; 4950FLUSH STATUS; 4951EXECUTE stmt; 4952SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4953WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4954VARIABLE_NAME VARIABLE_VALUE 4955HANDLER_COMMIT 1 4956HANDLER_EXTERNAL_LOCK 4 4957HANDLER_READ_FIRST 6 4958HANDLER_READ_KEY 16 4959HANDLER_READ_NEXT 4 4960HANDLER_READ_RND 2 4961HANDLER_READ_RND_NEXT 14 4962HANDLER_UPDATE 6 4963HANDLER_WRITE 22 4964SELECT * FROM t1 ORDER BY N, M; 4965N M 49661 2 49671 2 49682 2 49692 2 49703 0 4971DEALLOCATE PREPARE stmt; 4972PREPARE stmt FROM 'SELECT * FROM t1 WHERE N = 2'; 4973FLUSH STATUS; 4974EXECUTE stmt; 4975N M 49762 2 49772 2 4978SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 4979WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 4980VARIABLE_NAME VARIABLE_VALUE 4981HANDLER_COMMIT 1 4982HANDLER_EXTERNAL_LOCK 2 4983HANDLER_READ_FIRST 1 4984HANDLER_READ_KEY 1 4985HANDLER_READ_RND_NEXT 2 4986HANDLER_WRITE 17 4987DROP TABLE t1; 4988# Check if we can infer from condition on partition fields that 4989# no records will match. 4990CREATE TABLE t1 ( a int NOT NULL) PARTITION BY HASH(a) PARTITIONS 2; 4991INSERT INTO t1 VALUES (1),(2),(3); 4992FLUSH STATUS; 4993EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a=5 AND a=6; 4994id select_type table partitions type possible_keys key key_len ref rows filtered Extra 49951 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 4996Warnings: 4997Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 4998Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0 4999SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5000WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5001VARIABLE_NAME VARIABLE_VALUE 5002HANDLER_EXTERNAL_LOCK 2 5003HANDLER_WRITE 17 5004FLUSH STATUS; 5005SELECT * FROM t1 WHERE a=5 AND a=6; 5006a 5007SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5008WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5009VARIABLE_NAME VARIABLE_VALUE 5010HANDLER_EXTERNAL_LOCK 2 5011HANDLER_WRITE 17 5012DROP TABLE t1; 5013# 5014# Test of subqueries in INSERT 5015# 5016CREATE TABLE t1 (a INT, b VARCHAR(64)); 5017CREATE TABLE t2 (a INT, b VARCHAR(64)) PARTITION BY HASH (a) PARTITIONS 3; 5018INSERT INTO t1 VALUES (1, "test 1"); 5019INSERT INTO t2 VALUES (SELECT * FROM t1); 5020ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM t1)' at line 1 5021FLUSH STATUS; 5022INSERT INTO t2 VALUES ((SELECT a FROM t1), (SELECT b FROM t1)); 5023SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5024WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5025VARIABLE_NAME VARIABLE_VALUE 5026HANDLER_COMMIT 1 5027HANDLER_EXTERNAL_LOCK 6 5028HANDLER_READ_FIRST 2 5029HANDLER_READ_KEY 2 5030HANDLER_READ_RND_NEXT 4 5031HANDLER_WRITE 18 5032# I.e. No lock pruning possible 5033FLUSH STATUS; 5034INSERT INTO t2 VALUES (1 + (SELECT a FROM t1), 5035CONCAT("subq: ", (SELECT b FROM t1))); 5036SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5037WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5038VARIABLE_NAME VARIABLE_VALUE 5039HANDLER_COMMIT 1 5040HANDLER_EXTERNAL_LOCK 6 5041HANDLER_READ_FIRST 2 5042HANDLER_READ_KEY 2 5043HANDLER_READ_RND_NEXT 4 5044HANDLER_WRITE 18 5045# I.e. No lock pruning possible 5046SELECT * FROM t2; 5047a b 50481 test 1 50492 subq: test 1 5050DROP TABLE t1, t2; 5051CREATE TABLE t1 (a INT, b INT) PARTITION BY HASH (a) PARTITIONS 3; 5052CREATE TABLE t2 (a INT, b INT) PARTITION BY HASH (a) PARTITIONS 3; 5053INSERT INTO t1 VALUES (1, 1), (2, 0), (4, -1), (5, 2), (7, -3), (8, -9), 5054(10, 5), (11, 9); 5055FLUSH STATUS; 5056INSERT INTO t2 VALUES ((SELECT max(a) FROM t1), (SELECT min(a) FROM t1)); 5057SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5058WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5059VARIABLE_NAME VARIABLE_VALUE 5060HANDLER_COMMIT 1 5061HANDLER_EXTERNAL_LOCK 6 5062HANDLER_READ_FIRST 6 5063HANDLER_READ_KEY 6 5064HANDLER_READ_RND_NEXT 16 5065HANDLER_WRITE 18 5066# I.e. No lock pruning possible 5067FLUSH STATUS; 5068EXPLAIN PARTITIONS INSERT INTO t2 VALUES ((SELECT max(a) FROM t1), 5069(SELECT min(a) FROM t1)); 5070id select_type table partitions type possible_keys key key_len ref rows filtered Extra 50711 INSERT t2 p0,p1,p2 ALL NULL NULL NULL NULL # NULL NULL 50723 SUBQUERY t1 p0,p1,p2 ALL NULL NULL NULL NULL # 100.00 NULL 50732 SUBQUERY t1 p0,p1,p2 ALL NULL NULL NULL NULL # 100.00 NULL 5074Warnings: 5075Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5076SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5077WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5078VARIABLE_NAME VARIABLE_VALUE 5079HANDLER_COMMIT 1 5080HANDLER_EXTERNAL_LOCK 6 5081HANDLER_WRITE 17 5082# I.e. No lock pruning possible 5083FLUSH STATUS; 5084INSERT INTO t2 VALUES ((SELECT a FROM t1 WHERE a = 1), 5085(SELECT b FROM t1 WHERE a = 2)); 5086SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5087WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5088VARIABLE_NAME VARIABLE_VALUE 5089HANDLER_COMMIT 1 5090HANDLER_EXTERNAL_LOCK 6 5091HANDLER_READ_FIRST 2 5092HANDLER_READ_KEY 2 5093HANDLER_READ_RND_NEXT 8 5094HANDLER_WRITE 18 5095# I.e. No lock pruning possible on insert table 5096FLUSH STATUS; 5097EXPLAIN PARTITIONS INSERT INTO t2 VALUES ((SELECT a FROM t1 WHERE a = 1), 5098(SELECT b FROM t1 WHERE a = 2)); 5099id select_type table partitions type possible_keys key key_len ref rows filtered Extra 51001 INSERT t2 p0,p1,p2 ALL NULL NULL NULL NULL # NULL NULL 51013 SUBQUERY t1 p2 ALL NULL NULL NULL NULL # 25.00 Using where 51022 SUBQUERY t1 p1 ALL NULL NULL NULL NULL # 25.00 Using where 5103Warnings: 5104Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5105SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5106WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5107VARIABLE_NAME VARIABLE_VALUE 5108HANDLER_COMMIT 1 5109HANDLER_EXTERNAL_LOCK 6 5110HANDLER_WRITE 17 5111# I.e. No lock pruning possible on insert table 5112SELECT * FROM t2 ORDER BY a, b; 5113a b 51141 0 511511 1 5116DROP TABLE t1; 5117DROP TABLE t2; 5118# 5119# Test of InnoDB INSERT TABLE with non existing table in trigger 5120# 5121CREATE TABLE t1 (a INT) 5122ENGINE = InnoDB; 5123# Create a table to be used in a trigger on t1 5124CREATE TABLE t2 (a INT) 5125ENGINE = InnoDB; 5126# Create a trigger on t1 which uses t2 5127CREATE TRIGGER tr1_1_N BEFORE INSERT ON t1 5128FOR EACH ROW BEGIN 5129UPDATE t2 SET a = 8 WHERE a > 3 LIMIT 0; 5130END// 5131# Drop t2 to cause a failure when inserting into t1 5132DROP TABLE t2; 5133INSERT INTO t1 VALUES (1); 5134ERROR 42S02: Table 'test.t2' doesn't exist 5135DROP TABLE t1; 5136CREATE TABLE t1 (a INT) PARTITION BY HASH (a) PARTITIONS 3; 5137INSERT INTO t1 VALUES (1), (3), (9), (2), (8), (7); 5138FLUSH STATUS; 5139CREATE TABLE t2 SELECT * FROM t1 PARTITION (p1, p2); 5140SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5141WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5142VARIABLE_NAME VARIABLE_VALUE 5143HANDLER_COMMIT 1 5144HANDLER_EXTERNAL_LOCK 4 5145HANDLER_READ_FIRST 2 5146HANDLER_READ_KEY 2 5147HANDLER_READ_RND_NEXT 4 5148HANDLER_WRITE 21 5149SELECT * FROM t2; 5150a 51511 51522 51537 51548 5155DROP TABLE t2; 5156FLUSH STATUS; 5157CREATE TABLE t2 SELECT * FROM t1 WHERE a IN (1, 3, 9); 5158SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5159WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5160VARIABLE_NAME VARIABLE_VALUE 5161HANDLER_COMMIT 1 5162HANDLER_EXTERNAL_LOCK 4 5163HANDLER_READ_FIRST 2 5164HANDLER_READ_KEY 2 5165HANDLER_READ_RND_NEXT 4 5166HANDLER_WRITE 20 5167SELECT * FROM t2; 5168a 51691 51703 51719 5172DROP TABLE t1, t2; 5173# 5174# Test subqueries/stored functions with UPDATE/DELETE/SELECT 5175# 5176CREATE TABLE tq (id int PRIMARY KEY auto_increment, query varchar(255), not_select tinyint); 5177CREATE TABLE tsq (id int PRIMARY KEY auto_increment, subquery varchar(255), can_be_locked tinyint); 5178CREATE TABLE t1 (a int, b varchar(255), PRIMARY KEY (a), KEY (b)) 5179ENGINE = InnoDB 5180PARTITION BY HASH (a) PARTITIONS 3; 5181CREATE TABLE t2 (a int, b varchar(255), PRIMARY KEY (a), KEY (b)) 5182ENGINE = InnoDB 5183PARTITION BY HASH (a) PARTITIONS 3; 5184START TRANSACTION; 5185INSERT INTO t1 VALUES (1, "1"); 5186INSERT INTO t1 VALUES (2, "2"); 5187INSERT INTO t1 VALUES (8, "8"); 5188INSERT INTO t2 VALUES (1, "1"); 5189INSERT INTO t2 VALUES (2, "2"); 5190INSERT INTO t2 VALUES (8, "8"); 5191CREATE FUNCTION sf_add_hello(s VARCHAR(240)) 5192RETURNS VARCHAR(246) DETERMINISTIC 5193RETURN CONCAT('hello ', s); 5194CREATE FUNCTION sf_add_1(i INT) 5195RETURNS INT DETERMINISTIC 5196RETURN i + 1; 5197CREATE FUNCTION sf_a_from_t1b_d(s varchar(128)) 5198RETURNS INT DETERMINISTIC 5199BEGIN 5200DECLARE i INT; 5201SELECT a INTO i FROM t1 where b = s; 5202RETURN i; 5203END| 5204CREATE FUNCTION sf_a_from_t1b(s varchar(128)) 5205RETURNS INT 5206BEGIN 5207DECLARE i INT; 5208SELECT a INTO i FROM t1 where b = s; 5209RETURN i; 5210END| 5211INSERT INTO tq (query, not_select) VALUES 5212("SELECT * FROM t2", 0), 5213("SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2", 0), 5214("UPDATE t2 SET b = CONCAT('+', b)", 1), 5215("UPDATE t2 SET b = sf_add_hello(b)", 1), 5216("UPDATE t2 SET a = sf_add_1(a) + 4", 1), 5217("DELETE FROM t2", 1); 5218INSERT INTO tsq (subquery, can_be_locked) VALUES 5219("(SELECT a FROM t1 WHERE b = '1')", 1), 5220("7 + (SELECT a FROM t1 WHERE b = '1')", 1), 5221("sf_a_from_t1b('1')", 1), 5222("sf_a_from_t1b_d('1')", 1), 5223("7 + sf_a_from_t1b('1')", 1), 5224("7 + sf_a_from_t1b_d('1')", 1), 5225("sf_a_from_t1b('1') AND a = 2", 1), 5226("sf_a_from_t1b_d('1') AND a = 2", 1), 5227("(SELECT a FROM t1 WHERE b = '1') AND a = 2", 1), 5228("(SELECT a FROM t1 WHERE b = '1') OR a = 2", 1), 5229("(SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2')", 0); 5230set @old_autocommit= @@autocommit; 5231EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5232id select_type table partitions type possible_keys key key_len ref rows filtered Extra 52331 PRIMARY t2 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 52342 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5235Warnings: 5236Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5237Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b` from `test`.`t2` where 1 5238FLUSH STATUS; 5239START TRANSACTION; 5240SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5241a b 52421 1 5243SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5244WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5245VARIABLE_NAME VARIABLE_VALUE 5246HANDLER_COMMIT 1 5247HANDLER_EXTERNAL_LOCK 4 5248HANDLER_READ_KEY 4 5249HANDLER_READ_NEXT 1 5250HANDLER_WRITE 17 5251FLUSH STATUS; 5252SET autocommit = 0; 5253LOCK TABLES t1 read, t2 write; 5254SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5255a b 52561 1 5257SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5258WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5259VARIABLE_NAME VARIABLE_VALUE 5260HANDLER_COMMIT 2 5261HANDLER_EXTERNAL_LOCK 2 5262HANDLER_READ_KEY 4 5263HANDLER_READ_NEXT 1 5264HANDLER_WRITE 17 5265UNLOCK TABLES; 5266EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5267id select_type table partitions type possible_keys key key_len ref rows filtered Extra 52681 PRIMARY t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 52692 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5270Warnings: 5271Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5272Note 1003 /* select#1 */ select '8' AS `a`,'8' AS `b` from `test`.`t2` where ('8' = (7 + (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` = '1')))) 5273FLUSH STATUS; 5274START TRANSACTION; 5275SELECT * FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5276a b 52778 8 5278SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5279WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5280VARIABLE_NAME VARIABLE_VALUE 5281HANDLER_COMMIT 1 5282HANDLER_EXTERNAL_LOCK 4 5283HANDLER_READ_KEY 4 5284HANDLER_READ_NEXT 1 5285HANDLER_WRITE 17 5286FLUSH STATUS; 5287SET autocommit = 0; 5288LOCK TABLES t1 read, t2 write; 5289SELECT * FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5290a b 52918 8 5292SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5293WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5294VARIABLE_NAME VARIABLE_VALUE 5295HANDLER_COMMIT 2 5296HANDLER_EXTERNAL_LOCK 2 5297HANDLER_READ_KEY 4 5298HANDLER_READ_NEXT 1 5299HANDLER_WRITE 17 5300UNLOCK TABLES; 5301EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = sf_a_from_t1b('1'); 5302id select_type table partitions type possible_keys key key_len ref rows filtered Extra 53031 SIMPLE t2 p0,p1,p2 index NULL b 258 NULL # 33.33 Using where; Using index 5304Warnings: 5305Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5306Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` = `sf_a_from_t1b`('1')) 5307FLUSH STATUS; 5308START TRANSACTION; 5309SELECT * FROM t2 WHERE a = sf_a_from_t1b('1'); 5310a b 53111 1 5312SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5313WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5314VARIABLE_NAME VARIABLE_VALUE 5315HANDLER_COMMIT 1 5316HANDLER_EXTERNAL_LOCK 4 5317HANDLER_READ_FIRST 3 5318HANDLER_READ_KEY 12 5319HANDLER_READ_NEXT 6 5320HANDLER_WRITE 17 5321FLUSH STATUS; 5322SET autocommit = 0; 5323LOCK TABLES t1 read, t2 write; 5324SELECT * FROM t2 WHERE a = sf_a_from_t1b('1'); 5325a b 53261 1 5327SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5328WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5329VARIABLE_NAME VARIABLE_VALUE 5330HANDLER_COMMIT 2 5331HANDLER_EXTERNAL_LOCK 2 5332HANDLER_READ_FIRST 3 5333HANDLER_READ_KEY 12 5334HANDLER_READ_NEXT 6 5335HANDLER_WRITE 17 5336UNLOCK TABLES; 5337EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5338id select_type table partitions type possible_keys key key_len ref rows filtered Extra 53391 SIMPLE t2 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 5340Warnings: 5341Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5342Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b` from `test`.`t2` where 1 5343FLUSH STATUS; 5344START TRANSACTION; 5345SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5346a b 53471 1 5348SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5349WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5350VARIABLE_NAME VARIABLE_VALUE 5351HANDLER_COMMIT 1 5352HANDLER_EXTERNAL_LOCK 4 5353HANDLER_READ_KEY 10 5354HANDLER_READ_NEXT 3 5355HANDLER_WRITE 17 5356FLUSH STATUS; 5357SET autocommit = 0; 5358LOCK TABLES t1 read, t2 write; 5359SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5360a b 53611 1 5362SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5363WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5364VARIABLE_NAME VARIABLE_VALUE 5365HANDLER_COMMIT 2 5366HANDLER_EXTERNAL_LOCK 2 5367HANDLER_READ_KEY 10 5368HANDLER_READ_NEXT 3 5369HANDLER_WRITE 17 5370UNLOCK TABLES; 5371EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5372id select_type table partitions type possible_keys key key_len ref rows filtered Extra 53731 SIMPLE t2 p0,p1,p2 index NULL b 258 NULL # 33.33 Using where; Using index 5374Warnings: 5375Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5376Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`a` = (7 + `sf_a_from_t1b`('1'))) 5377FLUSH STATUS; 5378START TRANSACTION; 5379SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5380a b 53818 8 5382SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5383WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5384VARIABLE_NAME VARIABLE_VALUE 5385HANDLER_COMMIT 1 5386HANDLER_EXTERNAL_LOCK 4 5387HANDLER_READ_FIRST 3 5388HANDLER_READ_KEY 12 5389HANDLER_READ_NEXT 6 5390HANDLER_WRITE 17 5391FLUSH STATUS; 5392SET autocommit = 0; 5393LOCK TABLES t1 read, t2 write; 5394SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5395a b 53968 8 5397SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5398WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5399VARIABLE_NAME VARIABLE_VALUE 5400HANDLER_COMMIT 2 5401HANDLER_EXTERNAL_LOCK 2 5402HANDLER_READ_FIRST 3 5403HANDLER_READ_KEY 12 5404HANDLER_READ_NEXT 6 5405HANDLER_WRITE 17 5406UNLOCK TABLES; 5407EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5408id select_type table partitions type possible_keys key key_len ref rows filtered Extra 54091 SIMPLE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 5410Warnings: 5411Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5412Note 1003 /* select#1 */ select '8' AS `a`,'8' AS `b` from `test`.`t2` where ('8' = (7 + `sf_a_from_t1b_d`('1'))) 5413FLUSH STATUS; 5414START TRANSACTION; 5415SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5416a b 54178 8 5418SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5419WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5420VARIABLE_NAME VARIABLE_VALUE 5421HANDLER_COMMIT 1 5422HANDLER_EXTERNAL_LOCK 4 5423HANDLER_READ_KEY 10 5424HANDLER_READ_NEXT 3 5425HANDLER_WRITE 17 5426FLUSH STATUS; 5427SET autocommit = 0; 5428LOCK TABLES t1 read, t2 write; 5429SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5430a b 54318 8 5432SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5433WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5434VARIABLE_NAME VARIABLE_VALUE 5435HANDLER_COMMIT 2 5436HANDLER_EXTERNAL_LOCK 2 5437HANDLER_READ_KEY 10 5438HANDLER_READ_NEXT 3 5439HANDLER_WRITE 17 5440UNLOCK TABLES; 5441EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5442id select_type table partitions type possible_keys key key_len ref rows filtered Extra 54431 SIMPLE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 5444Warnings: 5445Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5446Note 1003 /* select#1 */ select '2' AS `a`,'2' AS `b` from `test`.`t2` where ((2 = `sf_a_from_t1b`('1'))) 5447FLUSH STATUS; 5448START TRANSACTION; 5449SELECT * FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5450a b 5451SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5452WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5453VARIABLE_NAME VARIABLE_VALUE 5454HANDLER_COMMIT 1 5455HANDLER_EXTERNAL_LOCK 4 5456HANDLER_READ_KEY 4 5457HANDLER_READ_NEXT 1 5458HANDLER_WRITE 17 5459FLUSH STATUS; 5460SET autocommit = 0; 5461LOCK TABLES t1 read, t2 write; 5462SELECT * FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5463a b 5464SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5465WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5466VARIABLE_NAME VARIABLE_VALUE 5467HANDLER_COMMIT 2 5468HANDLER_EXTERNAL_LOCK 2 5469HANDLER_READ_KEY 4 5470HANDLER_READ_NEXT 1 5471HANDLER_WRITE 17 5472UNLOCK TABLES; 5473EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5474id select_type table partitions type possible_keys key key_len ref rows filtered Extra 54751 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 5476Warnings: 5477Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5478Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where 0 5479FLUSH STATUS; 5480START TRANSACTION; 5481SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5482a b 5483SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5484WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5485VARIABLE_NAME VARIABLE_VALUE 5486HANDLER_COMMIT 1 5487HANDLER_EXTERNAL_LOCK 4 5488HANDLER_READ_KEY 3 5489HANDLER_READ_NEXT 1 5490HANDLER_WRITE 17 5491FLUSH STATUS; 5492SET autocommit = 0; 5493LOCK TABLES t1 read, t2 write; 5494SELECT * FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5495a b 5496SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5497WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5498VARIABLE_NAME VARIABLE_VALUE 5499HANDLER_COMMIT 2 5500HANDLER_EXTERNAL_LOCK 2 5501HANDLER_READ_KEY 3 5502HANDLER_READ_NEXT 1 5503HANDLER_WRITE 17 5504UNLOCK TABLES; 5505EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5506id select_type table partitions type possible_keys key key_len ref rows filtered Extra 55071 PRIMARY NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 55082 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5509Warnings: 5510Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5511Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where 0 5512FLUSH STATUS; 5513START TRANSACTION; 5514SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5515a b 5516SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5517WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5518VARIABLE_NAME VARIABLE_VALUE 5519HANDLER_COMMIT 1 5520HANDLER_EXTERNAL_LOCK 4 5521HANDLER_READ_KEY 3 5522HANDLER_READ_NEXT 1 5523HANDLER_WRITE 17 5524FLUSH STATUS; 5525SET autocommit = 0; 5526LOCK TABLES t1 read, t2 write; 5527SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5528a b 5529SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5530WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5531VARIABLE_NAME VARIABLE_VALUE 5532HANDLER_COMMIT 2 5533HANDLER_EXTERNAL_LOCK 2 5534HANDLER_READ_KEY 3 5535HANDLER_READ_NEXT 1 5536HANDLER_WRITE 17 5537UNLOCK TABLES; 5538EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5539id select_type table partitions type possible_keys key key_len ref rows filtered Extra 55401 PRIMARY t2 p1,p2 index PRIMARY b 258 NULL # 66.67 Using where; Using index 55412 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5542Warnings: 5543Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5544Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`a` = (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` = '1'))) or (`test`.`t2`.`a` = 2)) 5545FLUSH STATUS; 5546START TRANSACTION; 5547SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5548a b 55491 1 55502 2 5551SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5552WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5553VARIABLE_NAME VARIABLE_VALUE 5554HANDLER_COMMIT 1 5555HANDLER_EXTERNAL_LOCK 4 5556HANDLER_READ_FIRST 2 5557HANDLER_READ_KEY 5 5558HANDLER_READ_NEXT 4 5559HANDLER_WRITE 17 5560FLUSH STATUS; 5561SET autocommit = 0; 5562LOCK TABLES t1 read, t2 write; 5563SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5564a b 55651 1 55662 2 5567SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5568WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5569VARIABLE_NAME VARIABLE_VALUE 5570HANDLER_COMMIT 2 5571HANDLER_EXTERNAL_LOCK 2 5572HANDLER_READ_FIRST 2 5573HANDLER_READ_KEY 5 5574HANDLER_READ_NEXT 4 5575HANDLER_WRITE 17 5576UNLOCK TABLES; 5577EXPLAIN PARTITIONS SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 5578id select_type table partitions type possible_keys key key_len ref rows filtered Extra 55791 PRIMARY t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 55802 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5581Warnings: 5582Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5583Note 1003 /* select#1 */ select '8' AS `a`,'8' AS `b` from `test`.`t2` where (`sf_a_from_t1b`('2')) 5584FLUSH STATUS; 5585START TRANSACTION; 5586SELECT * FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 5587a b 55888 8 5589SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5590WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5591VARIABLE_NAME VARIABLE_VALUE 5592HANDLER_COMMIT 1 5593HANDLER_EXTERNAL_LOCK 6 5594HANDLER_READ_KEY 7 5595HANDLER_READ_NEXT 2 5596HANDLER_WRITE 17 5597EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5598id select_type table partitions type possible_keys key key_len ref rows filtered Extra 55991 PRIMARY t2 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 56002 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5601Warnings: 5602Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5603Note 1003 /* select#1 */ select (`sf_add_1`('1') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('1') AS `sf_add_hello(b)` from `test`.`t2` where 1 5604FLUSH STATUS; 5605START TRANSACTION; 5606SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5607sf_add_1(a) - 1 sf_add_hello(b) 56081 hello 1 5609SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5610WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5611VARIABLE_NAME VARIABLE_VALUE 5612HANDLER_COMMIT 1 5613HANDLER_EXTERNAL_LOCK 4 5614HANDLER_READ_KEY 4 5615HANDLER_READ_NEXT 1 5616HANDLER_WRITE 17 5617FLUSH STATUS; 5618SET autocommit = 0; 5619LOCK TABLES t1 read, t2 write; 5620SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5621sf_add_1(a) - 1 sf_add_hello(b) 56221 hello 1 5623SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5624WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5625VARIABLE_NAME VARIABLE_VALUE 5626HANDLER_COMMIT 2 5627HANDLER_EXTERNAL_LOCK 2 5628HANDLER_READ_KEY 4 5629HANDLER_READ_NEXT 1 5630HANDLER_WRITE 17 5631UNLOCK TABLES; 5632EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5633id select_type table partitions type possible_keys key key_len ref rows filtered Extra 56341 PRIMARY t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 56352 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5636Warnings: 5637Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5638Note 1003 /* select#1 */ select (`sf_add_1`('8') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('8') AS `sf_add_hello(b)` from `test`.`t2` where ('8' = (7 + (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` = '1')))) 5639FLUSH STATUS; 5640START TRANSACTION; 5641SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5642sf_add_1(a) - 1 sf_add_hello(b) 56438 hello 8 5644SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5645WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5646VARIABLE_NAME VARIABLE_VALUE 5647HANDLER_COMMIT 1 5648HANDLER_EXTERNAL_LOCK 4 5649HANDLER_READ_KEY 4 5650HANDLER_READ_NEXT 1 5651HANDLER_WRITE 17 5652FLUSH STATUS; 5653SET autocommit = 0; 5654LOCK TABLES t1 read, t2 write; 5655SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 5656sf_add_1(a) - 1 sf_add_hello(b) 56578 hello 8 5658SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5659WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5660VARIABLE_NAME VARIABLE_VALUE 5661HANDLER_COMMIT 2 5662HANDLER_EXTERNAL_LOCK 2 5663HANDLER_READ_KEY 4 5664HANDLER_READ_NEXT 1 5665HANDLER_WRITE 17 5666UNLOCK TABLES; 5667EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1'); 5668id select_type table partitions type possible_keys key key_len ref rows filtered Extra 56691 SIMPLE t2 p0,p1,p2 index NULL b 258 NULL # 33.33 Using where; Using index 5670Warnings: 5671Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5672Note 1003 /* select#1 */ select (`sf_add_1`(`test`.`t2`.`a`) - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`(`test`.`t2`.`b`) AS `sf_add_hello(b)` from `test`.`t2` where (`test`.`t2`.`a` = `sf_a_from_t1b`('1')) 5673FLUSH STATUS; 5674START TRANSACTION; 5675SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1'); 5676sf_add_1(a) - 1 sf_add_hello(b) 56771 hello 1 5678SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5679WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5680VARIABLE_NAME VARIABLE_VALUE 5681HANDLER_COMMIT 1 5682HANDLER_EXTERNAL_LOCK 4 5683HANDLER_READ_FIRST 3 5684HANDLER_READ_KEY 12 5685HANDLER_READ_NEXT 6 5686HANDLER_WRITE 17 5687FLUSH STATUS; 5688SET autocommit = 0; 5689LOCK TABLES t1 read, t2 write; 5690SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1'); 5691sf_add_1(a) - 1 sf_add_hello(b) 56921 hello 1 5693SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5694WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5695VARIABLE_NAME VARIABLE_VALUE 5696HANDLER_COMMIT 2 5697HANDLER_EXTERNAL_LOCK 2 5698HANDLER_READ_FIRST 3 5699HANDLER_READ_KEY 12 5700HANDLER_READ_NEXT 6 5701HANDLER_WRITE 17 5702UNLOCK TABLES; 5703EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5704id select_type table partitions type possible_keys key key_len ref rows filtered Extra 57051 SIMPLE t2 p1 const PRIMARY PRIMARY 4 const # 100.00 NULL 5706Warnings: 5707Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5708Note 1003 /* select#1 */ select (`sf_add_1`('1') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('1') AS `sf_add_hello(b)` from `test`.`t2` where 1 5709FLUSH STATUS; 5710START TRANSACTION; 5711SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5712sf_add_1(a) - 1 sf_add_hello(b) 57131 hello 1 5714SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5715WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5716VARIABLE_NAME VARIABLE_VALUE 5717HANDLER_COMMIT 1 5718HANDLER_EXTERNAL_LOCK 4 5719HANDLER_READ_KEY 10 5720HANDLER_READ_NEXT 3 5721HANDLER_WRITE 17 5722FLUSH STATUS; 5723SET autocommit = 0; 5724LOCK TABLES t1 read, t2 write; 5725SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1'); 5726sf_add_1(a) - 1 sf_add_hello(b) 57271 hello 1 5728SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5729WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5730VARIABLE_NAME VARIABLE_VALUE 5731HANDLER_COMMIT 2 5732HANDLER_EXTERNAL_LOCK 2 5733HANDLER_READ_KEY 10 5734HANDLER_READ_NEXT 3 5735HANDLER_WRITE 17 5736UNLOCK TABLES; 5737EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5738id select_type table partitions type possible_keys key key_len ref rows filtered Extra 57391 SIMPLE t2 p0,p1,p2 index NULL b 258 NULL # 33.33 Using where; Using index 5740Warnings: 5741Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5742Note 1003 /* select#1 */ select (`sf_add_1`(`test`.`t2`.`a`) - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`(`test`.`t2`.`b`) AS `sf_add_hello(b)` from `test`.`t2` where (`test`.`t2`.`a` = (7 + `sf_a_from_t1b`('1'))) 5743FLUSH STATUS; 5744START TRANSACTION; 5745SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5746sf_add_1(a) - 1 sf_add_hello(b) 57478 hello 8 5748SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5749WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5750VARIABLE_NAME VARIABLE_VALUE 5751HANDLER_COMMIT 1 5752HANDLER_EXTERNAL_LOCK 4 5753HANDLER_READ_FIRST 3 5754HANDLER_READ_KEY 12 5755HANDLER_READ_NEXT 6 5756HANDLER_WRITE 17 5757FLUSH STATUS; 5758SET autocommit = 0; 5759LOCK TABLES t1 read, t2 write; 5760SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 5761sf_add_1(a) - 1 sf_add_hello(b) 57628 hello 8 5763SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5764WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5765VARIABLE_NAME VARIABLE_VALUE 5766HANDLER_COMMIT 2 5767HANDLER_EXTERNAL_LOCK 2 5768HANDLER_READ_FIRST 3 5769HANDLER_READ_KEY 12 5770HANDLER_READ_NEXT 6 5771HANDLER_WRITE 17 5772UNLOCK TABLES; 5773EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5774id select_type table partitions type possible_keys key key_len ref rows filtered Extra 57751 SIMPLE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 5776Warnings: 5777Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5778Note 1003 /* select#1 */ select (`sf_add_1`('8') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('8') AS `sf_add_hello(b)` from `test`.`t2` where ('8' = (7 + `sf_a_from_t1b_d`('1'))) 5779FLUSH STATUS; 5780START TRANSACTION; 5781SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5782sf_add_1(a) - 1 sf_add_hello(b) 57838 hello 8 5784SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5785WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5786VARIABLE_NAME VARIABLE_VALUE 5787HANDLER_COMMIT 1 5788HANDLER_EXTERNAL_LOCK 4 5789HANDLER_READ_KEY 10 5790HANDLER_READ_NEXT 3 5791HANDLER_WRITE 17 5792FLUSH STATUS; 5793SET autocommit = 0; 5794LOCK TABLES t1 read, t2 write; 5795SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 5796sf_add_1(a) - 1 sf_add_hello(b) 57978 hello 8 5798SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5799WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5800VARIABLE_NAME VARIABLE_VALUE 5801HANDLER_COMMIT 2 5802HANDLER_EXTERNAL_LOCK 2 5803HANDLER_READ_KEY 10 5804HANDLER_READ_NEXT 3 5805HANDLER_WRITE 17 5806UNLOCK TABLES; 5807EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5808id select_type table partitions type possible_keys key key_len ref rows filtered Extra 58091 SIMPLE t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 5810Warnings: 5811Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5812Note 1003 /* select#1 */ select (`sf_add_1`('2') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('2') AS `sf_add_hello(b)` from `test`.`t2` where ((2 = `sf_a_from_t1b`('1'))) 5813FLUSH STATUS; 5814START TRANSACTION; 5815SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5816sf_add_1(a) - 1 sf_add_hello(b) 5817SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5818WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5819VARIABLE_NAME VARIABLE_VALUE 5820HANDLER_COMMIT 1 5821HANDLER_EXTERNAL_LOCK 4 5822HANDLER_READ_KEY 4 5823HANDLER_READ_NEXT 1 5824HANDLER_WRITE 17 5825FLUSH STATUS; 5826SET autocommit = 0; 5827LOCK TABLES t1 read, t2 write; 5828SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 5829sf_add_1(a) - 1 sf_add_hello(b) 5830SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5831WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5832VARIABLE_NAME VARIABLE_VALUE 5833HANDLER_COMMIT 2 5834HANDLER_EXTERNAL_LOCK 2 5835HANDLER_READ_KEY 4 5836HANDLER_READ_NEXT 1 5837HANDLER_WRITE 17 5838UNLOCK TABLES; 5839EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5840id select_type table partitions type possible_keys key key_len ref rows filtered Extra 58411 SIMPLE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 5842Warnings: 5843Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5844Note 1003 /* select#1 */ select (`sf_add_1`(`test`.`t2`.`a`) - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`(`test`.`t2`.`b`) AS `sf_add_hello(b)` from `test`.`t2` where 0 5845FLUSH STATUS; 5846START TRANSACTION; 5847SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5848sf_add_1(a) - 1 sf_add_hello(b) 5849SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5850WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5851VARIABLE_NAME VARIABLE_VALUE 5852HANDLER_COMMIT 1 5853HANDLER_EXTERNAL_LOCK 4 5854HANDLER_READ_KEY 3 5855HANDLER_READ_NEXT 1 5856HANDLER_WRITE 17 5857FLUSH STATUS; 5858SET autocommit = 0; 5859LOCK TABLES t1 read, t2 write; 5860SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 5861sf_add_1(a) - 1 sf_add_hello(b) 5862SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5863WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5864VARIABLE_NAME VARIABLE_VALUE 5865HANDLER_COMMIT 2 5866HANDLER_EXTERNAL_LOCK 2 5867HANDLER_READ_KEY 3 5868HANDLER_READ_NEXT 1 5869HANDLER_WRITE 17 5870UNLOCK TABLES; 5871EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5872id select_type table partitions type possible_keys key key_len ref rows filtered Extra 58731 PRIMARY NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 58742 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5875Warnings: 5876Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5877Note 1003 /* select#1 */ select (`sf_add_1`(`test`.`t2`.`a`) - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`(`test`.`t2`.`b`) AS `sf_add_hello(b)` from `test`.`t2` where 0 5878FLUSH STATUS; 5879START TRANSACTION; 5880SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5881sf_add_1(a) - 1 sf_add_hello(b) 5882SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5883WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5884VARIABLE_NAME VARIABLE_VALUE 5885HANDLER_COMMIT 1 5886HANDLER_EXTERNAL_LOCK 4 5887HANDLER_READ_KEY 3 5888HANDLER_READ_NEXT 1 5889HANDLER_WRITE 17 5890FLUSH STATUS; 5891SET autocommit = 0; 5892LOCK TABLES t1 read, t2 write; 5893SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 5894sf_add_1(a) - 1 sf_add_hello(b) 5895SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5896WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5897VARIABLE_NAME VARIABLE_VALUE 5898HANDLER_COMMIT 2 5899HANDLER_EXTERNAL_LOCK 2 5900HANDLER_READ_KEY 3 5901HANDLER_READ_NEXT 1 5902HANDLER_WRITE 17 5903UNLOCK TABLES; 5904EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5905id select_type table partitions type possible_keys key key_len ref rows filtered Extra 59061 PRIMARY t2 p1,p2 index PRIMARY b 258 NULL # 66.67 Using where; Using index 59072 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5908Warnings: 5909Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5910Note 1003 /* select#1 */ select (`sf_add_1`(`test`.`t2`.`a`) - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`(`test`.`t2`.`b`) AS `sf_add_hello(b)` from `test`.`t2` where ((`test`.`t2`.`a` = (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` = '1'))) or (`test`.`t2`.`a` = 2)) 5911FLUSH STATUS; 5912START TRANSACTION; 5913SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5914sf_add_1(a) - 1 sf_add_hello(b) 59151 hello 1 59162 hello 2 5917SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5918WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5919VARIABLE_NAME VARIABLE_VALUE 5920HANDLER_COMMIT 1 5921HANDLER_EXTERNAL_LOCK 4 5922HANDLER_READ_FIRST 2 5923HANDLER_READ_KEY 5 5924HANDLER_READ_NEXT 4 5925HANDLER_WRITE 17 5926FLUSH STATUS; 5927SET autocommit = 0; 5928LOCK TABLES t1 read, t2 write; 5929SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 5930sf_add_1(a) - 1 sf_add_hello(b) 59311 hello 1 59322 hello 2 5933SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5934WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5935VARIABLE_NAME VARIABLE_VALUE 5936HANDLER_COMMIT 2 5937HANDLER_EXTERNAL_LOCK 2 5938HANDLER_READ_FIRST 2 5939HANDLER_READ_KEY 5 5940HANDLER_READ_NEXT 4 5941HANDLER_WRITE 17 5942UNLOCK TABLES; 5943EXPLAIN PARTITIONS SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 5944id select_type table partitions type possible_keys key key_len ref rows filtered Extra 59451 PRIMARY t2 p2 const PRIMARY PRIMARY 4 const # 100.00 NULL 59462 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5947Warnings: 5948Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5949Note 1003 /* select#1 */ select (`sf_add_1`('8') - 1) AS `sf_add_1(a) - 1`,`sf_add_hello`('8') AS `sf_add_hello(b)` from `test`.`t2` where (`sf_a_from_t1b`('2')) 5950FLUSH STATUS; 5951START TRANSACTION; 5952SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 5953sf_add_1(a) - 1 sf_add_hello(b) 59548 hello 8 5955SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5956WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5957VARIABLE_NAME VARIABLE_VALUE 5958HANDLER_COMMIT 1 5959HANDLER_EXTERNAL_LOCK 6 5960HANDLER_READ_KEY 7 5961HANDLER_READ_NEXT 2 5962HANDLER_WRITE 17 5963EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5964id select_type table partitions type possible_keys key key_len ref rows filtered Extra 59651 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 59662 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 5967Warnings: 5968Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 5969FLUSH STATUS; 5970START TRANSACTION; 5971UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5972SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5973WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5974VARIABLE_NAME VARIABLE_VALUE 5975HANDLER_COMMIT 1 5976HANDLER_EXTERNAL_LOCK 4 5977HANDLER_READ_KEY 4 5978HANDLER_READ_NEXT 1 5979HANDLER_UPDATE 1 5980HANDLER_WRITE 17 5981SELECT * FROM t2; 5982a b 59831 +1 59842 2 59858 8 5986ROLLBACK; 5987FLUSH STATUS; 5988SET autocommit = 0; 5989LOCK TABLES t1 read, t2 write; 5990UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 5991SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 5992WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 5993VARIABLE_NAME VARIABLE_VALUE 5994HANDLER_COMMIT 2 5995HANDLER_EXTERNAL_LOCK 2 5996HANDLER_READ_KEY 4 5997HANDLER_READ_NEXT 1 5998HANDLER_UPDATE 1 5999HANDLER_WRITE 17 6000SELECT * FROM t2; 6001a b 60021 +1 60032 2 60048 8 6005ROLLBACK; 6006UNLOCK TABLES; 6007EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6008id select_type table partitions type possible_keys key key_len ref rows filtered Extra 60091 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 60102 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6011Warnings: 6012Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6013FLUSH STATUS; 6014START TRANSACTION; 6015UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6016SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6017WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6018VARIABLE_NAME VARIABLE_VALUE 6019HANDLER_COMMIT 1 6020HANDLER_EXTERNAL_LOCK 4 6021HANDLER_READ_KEY 4 6022HANDLER_READ_NEXT 1 6023HANDLER_UPDATE 1 6024HANDLER_WRITE 17 6025SELECT * FROM t2; 6026a b 60271 1 60282 2 60298 +8 6030ROLLBACK; 6031FLUSH STATUS; 6032SET autocommit = 0; 6033LOCK TABLES t1 read, t2 write; 6034UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6035SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6036WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6037VARIABLE_NAME VARIABLE_VALUE 6038HANDLER_COMMIT 2 6039HANDLER_EXTERNAL_LOCK 2 6040HANDLER_READ_KEY 4 6041HANDLER_READ_NEXT 1 6042HANDLER_UPDATE 1 6043HANDLER_WRITE 17 6044SELECT * FROM t2; 6045a b 60461 1 60472 2 60488 +8 6049ROLLBACK; 6050UNLOCK TABLES; 6051EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1'); 6052id select_type table partitions type possible_keys key key_len ref rows filtered Extra 60531 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where 6054Warnings: 6055Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6056FLUSH STATUS; 6057START TRANSACTION; 6058UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1'); 6059SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6060WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6061VARIABLE_NAME VARIABLE_VALUE 6062HANDLER_COMMIT 1 6063HANDLER_EXTERNAL_LOCK 4 6064HANDLER_READ_FIRST 3 6065HANDLER_READ_KEY 12 6066HANDLER_READ_NEXT 3 6067HANDLER_READ_RND_NEXT 3 6068HANDLER_UPDATE 1 6069HANDLER_WRITE 17 6070SELECT * FROM t2; 6071a b 60721 +1 60732 2 60748 8 6075ROLLBACK; 6076FLUSH STATUS; 6077SET autocommit = 0; 6078LOCK TABLES t1 read, t2 write; 6079UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1'); 6080SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6081WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6082VARIABLE_NAME VARIABLE_VALUE 6083HANDLER_COMMIT 2 6084HANDLER_EXTERNAL_LOCK 2 6085HANDLER_READ_FIRST 3 6086HANDLER_READ_KEY 12 6087HANDLER_READ_NEXT 3 6088HANDLER_READ_RND_NEXT 3 6089HANDLER_UPDATE 1 6090HANDLER_WRITE 17 6091SELECT * FROM t2; 6092a b 60931 +1 60942 2 60958 8 6096ROLLBACK; 6097UNLOCK TABLES; 6098EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1'); 6099id select_type table partitions type possible_keys key key_len ref rows filtered Extra 61001 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 6101Warnings: 6102Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6103FLUSH STATUS; 6104START TRANSACTION; 6105UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1'); 6106SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6107WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6108VARIABLE_NAME VARIABLE_VALUE 6109HANDLER_COMMIT 1 6110HANDLER_EXTERNAL_LOCK 4 6111HANDLER_READ_KEY 13 6112HANDLER_READ_NEXT 4 6113HANDLER_UPDATE 1 6114HANDLER_WRITE 17 6115SELECT * FROM t2; 6116a b 61171 +1 61182 2 61198 8 6120ROLLBACK; 6121FLUSH STATUS; 6122SET autocommit = 0; 6123LOCK TABLES t1 read, t2 write; 6124UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1'); 6125SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6126WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6127VARIABLE_NAME VARIABLE_VALUE 6128HANDLER_COMMIT 2 6129HANDLER_EXTERNAL_LOCK 2 6130HANDLER_READ_KEY 13 6131HANDLER_READ_NEXT 4 6132HANDLER_UPDATE 1 6133HANDLER_WRITE 17 6134SELECT * FROM t2; 6135a b 61361 +1 61372 2 61388 8 6139ROLLBACK; 6140UNLOCK TABLES; 6141EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b('1'); 6142id select_type table partitions type possible_keys key key_len ref rows filtered Extra 61431 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where 6144Warnings: 6145Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6146FLUSH STATUS; 6147START TRANSACTION; 6148UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b('1'); 6149SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6150WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6151VARIABLE_NAME VARIABLE_VALUE 6152HANDLER_COMMIT 1 6153HANDLER_EXTERNAL_LOCK 4 6154HANDLER_READ_FIRST 3 6155HANDLER_READ_KEY 12 6156HANDLER_READ_NEXT 3 6157HANDLER_READ_RND_NEXT 3 6158HANDLER_UPDATE 1 6159HANDLER_WRITE 17 6160SELECT * FROM t2; 6161a b 61621 1 61632 2 61648 +8 6165ROLLBACK; 6166FLUSH STATUS; 6167SET autocommit = 0; 6168LOCK TABLES t1 read, t2 write; 6169UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b('1'); 6170SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6171WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6172VARIABLE_NAME VARIABLE_VALUE 6173HANDLER_COMMIT 2 6174HANDLER_EXTERNAL_LOCK 2 6175HANDLER_READ_FIRST 3 6176HANDLER_READ_KEY 12 6177HANDLER_READ_NEXT 3 6178HANDLER_READ_RND_NEXT 3 6179HANDLER_UPDATE 1 6180HANDLER_WRITE 17 6181SELECT * FROM t2; 6182a b 61831 1 61842 2 61858 +8 6186ROLLBACK; 6187UNLOCK TABLES; 6188EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6189id select_type table partitions type possible_keys key key_len ref rows filtered Extra 61901 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 6191Warnings: 6192Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6193FLUSH STATUS; 6194START TRANSACTION; 6195UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6196SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6197WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6198VARIABLE_NAME VARIABLE_VALUE 6199HANDLER_COMMIT 1 6200HANDLER_EXTERNAL_LOCK 4 6201HANDLER_READ_KEY 13 6202HANDLER_READ_NEXT 4 6203HANDLER_UPDATE 1 6204HANDLER_WRITE 17 6205SELECT * FROM t2; 6206a b 62071 1 62082 2 62098 +8 6210ROLLBACK; 6211FLUSH STATUS; 6212SET autocommit = 0; 6213LOCK TABLES t1 read, t2 write; 6214UPDATE t2 SET b = CONCAT('+', b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6215SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6216WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6217VARIABLE_NAME VARIABLE_VALUE 6218HANDLER_COMMIT 2 6219HANDLER_EXTERNAL_LOCK 2 6220HANDLER_READ_KEY 13 6221HANDLER_READ_NEXT 4 6222HANDLER_UPDATE 1 6223HANDLER_WRITE 17 6224SELECT * FROM t2; 6225a b 62261 1 62272 2 62288 +8 6229ROLLBACK; 6230UNLOCK TABLES; 6231EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6232id select_type table partitions type possible_keys key key_len ref rows filtered Extra 62331 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 6234Warnings: 6235Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6236FLUSH STATUS; 6237START TRANSACTION; 6238UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6239SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6240WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6241VARIABLE_NAME VARIABLE_VALUE 6242HANDLER_COMMIT 1 6243HANDLER_EXTERNAL_LOCK 4 6244HANDLER_READ_KEY 4 6245HANDLER_READ_NEXT 1 6246HANDLER_WRITE 17 6247SELECT * FROM t2; 6248a b 62491 1 62502 2 62518 8 6252ROLLBACK; 6253FLUSH STATUS; 6254SET autocommit = 0; 6255LOCK TABLES t1 read, t2 write; 6256UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6257SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6258WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6259VARIABLE_NAME VARIABLE_VALUE 6260HANDLER_COMMIT 2 6261HANDLER_EXTERNAL_LOCK 2 6262HANDLER_READ_KEY 4 6263HANDLER_READ_NEXT 1 6264HANDLER_WRITE 17 6265SELECT * FROM t2; 6266a b 62671 1 62682 2 62698 8 6270ROLLBACK; 6271UNLOCK TABLES; 6272EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6273id select_type table partitions type possible_keys key key_len ref rows filtered Extra 62741 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 6275Warnings: 6276Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6277FLUSH STATUS; 6278START TRANSACTION; 6279UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6280SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6281WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6282VARIABLE_NAME VARIABLE_VALUE 6283HANDLER_COMMIT 1 6284HANDLER_EXTERNAL_LOCK 4 6285HANDLER_READ_KEY 3 6286HANDLER_READ_NEXT 1 6287HANDLER_WRITE 17 6288SELECT * FROM t2; 6289a b 62901 1 62912 2 62928 8 6293ROLLBACK; 6294FLUSH STATUS; 6295SET autocommit = 0; 6296LOCK TABLES t1 read, t2 write; 6297UPDATE t2 SET b = CONCAT('+', b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6298SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6299WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6300VARIABLE_NAME VARIABLE_VALUE 6301HANDLER_COMMIT 2 6302HANDLER_EXTERNAL_LOCK 2 6303HANDLER_READ_KEY 3 6304HANDLER_READ_NEXT 1 6305HANDLER_WRITE 17 6306SELECT * FROM t2; 6307a b 63081 1 63092 2 63108 8 6311ROLLBACK; 6312UNLOCK TABLES; 6313EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6314id select_type table partitions type possible_keys key key_len ref rows filtered Extra 63151 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 63162 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6317Warnings: 6318Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6319FLUSH STATUS; 6320START TRANSACTION; 6321UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6322SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6323WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6324VARIABLE_NAME VARIABLE_VALUE 6325HANDLER_COMMIT 1 6326HANDLER_EXTERNAL_LOCK 4 6327HANDLER_READ_KEY 3 6328HANDLER_READ_NEXT 1 6329HANDLER_WRITE 17 6330SELECT * FROM t2; 6331a b 63321 1 63332 2 63348 8 6335ROLLBACK; 6336FLUSH STATUS; 6337SET autocommit = 0; 6338LOCK TABLES t1 read, t2 write; 6339UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6340SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6341WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6342VARIABLE_NAME VARIABLE_VALUE 6343HANDLER_COMMIT 2 6344HANDLER_EXTERNAL_LOCK 2 6345HANDLER_READ_KEY 3 6346HANDLER_READ_NEXT 1 6347HANDLER_WRITE 17 6348SELECT * FROM t2; 6349a b 63501 1 63512 2 63528 8 6353ROLLBACK; 6354UNLOCK TABLES; 6355EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6356id select_type table partitions type possible_keys key key_len ref rows filtered Extra 63571 UPDATE t2 p1,p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 63582 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6359Warnings: 6360Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6361FLUSH STATUS; 6362START TRANSACTION; 6363UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6364SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6365WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6366VARIABLE_NAME VARIABLE_VALUE 6367HANDLER_COMMIT 1 6368HANDLER_EXTERNAL_LOCK 4 6369HANDLER_READ_KEY 5 6370HANDLER_READ_NEXT 1 6371HANDLER_UPDATE 2 6372HANDLER_WRITE 17 6373SELECT * FROM t2; 6374a b 63751 +1 63762 +2 63778 8 6378ROLLBACK; 6379FLUSH STATUS; 6380SET autocommit = 0; 6381LOCK TABLES t1 read, t2 write; 6382UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6383SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6384WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6385VARIABLE_NAME VARIABLE_VALUE 6386HANDLER_COMMIT 2 6387HANDLER_EXTERNAL_LOCK 2 6388HANDLER_READ_KEY 5 6389HANDLER_READ_NEXT 1 6390HANDLER_UPDATE 2 6391HANDLER_WRITE 17 6392SELECT * FROM t2; 6393a b 63941 +1 63952 +2 63968 8 6397ROLLBACK; 6398UNLOCK TABLES; 6399EXPLAIN PARTITIONS UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 6400id select_type table partitions type possible_keys key key_len ref rows filtered Extra 64011 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 64022 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6403Warnings: 6404Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6405FLUSH STATUS; 6406START TRANSACTION; 6407UPDATE t2 SET b = CONCAT('+', b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 6408SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6409WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6410VARIABLE_NAME VARIABLE_VALUE 6411HANDLER_COMMIT 1 6412HANDLER_EXTERNAL_LOCK 6 6413HANDLER_READ_KEY 7 6414HANDLER_READ_NEXT 2 6415HANDLER_UPDATE 1 6416HANDLER_WRITE 17 6417SELECT * FROM t2; 6418a b 64191 1 64202 2 64218 +8 6422ROLLBACK; 6423EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6424id select_type table partitions type possible_keys key key_len ref rows filtered Extra 64251 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 64262 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6427Warnings: 6428Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6429FLUSH STATUS; 6430START TRANSACTION; 6431UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6432SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6433WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6434VARIABLE_NAME VARIABLE_VALUE 6435HANDLER_COMMIT 1 6436HANDLER_EXTERNAL_LOCK 4 6437HANDLER_READ_KEY 4 6438HANDLER_READ_NEXT 1 6439HANDLER_UPDATE 1 6440HANDLER_WRITE 17 6441SELECT * FROM t2; 6442a b 64431 hello 1 64442 2 64458 8 6446ROLLBACK; 6447FLUSH STATUS; 6448SET autocommit = 0; 6449LOCK TABLES t1 read, t2 write; 6450UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6451SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6452WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6453VARIABLE_NAME VARIABLE_VALUE 6454HANDLER_COMMIT 2 6455HANDLER_EXTERNAL_LOCK 2 6456HANDLER_READ_KEY 4 6457HANDLER_READ_NEXT 1 6458HANDLER_UPDATE 1 6459HANDLER_WRITE 17 6460SELECT * FROM t2; 6461a b 64621 hello 1 64632 2 64648 8 6465ROLLBACK; 6466UNLOCK TABLES; 6467EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6468id select_type table partitions type possible_keys key key_len ref rows filtered Extra 64691 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 64702 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6471Warnings: 6472Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6473FLUSH STATUS; 6474START TRANSACTION; 6475UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6476SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6477WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6478VARIABLE_NAME VARIABLE_VALUE 6479HANDLER_COMMIT 1 6480HANDLER_EXTERNAL_LOCK 4 6481HANDLER_READ_KEY 4 6482HANDLER_READ_NEXT 1 6483HANDLER_UPDATE 1 6484HANDLER_WRITE 17 6485SELECT * FROM t2; 6486a b 64871 1 64882 2 64898 hello 8 6490ROLLBACK; 6491FLUSH STATUS; 6492SET autocommit = 0; 6493LOCK TABLES t1 read, t2 write; 6494UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6495SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6496WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6497VARIABLE_NAME VARIABLE_VALUE 6498HANDLER_COMMIT 2 6499HANDLER_EXTERNAL_LOCK 2 6500HANDLER_READ_KEY 4 6501HANDLER_READ_NEXT 1 6502HANDLER_UPDATE 1 6503HANDLER_WRITE 17 6504SELECT * FROM t2; 6505a b 65061 1 65072 2 65088 hello 8 6509ROLLBACK; 6510UNLOCK TABLES; 6511EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1'); 6512id select_type table partitions type possible_keys key key_len ref rows filtered Extra 65131 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where 6514Warnings: 6515Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6516FLUSH STATUS; 6517START TRANSACTION; 6518UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1'); 6519SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6520WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6521VARIABLE_NAME VARIABLE_VALUE 6522HANDLER_COMMIT 1 6523HANDLER_EXTERNAL_LOCK 4 6524HANDLER_READ_FIRST 3 6525HANDLER_READ_KEY 12 6526HANDLER_READ_NEXT 3 6527HANDLER_READ_RND_NEXT 3 6528HANDLER_UPDATE 1 6529HANDLER_WRITE 17 6530SELECT * FROM t2; 6531a b 65321 hello 1 65332 2 65348 8 6535ROLLBACK; 6536FLUSH STATUS; 6537SET autocommit = 0; 6538LOCK TABLES t1 read, t2 write; 6539UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1'); 6540SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6541WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6542VARIABLE_NAME VARIABLE_VALUE 6543HANDLER_COMMIT 2 6544HANDLER_EXTERNAL_LOCK 2 6545HANDLER_READ_FIRST 3 6546HANDLER_READ_KEY 12 6547HANDLER_READ_NEXT 3 6548HANDLER_READ_RND_NEXT 3 6549HANDLER_UPDATE 1 6550HANDLER_WRITE 17 6551SELECT * FROM t2; 6552a b 65531 hello 1 65542 2 65558 8 6556ROLLBACK; 6557UNLOCK TABLES; 6558EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1'); 6559id select_type table partitions type possible_keys key key_len ref rows filtered Extra 65601 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 6561Warnings: 6562Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6563FLUSH STATUS; 6564START TRANSACTION; 6565UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1'); 6566SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6567WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6568VARIABLE_NAME VARIABLE_VALUE 6569HANDLER_COMMIT 1 6570HANDLER_EXTERNAL_LOCK 4 6571HANDLER_READ_KEY 13 6572HANDLER_READ_NEXT 4 6573HANDLER_UPDATE 1 6574HANDLER_WRITE 17 6575SELECT * FROM t2; 6576a b 65771 hello 1 65782 2 65798 8 6580ROLLBACK; 6581FLUSH STATUS; 6582SET autocommit = 0; 6583LOCK TABLES t1 read, t2 write; 6584UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1'); 6585SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6586WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6587VARIABLE_NAME VARIABLE_VALUE 6588HANDLER_COMMIT 2 6589HANDLER_EXTERNAL_LOCK 2 6590HANDLER_READ_KEY 13 6591HANDLER_READ_NEXT 4 6592HANDLER_UPDATE 1 6593HANDLER_WRITE 17 6594SELECT * FROM t2; 6595a b 65961 hello 1 65972 2 65988 8 6599ROLLBACK; 6600UNLOCK TABLES; 6601EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b('1'); 6602id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66031 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where 6604Warnings: 6605Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6606FLUSH STATUS; 6607START TRANSACTION; 6608UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b('1'); 6609SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6610WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6611VARIABLE_NAME VARIABLE_VALUE 6612HANDLER_COMMIT 1 6613HANDLER_EXTERNAL_LOCK 4 6614HANDLER_READ_FIRST 3 6615HANDLER_READ_KEY 12 6616HANDLER_READ_NEXT 3 6617HANDLER_READ_RND_NEXT 3 6618HANDLER_UPDATE 1 6619HANDLER_WRITE 17 6620SELECT * FROM t2; 6621a b 66221 1 66232 2 66248 hello 8 6625ROLLBACK; 6626FLUSH STATUS; 6627SET autocommit = 0; 6628LOCK TABLES t1 read, t2 write; 6629UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b('1'); 6630SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6631WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6632VARIABLE_NAME VARIABLE_VALUE 6633HANDLER_COMMIT 2 6634HANDLER_EXTERNAL_LOCK 2 6635HANDLER_READ_FIRST 3 6636HANDLER_READ_KEY 12 6637HANDLER_READ_NEXT 3 6638HANDLER_READ_RND_NEXT 3 6639HANDLER_UPDATE 1 6640HANDLER_WRITE 17 6641SELECT * FROM t2; 6642a b 66431 1 66442 2 66458 hello 8 6646ROLLBACK; 6647UNLOCK TABLES; 6648EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6649id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66501 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 6651Warnings: 6652Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6653FLUSH STATUS; 6654START TRANSACTION; 6655UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6656SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6657WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6658VARIABLE_NAME VARIABLE_VALUE 6659HANDLER_COMMIT 1 6660HANDLER_EXTERNAL_LOCK 4 6661HANDLER_READ_KEY 13 6662HANDLER_READ_NEXT 4 6663HANDLER_UPDATE 1 6664HANDLER_WRITE 17 6665SELECT * FROM t2; 6666a b 66671 1 66682 2 66698 hello 8 6670ROLLBACK; 6671FLUSH STATUS; 6672SET autocommit = 0; 6673LOCK TABLES t1 read, t2 write; 6674UPDATE t2 SET b = sf_add_hello(b) WHERE a = 7 + sf_a_from_t1b_d('1'); 6675SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6676WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6677VARIABLE_NAME VARIABLE_VALUE 6678HANDLER_COMMIT 2 6679HANDLER_EXTERNAL_LOCK 2 6680HANDLER_READ_KEY 13 6681HANDLER_READ_NEXT 4 6682HANDLER_UPDATE 1 6683HANDLER_WRITE 17 6684SELECT * FROM t2; 6685a b 66861 1 66872 2 66888 hello 8 6689ROLLBACK; 6690UNLOCK TABLES; 6691EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6692id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66931 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 6694Warnings: 6695Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6696FLUSH STATUS; 6697START TRANSACTION; 6698UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6699SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6700WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6701VARIABLE_NAME VARIABLE_VALUE 6702HANDLER_COMMIT 1 6703HANDLER_EXTERNAL_LOCK 4 6704HANDLER_READ_KEY 4 6705HANDLER_READ_NEXT 1 6706HANDLER_WRITE 17 6707SELECT * FROM t2; 6708a b 67091 1 67102 2 67118 8 6712ROLLBACK; 6713FLUSH STATUS; 6714SET autocommit = 0; 6715LOCK TABLES t1 read, t2 write; 6716UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b('1') AND a = 2; 6717SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6718WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6719VARIABLE_NAME VARIABLE_VALUE 6720HANDLER_COMMIT 2 6721HANDLER_EXTERNAL_LOCK 2 6722HANDLER_READ_KEY 4 6723HANDLER_READ_NEXT 1 6724HANDLER_WRITE 17 6725SELECT * FROM t2; 6726a b 67271 1 67282 2 67298 8 6730ROLLBACK; 6731UNLOCK TABLES; 6732EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6733id select_type table partitions type possible_keys key key_len ref rows filtered Extra 67341 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 6735Warnings: 6736Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6737FLUSH STATUS; 6738START TRANSACTION; 6739UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6740SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6741WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6742VARIABLE_NAME VARIABLE_VALUE 6743HANDLER_COMMIT 1 6744HANDLER_EXTERNAL_LOCK 4 6745HANDLER_READ_KEY 3 6746HANDLER_READ_NEXT 1 6747HANDLER_WRITE 17 6748SELECT * FROM t2; 6749a b 67501 1 67512 2 67528 8 6753ROLLBACK; 6754FLUSH STATUS; 6755SET autocommit = 0; 6756LOCK TABLES t1 read, t2 write; 6757UPDATE t2 SET b = sf_add_hello(b) WHERE a = sf_a_from_t1b_d('1') AND a = 2; 6758SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6759WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6760VARIABLE_NAME VARIABLE_VALUE 6761HANDLER_COMMIT 2 6762HANDLER_EXTERNAL_LOCK 2 6763HANDLER_READ_KEY 3 6764HANDLER_READ_NEXT 1 6765HANDLER_WRITE 17 6766SELECT * FROM t2; 6767a b 67681 1 67692 2 67708 8 6771ROLLBACK; 6772UNLOCK TABLES; 6773EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6774id select_type table partitions type possible_keys key key_len ref rows filtered Extra 67751 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 67762 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6777Warnings: 6778Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6779FLUSH STATUS; 6780START TRANSACTION; 6781UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6782SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6783WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6784VARIABLE_NAME VARIABLE_VALUE 6785HANDLER_COMMIT 1 6786HANDLER_EXTERNAL_LOCK 4 6787HANDLER_READ_KEY 3 6788HANDLER_READ_NEXT 1 6789HANDLER_WRITE 17 6790SELECT * FROM t2; 6791a b 67921 1 67932 2 67948 8 6795ROLLBACK; 6796FLUSH STATUS; 6797SET autocommit = 0; 6798LOCK TABLES t1 read, t2 write; 6799UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 6800SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6801WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6802VARIABLE_NAME VARIABLE_VALUE 6803HANDLER_COMMIT 2 6804HANDLER_EXTERNAL_LOCK 2 6805HANDLER_READ_KEY 3 6806HANDLER_READ_NEXT 1 6807HANDLER_WRITE 17 6808SELECT * FROM t2; 6809a b 68101 1 68112 2 68128 8 6813ROLLBACK; 6814UNLOCK TABLES; 6815EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6816id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68171 UPDATE t2 p1,p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 68182 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6819Warnings: 6820Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6821FLUSH STATUS; 6822START TRANSACTION; 6823UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6824SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6825WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6826VARIABLE_NAME VARIABLE_VALUE 6827HANDLER_COMMIT 1 6828HANDLER_EXTERNAL_LOCK 4 6829HANDLER_READ_KEY 5 6830HANDLER_READ_NEXT 1 6831HANDLER_UPDATE 2 6832HANDLER_WRITE 17 6833SELECT * FROM t2; 6834a b 68351 hello 1 68362 hello 2 68378 8 6838ROLLBACK; 6839FLUSH STATUS; 6840SET autocommit = 0; 6841LOCK TABLES t1 read, t2 write; 6842UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 6843SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6844WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6845VARIABLE_NAME VARIABLE_VALUE 6846HANDLER_COMMIT 2 6847HANDLER_EXTERNAL_LOCK 2 6848HANDLER_READ_KEY 5 6849HANDLER_READ_NEXT 1 6850HANDLER_UPDATE 2 6851HANDLER_WRITE 17 6852SELECT * FROM t2; 6853a b 68541 hello 1 68552 hello 2 68568 8 6857ROLLBACK; 6858UNLOCK TABLES; 6859EXPLAIN PARTITIONS UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 6860id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68611 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 68622 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6863Warnings: 6864Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6865FLUSH STATUS; 6866START TRANSACTION; 6867UPDATE t2 SET b = sf_add_hello(b) WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 6868SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6869WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6870VARIABLE_NAME VARIABLE_VALUE 6871HANDLER_COMMIT 1 6872HANDLER_EXTERNAL_LOCK 6 6873HANDLER_READ_KEY 7 6874HANDLER_READ_NEXT 2 6875HANDLER_UPDATE 1 6876HANDLER_WRITE 17 6877SELECT * FROM t2; 6878a b 68791 1 68802 2 68818 hello 8 6882ROLLBACK; 6883EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6884id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68851 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 68862 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6887Warnings: 6888Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6889FLUSH STATUS; 6890START TRANSACTION; 6891UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6892SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6893WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6894VARIABLE_NAME VARIABLE_VALUE 6895HANDLER_COMMIT 1 6896HANDLER_DELETE 1 6897HANDLER_EXTERNAL_LOCK 4 6898HANDLER_READ_KEY 5 6899HANDLER_READ_NEXT 1 6900HANDLER_READ_RND 1 6901HANDLER_WRITE 18 6902SELECT * FROM t2; 6903a b 69042 2 69056 1 69068 8 6907ROLLBACK; 6908FLUSH STATUS; 6909SET autocommit = 0; 6910LOCK TABLES t1 read, t2 write; 6911UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 6912SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6913WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6914VARIABLE_NAME VARIABLE_VALUE 6915HANDLER_COMMIT 2 6916HANDLER_DELETE 1 6917HANDLER_EXTERNAL_LOCK 2 6918HANDLER_READ_KEY 5 6919HANDLER_READ_NEXT 1 6920HANDLER_READ_RND 1 6921HANDLER_WRITE 18 6922SELECT * FROM t2; 6923a b 69242 2 69256 1 69268 8 6927ROLLBACK; 6928UNLOCK TABLES; 6929EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6930id select_type table partitions type possible_keys key key_len ref rows filtered Extra 69311 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 69322 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 6933Warnings: 6934Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6935FLUSH STATUS; 6936START TRANSACTION; 6937UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6938SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6939WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6940VARIABLE_NAME VARIABLE_VALUE 6941HANDLER_COMMIT 1 6942HANDLER_DELETE 1 6943HANDLER_EXTERNAL_LOCK 4 6944HANDLER_READ_KEY 5 6945HANDLER_READ_NEXT 1 6946HANDLER_READ_RND 1 6947HANDLER_WRITE 18 6948SELECT * FROM t2; 6949a b 69501 1 695113 8 69522 2 6953ROLLBACK; 6954FLUSH STATUS; 6955SET autocommit = 0; 6956LOCK TABLES t1 read, t2 write; 6957UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 6958SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6959WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6960VARIABLE_NAME VARIABLE_VALUE 6961HANDLER_COMMIT 2 6962HANDLER_DELETE 1 6963HANDLER_EXTERNAL_LOCK 2 6964HANDLER_READ_KEY 5 6965HANDLER_READ_NEXT 1 6966HANDLER_READ_RND 1 6967HANDLER_WRITE 18 6968SELECT * FROM t2; 6969a b 69701 1 697113 8 69722 2 6973ROLLBACK; 6974UNLOCK TABLES; 6975EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1'); 6976id select_type table partitions type possible_keys key key_len ref rows filtered Extra 69771 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where; Using temporary 6978Warnings: 6979Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 6980FLUSH STATUS; 6981START TRANSACTION; 6982UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1'); 6983SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 6984WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 6985VARIABLE_NAME VARIABLE_VALUE 6986HANDLER_COMMIT 1 6987HANDLER_DELETE 1 6988HANDLER_EXTERNAL_LOCK 4 6989HANDLER_READ_FIRST 3 6990HANDLER_READ_KEY 13 6991HANDLER_READ_NEXT 6 6992HANDLER_READ_RND 1 6993HANDLER_WRITE 18 6994SELECT * FROM t2; 6995a b 69962 2 69976 1 69988 8 6999ROLLBACK; 7000FLUSH STATUS; 7001SET autocommit = 0; 7002LOCK TABLES t1 read, t2 write; 7003UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1'); 7004SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7005WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7006VARIABLE_NAME VARIABLE_VALUE 7007HANDLER_COMMIT 2 7008HANDLER_DELETE 1 7009HANDLER_EXTERNAL_LOCK 2 7010HANDLER_READ_FIRST 3 7011HANDLER_READ_KEY 13 7012HANDLER_READ_NEXT 6 7013HANDLER_READ_RND 1 7014HANDLER_WRITE 18 7015SELECT * FROM t2; 7016a b 70172 2 70186 1 70198 8 7020ROLLBACK; 7021UNLOCK TABLES; 7022EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1'); 7023id select_type table partitions type possible_keys key key_len ref rows filtered Extra 70241 UPDATE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 7025Warnings: 7026Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7027FLUSH STATUS; 7028START TRANSACTION; 7029UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1'); 7030SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7031WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7032VARIABLE_NAME VARIABLE_VALUE 7033HANDLER_COMMIT 1 7034HANDLER_DELETE 1 7035HANDLER_EXTERNAL_LOCK 4 7036HANDLER_READ_KEY 14 7037HANDLER_READ_NEXT 4 7038HANDLER_READ_RND 1 7039HANDLER_WRITE 18 7040SELECT * FROM t2; 7041a b 70422 2 70436 1 70448 8 7045ROLLBACK; 7046FLUSH STATUS; 7047SET autocommit = 0; 7048LOCK TABLES t1 read, t2 write; 7049UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1'); 7050SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7051WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7052VARIABLE_NAME VARIABLE_VALUE 7053HANDLER_COMMIT 2 7054HANDLER_DELETE 1 7055HANDLER_EXTERNAL_LOCK 2 7056HANDLER_READ_KEY 14 7057HANDLER_READ_NEXT 4 7058HANDLER_READ_RND 1 7059HANDLER_WRITE 18 7060SELECT * FROM t2; 7061a b 70622 2 70636 1 70648 8 7065ROLLBACK; 7066UNLOCK TABLES; 7067EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b('1'); 7068id select_type table partitions type possible_keys key key_len ref rows filtered Extra 70691 UPDATE t2 p0,p1,p2 index NULL PRIMARY 4 NULL # 100.00 Using where; Using temporary 7070Warnings: 7071Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7072FLUSH STATUS; 7073START TRANSACTION; 7074UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b('1'); 7075SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7076WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7077VARIABLE_NAME VARIABLE_VALUE 7078HANDLER_COMMIT 1 7079HANDLER_DELETE 1 7080HANDLER_EXTERNAL_LOCK 4 7081HANDLER_READ_FIRST 3 7082HANDLER_READ_KEY 13 7083HANDLER_READ_NEXT 6 7084HANDLER_READ_RND 1 7085HANDLER_WRITE 18 7086SELECT * FROM t2; 7087a b 70881 1 708913 8 70902 2 7091ROLLBACK; 7092FLUSH STATUS; 7093SET autocommit = 0; 7094LOCK TABLES t1 read, t2 write; 7095UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b('1'); 7096SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7097WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7098VARIABLE_NAME VARIABLE_VALUE 7099HANDLER_COMMIT 2 7100HANDLER_DELETE 1 7101HANDLER_EXTERNAL_LOCK 2 7102HANDLER_READ_FIRST 3 7103HANDLER_READ_KEY 13 7104HANDLER_READ_NEXT 6 7105HANDLER_READ_RND 1 7106HANDLER_WRITE 18 7107SELECT * FROM t2; 7108a b 71091 1 711013 8 71112 2 7112ROLLBACK; 7113UNLOCK TABLES; 7114EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b_d('1'); 7115id select_type table partitions type possible_keys key key_len ref rows filtered Extra 71161 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 7117Warnings: 7118Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7119FLUSH STATUS; 7120START TRANSACTION; 7121UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b_d('1'); 7122SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7123WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7124VARIABLE_NAME VARIABLE_VALUE 7125HANDLER_COMMIT 1 7126HANDLER_DELETE 1 7127HANDLER_EXTERNAL_LOCK 4 7128HANDLER_READ_KEY 14 7129HANDLER_READ_NEXT 4 7130HANDLER_READ_RND 1 7131HANDLER_WRITE 18 7132SELECT * FROM t2; 7133a b 71341 1 713513 8 71362 2 7137ROLLBACK; 7138FLUSH STATUS; 7139SET autocommit = 0; 7140LOCK TABLES t1 read, t2 write; 7141UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = 7 + sf_a_from_t1b_d('1'); 7142SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7143WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7144VARIABLE_NAME VARIABLE_VALUE 7145HANDLER_COMMIT 2 7146HANDLER_DELETE 1 7147HANDLER_EXTERNAL_LOCK 2 7148HANDLER_READ_KEY 14 7149HANDLER_READ_NEXT 4 7150HANDLER_READ_RND 1 7151HANDLER_WRITE 18 7152SELECT * FROM t2; 7153a b 71541 1 715513 8 71562 2 7157ROLLBACK; 7158UNLOCK TABLES; 7159EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1') AND a = 2; 7160id select_type table partitions type possible_keys key key_len ref rows filtered Extra 71611 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 7162Warnings: 7163Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7164FLUSH STATUS; 7165START TRANSACTION; 7166UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1') AND a = 2; 7167SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7168WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7169VARIABLE_NAME VARIABLE_VALUE 7170HANDLER_COMMIT 1 7171HANDLER_EXTERNAL_LOCK 4 7172HANDLER_READ_KEY 4 7173HANDLER_READ_NEXT 1 7174HANDLER_WRITE 17 7175SELECT * FROM t2; 7176a b 71771 1 71782 2 71798 8 7180ROLLBACK; 7181FLUSH STATUS; 7182SET autocommit = 0; 7183LOCK TABLES t1 read, t2 write; 7184UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b('1') AND a = 2; 7185SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7186WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7187VARIABLE_NAME VARIABLE_VALUE 7188HANDLER_COMMIT 2 7189HANDLER_EXTERNAL_LOCK 2 7190HANDLER_READ_KEY 4 7191HANDLER_READ_NEXT 1 7192HANDLER_WRITE 17 7193SELECT * FROM t2; 7194a b 71951 1 71962 2 71978 8 7198ROLLBACK; 7199UNLOCK TABLES; 7200EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7201id select_type table partitions type possible_keys key key_len ref rows filtered Extra 72021 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 7203Warnings: 7204Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7205FLUSH STATUS; 7206START TRANSACTION; 7207UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7208SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7209WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7210VARIABLE_NAME VARIABLE_VALUE 7211HANDLER_COMMIT 1 7212HANDLER_EXTERNAL_LOCK 4 7213HANDLER_READ_KEY 3 7214HANDLER_READ_NEXT 1 7215HANDLER_WRITE 17 7216SELECT * FROM t2; 7217a b 72181 1 72192 2 72208 8 7221ROLLBACK; 7222FLUSH STATUS; 7223SET autocommit = 0; 7224LOCK TABLES t1 read, t2 write; 7225UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7226SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7227WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7228VARIABLE_NAME VARIABLE_VALUE 7229HANDLER_COMMIT 2 7230HANDLER_EXTERNAL_LOCK 2 7231HANDLER_READ_KEY 3 7232HANDLER_READ_NEXT 1 7233HANDLER_WRITE 17 7234SELECT * FROM t2; 7235a b 72361 1 72372 2 72388 8 7239ROLLBACK; 7240UNLOCK TABLES; 7241EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7242id select_type table partitions type possible_keys key key_len ref rows filtered Extra 72431 UPDATE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 72442 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7245Warnings: 7246Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7247FLUSH STATUS; 7248START TRANSACTION; 7249UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7250SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7251WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7252VARIABLE_NAME VARIABLE_VALUE 7253HANDLER_COMMIT 1 7254HANDLER_EXTERNAL_LOCK 4 7255HANDLER_READ_KEY 3 7256HANDLER_READ_NEXT 1 7257HANDLER_WRITE 17 7258SELECT * FROM t2; 7259a b 72601 1 72612 2 72628 8 7263ROLLBACK; 7264FLUSH STATUS; 7265SET autocommit = 0; 7266LOCK TABLES t1 read, t2 write; 7267UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7268SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7269WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7270VARIABLE_NAME VARIABLE_VALUE 7271HANDLER_COMMIT 2 7272HANDLER_EXTERNAL_LOCK 2 7273HANDLER_READ_KEY 3 7274HANDLER_READ_NEXT 1 7275HANDLER_WRITE 17 7276SELECT * FROM t2; 7277a b 72781 1 72792 2 72808 8 7281ROLLBACK; 7282UNLOCK TABLES; 7283EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7284id select_type table partitions type possible_keys key key_len ref rows filtered Extra 72851 UPDATE t2 p1,p2 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 72862 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7287Warnings: 7288Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7289FLUSH STATUS; 7290START TRANSACTION; 7291UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7292SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7293WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7294VARIABLE_NAME VARIABLE_VALUE 7295HANDLER_COMMIT 1 7296HANDLER_DELETE 2 7297HANDLER_EXTERNAL_LOCK 4 7298HANDLER_READ_KEY 7 7299HANDLER_READ_NEXT 1 7300HANDLER_READ_RND 2 7301HANDLER_WRITE 19 7302SELECT * FROM t2; 7303a b 73046 1 73057 2 73068 8 7307ROLLBACK; 7308FLUSH STATUS; 7309SET autocommit = 0; 7310LOCK TABLES t1 read, t2 write; 7311UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7312SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7313WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7314VARIABLE_NAME VARIABLE_VALUE 7315HANDLER_COMMIT 2 7316HANDLER_DELETE 2 7317HANDLER_EXTERNAL_LOCK 2 7318HANDLER_READ_KEY 7 7319HANDLER_READ_NEXT 1 7320HANDLER_READ_RND 2 7321HANDLER_WRITE 19 7322SELECT * FROM t2; 7323a b 73246 1 73257 2 73268 8 7327ROLLBACK; 7328UNLOCK TABLES; 7329EXPLAIN PARTITIONS UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 7330id select_type table partitions type possible_keys key key_len ref rows filtered Extra 73311 UPDATE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where; Using temporary 73322 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7333Warnings: 7334Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7335FLUSH STATUS; 7336START TRANSACTION; 7337UPDATE t2 SET a = sf_add_1(a) + 4 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 7338SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7339WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7340VARIABLE_NAME VARIABLE_VALUE 7341HANDLER_COMMIT 1 7342HANDLER_DELETE 1 7343HANDLER_EXTERNAL_LOCK 6 7344HANDLER_READ_KEY 8 7345HANDLER_READ_NEXT 2 7346HANDLER_READ_RND 1 7347HANDLER_WRITE 18 7348SELECT * FROM t2; 7349a b 73501 1 735113 8 73522 2 7353ROLLBACK; 7354EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 7355id select_type table partitions type possible_keys key key_len ref rows filtered Extra 73561 DELETE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 73572 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7358Warnings: 7359Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7360FLUSH STATUS; 7361START TRANSACTION; 7362DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 7363SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7364WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7365VARIABLE_NAME VARIABLE_VALUE 7366HANDLER_COMMIT 1 7367HANDLER_DELETE 1 7368HANDLER_EXTERNAL_LOCK 4 7369HANDLER_READ_KEY 4 7370HANDLER_READ_NEXT 1 7371HANDLER_WRITE 17 7372SELECT * FROM t2; 7373a b 73742 2 73758 8 7376ROLLBACK; 7377FLUSH STATUS; 7378SET autocommit = 0; 7379LOCK TABLES t1 read, t2 write; 7380DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1'); 7381SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7382WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7383VARIABLE_NAME VARIABLE_VALUE 7384HANDLER_COMMIT 2 7385HANDLER_DELETE 1 7386HANDLER_EXTERNAL_LOCK 2 7387HANDLER_READ_KEY 4 7388HANDLER_READ_NEXT 1 7389HANDLER_WRITE 17 7390SELECT * FROM t2; 7391a b 73922 2 73938 8 7394ROLLBACK; 7395UNLOCK TABLES; 7396EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 7397id select_type table partitions type possible_keys key key_len ref rows filtered Extra 73981 DELETE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 73992 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7400Warnings: 7401Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7402FLUSH STATUS; 7403START TRANSACTION; 7404DELETE FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 7405SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7406WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7407VARIABLE_NAME VARIABLE_VALUE 7408HANDLER_COMMIT 1 7409HANDLER_DELETE 1 7410HANDLER_EXTERNAL_LOCK 4 7411HANDLER_READ_KEY 4 7412HANDLER_READ_NEXT 1 7413HANDLER_WRITE 17 7414SELECT * FROM t2; 7415a b 74161 1 74172 2 7418ROLLBACK; 7419FLUSH STATUS; 7420SET autocommit = 0; 7421LOCK TABLES t1 read, t2 write; 7422DELETE FROM t2 WHERE a = 7 + (SELECT a FROM t1 WHERE b = '1'); 7423SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7424WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7425VARIABLE_NAME VARIABLE_VALUE 7426HANDLER_COMMIT 2 7427HANDLER_DELETE 1 7428HANDLER_EXTERNAL_LOCK 2 7429HANDLER_READ_KEY 4 7430HANDLER_READ_NEXT 1 7431HANDLER_WRITE 17 7432SELECT * FROM t2; 7433a b 74341 1 74352 2 7436ROLLBACK; 7437UNLOCK TABLES; 7438EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = sf_a_from_t1b('1'); 7439id select_type table partitions type possible_keys key key_len ref rows filtered Extra 74401 DELETE t2 p0,p1,p2 ALL NULL NULL NULL NULL # 100.00 Using where 7441Warnings: 7442Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7443FLUSH STATUS; 7444START TRANSACTION; 7445DELETE FROM t2 WHERE a = sf_a_from_t1b('1'); 7446SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7447WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7448VARIABLE_NAME VARIABLE_VALUE 7449HANDLER_COMMIT 1 7450HANDLER_DELETE 1 7451HANDLER_EXTERNAL_LOCK 4 7452HANDLER_READ_FIRST 3 7453HANDLER_READ_KEY 12 7454HANDLER_READ_NEXT 3 7455HANDLER_READ_RND_NEXT 3 7456HANDLER_WRITE 17 7457SELECT * FROM t2; 7458a b 74592 2 74608 8 7461ROLLBACK; 7462FLUSH STATUS; 7463SET autocommit = 0; 7464LOCK TABLES t1 read, t2 write; 7465DELETE FROM t2 WHERE a = sf_a_from_t1b('1'); 7466SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7467WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7468VARIABLE_NAME VARIABLE_VALUE 7469HANDLER_COMMIT 2 7470HANDLER_DELETE 1 7471HANDLER_EXTERNAL_LOCK 2 7472HANDLER_READ_FIRST 3 7473HANDLER_READ_KEY 12 7474HANDLER_READ_NEXT 3 7475HANDLER_READ_RND_NEXT 3 7476HANDLER_WRITE 17 7477SELECT * FROM t2; 7478a b 74792 2 74808 8 7481ROLLBACK; 7482UNLOCK TABLES; 7483EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1'); 7484id select_type table partitions type possible_keys key key_len ref rows filtered Extra 74851 DELETE t2 p1 range PRIMARY PRIMARY 4 const # 100.00 Using where 7486Warnings: 7487Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7488FLUSH STATUS; 7489START TRANSACTION; 7490DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1'); 7491SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7492WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7493VARIABLE_NAME VARIABLE_VALUE 7494HANDLER_COMMIT 1 7495HANDLER_DELETE 1 7496HANDLER_EXTERNAL_LOCK 4 7497HANDLER_READ_KEY 13 7498HANDLER_READ_NEXT 4 7499HANDLER_WRITE 17 7500SELECT * FROM t2; 7501a b 75022 2 75038 8 7504ROLLBACK; 7505FLUSH STATUS; 7506SET autocommit = 0; 7507LOCK TABLES t1 read, t2 write; 7508DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1'); 7509SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7510WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7511VARIABLE_NAME VARIABLE_VALUE 7512HANDLER_COMMIT 2 7513HANDLER_DELETE 1 7514HANDLER_EXTERNAL_LOCK 2 7515HANDLER_READ_KEY 13 7516HANDLER_READ_NEXT 4 7517HANDLER_WRITE 17 7518SELECT * FROM t2; 7519a b 75202 2 75218 8 7522ROLLBACK; 7523UNLOCK TABLES; 7524EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 7525id select_type table partitions type possible_keys key key_len ref rows filtered Extra 75261 DELETE t2 p0,p1,p2 ALL NULL NULL NULL NULL # 100.00 Using where 7527Warnings: 7528Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7529FLUSH STATUS; 7530START TRANSACTION; 7531DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 7532SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7533WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7534VARIABLE_NAME VARIABLE_VALUE 7535HANDLER_COMMIT 1 7536HANDLER_DELETE 1 7537HANDLER_EXTERNAL_LOCK 4 7538HANDLER_READ_FIRST 3 7539HANDLER_READ_KEY 12 7540HANDLER_READ_NEXT 3 7541HANDLER_READ_RND_NEXT 3 7542HANDLER_WRITE 17 7543SELECT * FROM t2; 7544a b 75451 1 75462 2 7547ROLLBACK; 7548FLUSH STATUS; 7549SET autocommit = 0; 7550LOCK TABLES t1 read, t2 write; 7551DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b('1'); 7552SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7553WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7554VARIABLE_NAME VARIABLE_VALUE 7555HANDLER_COMMIT 2 7556HANDLER_DELETE 1 7557HANDLER_EXTERNAL_LOCK 2 7558HANDLER_READ_FIRST 3 7559HANDLER_READ_KEY 12 7560HANDLER_READ_NEXT 3 7561HANDLER_READ_RND_NEXT 3 7562HANDLER_WRITE 17 7563SELECT * FROM t2; 7564a b 75651 1 75662 2 7567ROLLBACK; 7568UNLOCK TABLES; 7569EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 7570id select_type table partitions type possible_keys key key_len ref rows filtered Extra 75711 DELETE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 7572Warnings: 7573Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7574FLUSH STATUS; 7575START TRANSACTION; 7576DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 7577SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7578WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7579VARIABLE_NAME VARIABLE_VALUE 7580HANDLER_COMMIT 1 7581HANDLER_DELETE 1 7582HANDLER_EXTERNAL_LOCK 4 7583HANDLER_READ_KEY 13 7584HANDLER_READ_NEXT 4 7585HANDLER_WRITE 17 7586SELECT * FROM t2; 7587a b 75881 1 75892 2 7590ROLLBACK; 7591FLUSH STATUS; 7592SET autocommit = 0; 7593LOCK TABLES t1 read, t2 write; 7594DELETE FROM t2 WHERE a = 7 + sf_a_from_t1b_d('1'); 7595SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7596WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7597VARIABLE_NAME VARIABLE_VALUE 7598HANDLER_COMMIT 2 7599HANDLER_DELETE 1 7600HANDLER_EXTERNAL_LOCK 2 7601HANDLER_READ_KEY 13 7602HANDLER_READ_NEXT 4 7603HANDLER_WRITE 17 7604SELECT * FROM t2; 7605a b 76061 1 76072 2 7608ROLLBACK; 7609UNLOCK TABLES; 7610EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 7611id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76121 DELETE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 7613Warnings: 7614Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7615FLUSH STATUS; 7616START TRANSACTION; 7617DELETE FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 7618SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7619WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7620VARIABLE_NAME VARIABLE_VALUE 7621HANDLER_COMMIT 1 7622HANDLER_EXTERNAL_LOCK 4 7623HANDLER_READ_KEY 4 7624HANDLER_READ_NEXT 1 7625HANDLER_WRITE 17 7626SELECT * FROM t2; 7627a b 76281 1 76292 2 76308 8 7631ROLLBACK; 7632FLUSH STATUS; 7633SET autocommit = 0; 7634LOCK TABLES t1 read, t2 write; 7635DELETE FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2; 7636SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7637WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7638VARIABLE_NAME VARIABLE_VALUE 7639HANDLER_COMMIT 2 7640HANDLER_EXTERNAL_LOCK 2 7641HANDLER_READ_KEY 4 7642HANDLER_READ_NEXT 1 7643HANDLER_WRITE 17 7644SELECT * FROM t2; 7645a b 76461 1 76472 2 76488 8 7649ROLLBACK; 7650UNLOCK TABLES; 7651EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7652id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76531 DELETE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 7654Warnings: 7655Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7656FLUSH STATUS; 7657START TRANSACTION; 7658DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7659SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7660WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7661VARIABLE_NAME VARIABLE_VALUE 7662HANDLER_COMMIT 1 7663HANDLER_EXTERNAL_LOCK 4 7664HANDLER_READ_KEY 3 7665HANDLER_READ_NEXT 1 7666HANDLER_WRITE 17 7667SELECT * FROM t2; 7668a b 76691 1 76702 2 76718 8 7672ROLLBACK; 7673FLUSH STATUS; 7674SET autocommit = 0; 7675LOCK TABLES t1 read, t2 write; 7676DELETE FROM t2 WHERE a = sf_a_from_t1b_d('1') AND a = 2; 7677SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7678WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7679VARIABLE_NAME VARIABLE_VALUE 7680HANDLER_COMMIT 2 7681HANDLER_EXTERNAL_LOCK 2 7682HANDLER_READ_KEY 3 7683HANDLER_READ_NEXT 1 7684HANDLER_WRITE 17 7685SELECT * FROM t2; 7686a b 76871 1 76882 2 76898 8 7690ROLLBACK; 7691UNLOCK TABLES; 7692EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7693id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76941 DELETE NULL NULL NULL NULL NULL NULL NULL # NULL Impossible WHERE 76952 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7696Warnings: 7697Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7698FLUSH STATUS; 7699START TRANSACTION; 7700DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7701SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7702WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7703VARIABLE_NAME VARIABLE_VALUE 7704HANDLER_COMMIT 1 7705HANDLER_EXTERNAL_LOCK 4 7706HANDLER_READ_KEY 3 7707HANDLER_READ_NEXT 1 7708HANDLER_WRITE 17 7709SELECT * FROM t2; 7710a b 77111 1 77122 2 77138 8 7714ROLLBACK; 7715FLUSH STATUS; 7716SET autocommit = 0; 7717LOCK TABLES t1 read, t2 write; 7718DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2; 7719SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7720WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7721VARIABLE_NAME VARIABLE_VALUE 7722HANDLER_COMMIT 2 7723HANDLER_EXTERNAL_LOCK 2 7724HANDLER_READ_KEY 3 7725HANDLER_READ_NEXT 1 7726HANDLER_WRITE 17 7727SELECT * FROM t2; 7728a b 77291 1 77302 2 77318 8 7732ROLLBACK; 7733UNLOCK TABLES; 7734EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7735id select_type table partitions type possible_keys key key_len ref rows filtered Extra 77361 DELETE t2 p1,p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 77372 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7738Warnings: 7739Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7740FLUSH STATUS; 7741START TRANSACTION; 7742DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7743SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7744WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7745VARIABLE_NAME VARIABLE_VALUE 7746HANDLER_COMMIT 1 7747HANDLER_DELETE 2 7748HANDLER_EXTERNAL_LOCK 4 7749HANDLER_READ_KEY 5 7750HANDLER_READ_NEXT 1 7751HANDLER_WRITE 17 7752SELECT * FROM t2; 7753a b 77548 8 7755ROLLBACK; 7756FLUSH STATUS; 7757SET autocommit = 0; 7758LOCK TABLES t1 read, t2 write; 7759DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') OR a = 2; 7760SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7761WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7762VARIABLE_NAME VARIABLE_VALUE 7763HANDLER_COMMIT 2 7764HANDLER_DELETE 2 7765HANDLER_EXTERNAL_LOCK 2 7766HANDLER_READ_KEY 5 7767HANDLER_READ_NEXT 1 7768HANDLER_WRITE 17 7769SELECT * FROM t2; 7770a b 77718 8 7772ROLLBACK; 7773UNLOCK TABLES; 7774EXPLAIN PARTITIONS DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 7775id select_type table partitions type possible_keys key key_len ref rows filtered Extra 77761 DELETE t2 p2 range PRIMARY PRIMARY 4 const # 100.00 Using where 77772 SUBQUERY t1 p0,p1,p2 ref b b 258 const # 100.00 Using index 7778Warnings: 7779Warning 1681 'PARTITIONS' is deprecated and will be removed in a future release. 7780FLUSH STATUS; 7781START TRANSACTION; 7782DELETE FROM t2 WHERE a = (SELECT a FROM t1 WHERE b = '1') AND a = 2 OR a = 8 AND sf_a_from_t1b('2'); 7783SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS 7784WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; 7785VARIABLE_NAME VARIABLE_VALUE 7786HANDLER_COMMIT 1 7787HANDLER_DELETE 1 7788HANDLER_EXTERNAL_LOCK 6 7789HANDLER_READ_KEY 7 7790HANDLER_READ_NEXT 2 7791HANDLER_WRITE 17 7792SELECT * FROM t2; 7793a b 77941 1 77952 2 7796ROLLBACK; 7797set @@autocommit= @old_autocommit; 7798DROP FUNCTION sf_add_hello; 7799DROP FUNCTION sf_add_1; 7800DROP FUNCTION sf_a_from_t1b_d; 7801DROP FUNCTION sf_a_from_t1b; 7802DROP TABLE tq, tsq, t1, t2; 7803SET @@global.innodb_stats_persistent= @old_innodb_stats_persistent; 7804