File: partition_innodb.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (1925 lines) | stat: -rw-r--r-- 58,268 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
drop table if exists t1, t2;
#
#BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
#              CORRUPTS FRM
# After WL#8971, the test case was rewritten to use InnoDB.
CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= INNODB PARTITION BY HASH(fld1)
PARTITIONS 5;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `fld1` int NOT NULL,
  PRIMARY KEY (`fld1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY HASH (`fld1`)
PARTITIONS 5 */
ALTER TABLE t1 ENGINE= ARCHIVE;
ERROR 42000: The storage engine for the table doesn't support native partitioning
#After the patch, the ENGINE is correctly displayed as InnoDB
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `fld1` int NOT NULL,
  PRIMARY KEY (`fld1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY HASH (`fld1`)
PARTITIONS 5 */
#Cleanup.
DROP TABLE t1;
#
# Bug#11763825/56590: PARTITIONS: FULLTEXT SEARCHES FAIL
# (bad/confusing error message)
# After WL#8971, the test case was rewritten to use InnoDB.
# The errors returned are  different.
#
CREATE TABLE t1
(a INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
b VARCHAR(200),
c TEXT)
ENGINE=InnoDB
PARTITION BY HASH(a) PARTITIONS 1;
CREATE FULLTEXT INDEX msg ON t1 (b, c);
ERROR HY000: The used table type doesn't support FULLTEXT indexes
DROP TABLE t1;
CREATE TABLE t1
(a INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
b VARCHAR(200),
c TEXT,
FULLTEXT (b, c))
ENGINE=InnoDB
PARTITION BY HASH(a) PARTITIONS 1;
ERROR HY000: The used table type doesn't support FULLTEXT indexes
#
# BUG#11933226 - 60681: CHECKSUM TABLE RETURNS 0 FOR PARTITIONED TABLE
# After WL#8971, the test case was rewritten to use InnoDB.
#
CREATE TABLE t1 (
i INT
)
ENGINE=InnoDB
PARTITION BY RANGE (i)
(PARTITION p3 VALUES LESS THAN (3),
PARTITION p5 VALUES LESS THAN (5),
PARTITION pMax VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
CHECKSUM TABLE t1;
Table	Checksum
test.t1	2653438147
ALTER TABLE t1 CHECKSUM = 1;
CHECKSUM TABLE t1 EXTENDED;
Table	Checksum
test.t1	2653438147
CHECKSUM TABLE t1;
Table	Checksum
test.t1	2653438147
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `i` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci CHECKSUM=1
/*!50100 PARTITION BY RANGE (`i`)
(PARTITION p3 VALUES LESS THAN (3) ENGINE = InnoDB,
 PARTITION p5 VALUES LESS THAN (5) ENGINE = InnoDB,
 PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
DROP TABLE t1;
# Same test without partitioning
CREATE TABLE t1 (
i INT
) ENGINE=InnoDB;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `i` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
CHECKSUM TABLE t1;
Table	Checksum
test.t1	2653438147
ALTER TABLE t1 CHECKSUM = 1;
CHECKSUM TABLE t1 EXTENDED;
Table	Checksum
test.t1	2653438147
CHECKSUM TABLE t1;
Table	Checksum
test.t1	2653438147
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `i` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci CHECKSUM=1
DROP TABLE t1;
#
# Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST
#               INNODB PARTITION STATISTICS
#
CREATE TABLE t1
(a INT,
b varchar(64),
PRIMARY KEY (a),
KEY (b))
ENGINE = InnoDB
PARTITION BY RANGE (a)
SUBPARTITION BY HASH (a) SUBPARTITIONS 10
(PARTITION pNeg VALUES LESS THAN (0),
PARTITION p0 VALUES LESS THAN (1000),
PARTITION pMAX VALUES LESS THAN MAXVALUE);
# Only one row in the first 10 subpartitions
INSERT INTO t1 VALUES (-1, 'Only negative pk value');
INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
(10, 'Zero'), (11, 'Mod One'), (12, 'Mod Two'), (13, 'Mod Three'),
(20, '0'), (21, '1'), (22, '2'), (23, '3'),
(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	pNeg_pNegsp0,pNeg_pNegsp1,pNeg_pNegsp2,pNeg_pNegsp3,pNeg_pNegsp4,pNeg_pNegsp5,pNeg_pNegsp6,pNeg_pNegsp7,pNeg_pNegsp8,pNeg_pNegsp9,p0_p0sp0,p0_p0sp1,p0_p0sp2,p0_p0sp3,p0_p0sp4,p0_p0sp5,p0_p0sp6,p0_p0sp7,p0_p0sp8,p0_p0sp9,pMAX_pMAXsp0,pMAX_pMAXsp1,pMAX_pMAXsp2,pMAX_pMAXsp3,pMAX_pMAXsp4,pMAX_pMAXsp5,pMAX_pMAXsp6,pMAX_pMAXsp7,pMAX_pMAXsp8,pMAX_pMAXsp9	range	PRIMARY,b	b	263	NULL	8	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` between 'L' and 'N') and (`test`.`t1`.`a` > <cache>(-(100))))
DROP TABLE t1;
#
# Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY
#               and PARTITIONING
#
CREATE TABLE t1 (a INT, KEY(a))
ENGINE = InnoDB
PARTITION BY KEY (a) PARTITIONS 1;
SELECT 1 FROM t1 WHERE a > (SELECT LAST_INSERT_ID() FROM t1 LIMIT 0)
ORDER BY a;
1
DROP TABLE t1;
#
# Bug#56287: crash when using Partition datetime in sub in query
#
CREATE TABLE t1
(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT,
c2 varchar(40) not null default '',
c3 datetime not  NULL,
PRIMARY KEY (c1,c3),
KEY partidx(c3))
ENGINE=InnoDB
PARTITION BY RANGE (TO_DAYS(c3))
(PARTITION p200912 VALUES LESS THAN (to_days('2010-01-01')),
PARTITION p201103 VALUES LESS THAN (to_days('2011-04-01')),
PARTITION p201912 VALUES LESS THAN MAXVALUE);
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00');
SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
PARTITION_NAME	TABLE_ROWS
p200912	0
p201103	1
p201912	0
SELECT count(*) FROM t1 p where c3 in
(SELECT c3 FROM t1 t WHERE t.c3 < TIMESTAMP'2011-04-26 19:19:44'
 AND t.c3 > TIMESTAMP'2011-04-26 19:18:44') ;
count(*)
0
DROP TABLE t1;
#
# Bug#54747: Deadlock between REORGANIZE PARTITION and
#            SELECT is not detected
#
SET @old_innodb_thread_concurrency := @@innodb_thread_concurrency;
SET @old_innodb_thread_sleep_delay := @@innodb_thread_sleep_delay;
SET GLOBAL innodb_thread_concurrency = 2;
CREATE TABLE t1
(user_num BIGINT,
hours SMALLINT,
KEY user_num (user_num))
ENGINE = InnoDB   
PARTITION BY RANGE COLUMNS (hours)
(PARTITION hour_003 VALUES LESS THAN (3),
PARTITION hour_004 VALUES LESS THAN (4),
PARTITION hour_005 VALUES LESS THAN (5),
PARTITION hour_last VALUES LESS THAN (MAXVALUE));
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
BEGIN;
SELECT COUNT(*) FROM t1;
COUNT(*)
5
# con1
# SEND a ALTER PARTITION which waits on the ongoing transaction.
ALTER TABLE t1
REORGANIZE PARTITION hour_003, hour_004 INTO
(PARTITION oldest VALUES LESS THAN (4));
# Connection default wait until the ALTER is in 'waiting for table...'
# state and then continue the transaction by trying a SELECT
SELECT COUNT(*) FROM t1;
COUNT(*)
5
COMMIT;
# con1, reaping ALTER.
# Disconnecting con1 and switching to default. Cleaning up.
SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency;
SET GLOBAL innodb_thread_sleep_delay = @old_innodb_thread_sleep_delay;
DROP TABLE t1;
#
# Bug#50418: DROP PARTITION does not interact with transactions
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL,
name CHAR(50) NOT NULL,
myDate DATE NOT NULL,
PRIMARY KEY (id, myDate),
INDEX idx_date (myDate)
) ENGINE=InnoDB
PARTITION BY RANGE ( TO_DAYS(myDate) ) (
PARTITION p0 VALUES LESS THAN (734028),
PARTITION p1 VALUES LESS THAN (734029),
PARTITION p2 VALUES LESS THAN (734030),
PARTITION p3 VALUES LESS THAN MAXVALUE
) ;
INSERT INTO t1 VALUES 
(NULL, 'Lachlan', '2009-09-13'),
(NULL, 'Clint', '2009-09-13'),
(NULL, 'John', '2009-09-14'),
(NULL, 'Dave', '2009-09-14'),
(NULL, 'Jeremy', '2009-09-15'),
(NULL, 'Scott', '2009-09-15'),
(NULL, 'Jeff', '2009-09-16'),
(NULL, 'Joe', '2009-09-16');
SET AUTOCOMMIT=0;
SELECT * FROM t1 FOR UPDATE;
id	name	myDate
1	Lachlan	2009-09-13
2	Clint	2009-09-13
3	John	2009-09-14
4	Dave	2009-09-14
5	Jeremy	2009-09-15
6	Scott	2009-09-15
7	Jeff	2009-09-16
8	Joe	2009-09-16
UPDATE t1 SET name = 'Mattias' WHERE id = 7;
SELECT * FROM t1 WHERE id = 7;
id	name	myDate
7	Mattias	2009-09-16
# Connection con1
SET lock_wait_timeout = 1;
# After the patch it will wait and fail on timeout.
ALTER TABLE t1 DROP PARTITION p3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SHOW WARNINGS;
Level	Code	Message
Error	1205	Lock wait timeout exceeded; try restarting transaction
# Connection default
SELECT * FROM t1;
id	name	myDate
1	Lachlan	2009-09-13
2	Clint	2009-09-13
3	John	2009-09-14
4	Dave	2009-09-14
5	Jeremy	2009-09-15
6	Scott	2009-09-15
7	Mattias	2009-09-16
8	Joe	2009-09-16
# No changes.
COMMIT;
DROP TABLE t1;
#
# Bug#51830: Incorrect partition pruning on range partition (regression)
#
CREATE TABLE t1 (a INT NOT NULL)
ENGINE = InnoDB
PARTITION BY RANGE(a)
(PARTITION p10 VALUES LESS THAN (10),
PARTITION p30 VALUES LESS THAN (30),
PARTITION p50 VALUES LESS THAN (50),
PARTITION p70 VALUES LESS THAN (70),
PARTITION p90 VALUES LESS THAN (90));
INSERT INTO t1 VALUES (10),(30),(50);
INSERT INTO t1 VALUES (70);
INSERT INTO t1 VALUES (80);
INSERT INTO t1 VALUES (89);
INSERT INTO t1 VALUES (90);
ERROR HY000: Table has no partition for value 90
INSERT INTO t1 VALUES (100);
ERROR HY000: Table has no partition for value 100
insert INTO t1 VALUES (110);
ERROR HY000: Table has no partition for value 110
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
EXPLAIN SELECT * FROM t1 WHERE a > 90;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 90)
EXPLAIN SELECT * FROM t1 WHERE a >= 90;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` >= 90)
EXPLAIN SELECT * FROM t1 WHERE a = 90;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 90)
EXPLAIN SELECT * FROM t1 WHERE a = 89;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	33.33	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 89)
EXPLAIN SELECT * FROM t1 WHERE a >= 89;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p90	ALL	NULL	NULL	NULL	NULL	3	33.33	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` >= 89)
EXPLAIN SELECT * FROM t1 WHERE a > 89;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 89)
EXPLAIN SELECT * FROM t1 WHERE a = 100;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 100)
EXPLAIN SELECT * FROM t1 WHERE a >= 100;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` >= 100)
EXPLAIN SELECT * FROM t1 WHERE a > 100;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 100)
DROP TABLE t1;
#
# Bug#50104: Partitioned table with just 1 partion works with fk
#
CREATE TABLE t2 (
id INT,
PRIMARY KEY (id)
) ENGINE=InnoDB ;
CREATE TABLE t1 (
id INT NOT NULL AUTO_INCREMENT,
parent_id INT DEFAULT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id)
) ENGINE=InnoDB;
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
ERROR HY000: Foreign keys are not yet supported in conjunction with partitioning
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
ERROR HY000: Foreign keys are not yet supported in conjunction with partitioning
DROP TABLE t1, t2;
create table t1 (a varchar(5), b int signed, c varchar(10), d datetime)
partition by range columns(b,c)
subpartition by hash(to_seconds(d))
( partition p0 values less than (2, 'b'),
partition p1 values less than (4, 'd'),
partition p2 values less than (10, 'za'));
insert into t1 values ('a', 3, 'w', '2001-10-27 04:34:00');
insert into t1 values ('r', 7, 'w', '2001-10-27 05:34:00');
insert into t1 values ('g', 10, 'w', '2001-10-27 06:34:00');
update t1 set a = 'c' where a > 'f';
drop table t1;
create table t1 (a varchar(5))
engine=innodb
partition by range columns(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values  ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a int not null,
b datetime not null,
primary key (a,b))
engine=innodb
partition by range (to_days(b))
subpartition by hash (a)
subpartitions 2
( partition p0 values less than (to_days('2009-01-01')),
partition p1 values less than (to_days('2009-02-01')),
partition p2 values less than (to_days('2009-03-01')),
partition p3 values less than maxvalue);
alter table t1 reorganize partition p1,p2 into
( partition p2 values less than (to_days('2009-03-01')));
drop table t1;
CREATE TABLE t1 (id INT PRIMARY KEY, data INT) ENGINE = InnoDB 
PARTITION BY RANGE(id) ( 
PARTITION p0 VALUES LESS THAN (5), 
PARTITION p1 VALUES LESS THAN (10), 
PARTITION p2 VALUES LESS THAN MAXVALUE 
);
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8),
(9,9), (10,10), (11,11);
SET @old_transaction_isolation := @@session.transaction_isolation;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET autocommit = 0;
UPDATE t1 SET DATA = data*2 WHERE id = 3;
UPDATE t1 SET data = data*2 WHERE data = 2;
SET @@session.transaction_isolation = @old_transaction_isolation;
SET autocommit = default;
DROP TABLE t1;
# Bug#37721, test of ORDER BY on PK and WHERE on INDEX
CREATE TABLE t1 (
a INT,
b INT,
PRIMARY KEY (a),
INDEX (b))
ENGINE InnoDB
PARTITION BY HASH(a)
PARTITIONS 3;
INSERT INTO t1 VALUES (0,0),(4,0),(2,0);
SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
a
0
2
4
SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
a
4
2
0
ALTER TABLE t1 DROP INDEX b;
SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
a
0
2
4
SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
a
4
2
0
DROP TABLE t1;
CREATE TABLE t1 (
a VARCHAR(600),
b VARCHAR(600),
PRIMARY KEY (a),
INDEX (b))
ENGINE InnoDB
PARTITION BY KEY(a)
PARTITIONS 3;
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'1'),repeat('0',257));
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'3'),repeat('0',257));
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'2'),repeat('0',257));
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
right(a,1)
1
2
3
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
right(a,1)
3
2
1
ALTER TABLE t1 DROP INDEX b;
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
right(a,1)
1
2
3
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
right(a,1)
3
2
1
DROP TABLE t1;
create table t1 (a int) engine=innodb partition by hash(a) ;
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status like 't1';
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	0	#	#	0	0	#	NULL	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
drop table t1;
create table t1 (a int)
engine = innodb
partition by key (a);
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	0	#	#	0	0	#	NULL	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
insert into t1 values (0), (1), (2), (3);
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	4	#	#	0	0	#	NULL	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
drop table t1;
create table t1 (a int auto_increment primary key)
engine = innodb
partition by key (a);
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	0	#	#	0	0	#	1	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
insert into t1 values (NULL), (NULL), (NULL), (NULL);
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	4	#	#	0	0	#	5	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
insert into t1 values (NULL), (NULL), (NULL), (NULL);
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	InnoDB	10	Dynamic	8	#	#	0	0	#	9	#	#	NULL	utf8mb4_0900_ai_ci	NULL	partitioned	
drop table t1;
create table t1 (a int)
partition by key (a)
(partition p1 engine = innodb);
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
drop table t1;
create table t1 (a date)
engine = innodb
partition by range (year(a))
(partition p0 values less than (2006),
partition p1 values less than (2007));
explain select * from t1
where a between '2006-01-01' and '2007-06-01';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p1	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` between '2006-01-01' and '2007-06-01')
drop table t1;
create table t1 (a int)
engine = x
partition by key (a);
ERROR 42000: Unknown storage engine 'x'
create table t1 (a int)
engine = innodb
partition by list (a)
(partition p0 values in (0));
alter table t1 engine = x;
ERROR 42000: Unknown storage engine 'x'
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY LIST (`a`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB) */
drop table t1;
create table t1
(
id int unsigned auto_increment,
time datetime not null,
first_name varchar(40),
last_name varchar(50),
primary key (id, time),
index first_index (first_name),
index last_index (last_name)	
) engine=Innodb partition by range (to_days(time)) (
partition p1 values less than (to_days('2007-02-07')),
partition p2 values less than (to_days('2007-02-08')),
partition p3 values less than MAXVALUE
);
insert into t1 (time, first_name, last_name) values ('2007-02-07', 'Q', 'Robert'),
('2007-02-07', 'Mark', 'Nate'), ('2007-02-07', 'Nate', 'Oscar'),
('2007-02-07', 'Zack', 'Alice'), ('2007-02-07', 'Jack', 'Kathy'),
('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Brian', 'Charles'),
('2007-02-06', 'Charles', 'David'), ('2007-02-06', 'David', 'Eric'),
('2007-02-07', 'Hector', 'Isaac'), ('2007-02-07', 'Oscar', 'Patricia'),
('2007-02-07', 'Patricia', 'Q'), ('2007-02-07', 'X', 'Yuri'),
('2007-02-07', 'Robert', 'Shawn'), ('2007-02-07', 'Kathy', 'Lois'),
('2007-02-07', 'Eric', 'Francis'), ('2007-02-06', 'Shawn', 'Theron'),
('2007-02-06', 'U', 'Vincent'), ('2007-02-06', 'Francis', 'George'),
('2007-02-06', 'George', 'Hector'), ('2007-02-06', 'Vincent', 'Walter'),
('2007-02-06', 'Walter', 'X'), ('2007-02-07', 'Lois', 'Mark'),
('2007-02-07', 'Yuri', 'Zack'), ('2007-02-07', 'Isaac', 'Jack'),
('2007-02-07', 'Sharon', 'Mark'), ('2007-02-07', 'Michael', 'Michelle'),
('2007-02-07', 'Derick', 'Nathan'), ('2007-02-07', 'Peter', 'Xavier'),
('2007-02-07', 'Fred', 'Harold'), ('2007-02-07', 'Katherine', 'Lisa'),
('2007-02-07', 'Tom', 'Rina'), ('2007-02-07', 'Jerry', 'Victor'),
('2007-02-07', 'Alexander', 'Terry'), ('2007-02-07', 'Justin', 'John'),
('2007-02-07', 'Greg', 'Ernest'), ('2007-02-07', 'Robert', 'Q'),
('2007-02-07', 'Nate', 'Mark'), ('2007-02-07', 'Oscar', 'Nate'),
('2007-02-07', 'Alice', 'Zack'), ('2007-02-07', 'Kathy', 'Jack'),
('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Charles', 'Brian'),
('2007-02-06', 'David', 'Charles'), ('2007-02-06', 'Eric', 'David'),
('2007-02-07', 'Isaac', 'Hector'), ('2007-02-07', 'Patricia', 'Oscar'),
('2007-02-07', 'Q', 'Patricia'), ('2007-02-07', 'Yuri', 'X'),
('2007-02-07', 'Shawn', 'Robert'), ('2007-02-07', 'Lois', 'Kathy'),
('2007-02-07', 'Francis', 'Eric'), ('2007-02-06', 'Theron', 'Shawn'),
('2007-02-06', 'Vincent', 'U'), ('2007-02-06', 'George', 'Francis'),
('2007-02-06', 'Hector', 'George'), ('2007-02-06', 'Walter', 'Vincent'),
('2007-02-06', 'X', 'Walter'), ('2007-02-07', 'Mark', 'Lois'),
('2007-02-07', 'Zack', 'Yuri'), ('2007-02-07', 'Jack', 'Isaac'),
('2007-02-07', 'Mark', 'Sharon'), ('2007-02-07', 'Michelle', 'Michael'),
('2007-02-07', 'Nathan', 'Derick'), ('2007-02-07', 'Xavier', 'Peter'),
('2007-02-07', 'Harold', 'Fred'), ('2007-02-07', 'Lisa', 'Katherine'),
('2007-02-07', 'Rina', 'Tom'), ('2007-02-07', 'Victor', 'Jerry'),
('2007-02-07', 'Terry', 'Alexander'), ('2007-02-07', 'John', 'Justin'),
('2007-02-07', 'Ernest', 'Greg');
SELECT * FROM t1 WHERE first_name='Andy' OR last_name='Jake';
id	time	first_name	last_name
drop table t1;
CREATE TABLE t1 (a DOUBLE NOT NULL, KEY(a)) ENGINE=InnoDB
PARTITION BY KEY(a) PARTITIONS 10;
INSERT INTO t1 VALUES(1),(2);
SELECT COUNT(*) FROM t1;
COUNT(*)
2
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB
PARTITION BY list(a) (PARTITION p1 VALUES IN (1));
CREATE INDEX i1 ON t1 (a);
DROP TABLE t1;
#
# Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE
#
DROP TABLE IF EXISTS t1;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (a INT, b TIMESTAMP DEFAULT '0000-00-00 00:00:00')
ENGINE=INNODB PARTITION BY LINEAR HASH (a) PARTITIONS 1;
SET @old_mode = @@sql_mode;
SET SESSION sql_mode = '';
OPTIMIZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
test.t1	optimize	status	OK
SET SESSION sql_mode = @old_mode;
DROP TABLE t1;
SET sql_mode = default;
#
# Bug#57985 "ONLINE/FAST ALTER PARTITION can fail and leave the
#            table unusable".
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a bigint not null, b int not null, PRIMARY KEY (a))
ENGINE = InnoDB PARTITION BY KEY(a) PARTITIONS 2;
INSERT INTO t1 values (0,1), (1,2);
# The below ALTER should fail. It should leave the
# table in its original, non-corrupted, usable state.
ALTER TABLE t1 ADD UNIQUE KEY (b);
ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function (prefixed columns are not considered).
# The below statements should succeed, as ALTER should
# have left table intact.
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` bigint NOT NULL,
  `b` int NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY KEY (a)
PARTITIONS 2 */
SELECT * FROM t1;
a	b
1	2
0	1
DROP TABLE t1;
#
# Bug#16943907: FLUSH TABLES FOR EXPORT: ASSERTION IN HA_PARTITION::EXTRA
#
CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB
PARTITION BY HASH (a) PARTITIONS 2;
FLUSH TABLES t1 FOR EXPORT;
# List of files after EXPORT (should include a .cfg file for each part).
t1#P#p0.cfg
t1#P#p0.ibd
t1#P#p1.cfg
t1#P#p1.ibd
# Copying the .cfg and .ibd files as backup
UNLOCK TABLES;
# List of files after UNLOCK (no .cfg files).
t1#P#p0.ibd
t1#P#p1.ibd
ALTER TABLE t1 DISCARD TABLESPACE;
# List of files after DISCARD (no .cfg/.ibd files).
# Moving the .cfg and .ibd files back from backup
ALTER TABLE t1 IMPORT TABLESPACE;
# List of files after IMPORT (.cfg files still there).
t1#P#p0.cfg
t1#P#p0.ibd
t1#P#p1.cfg
t1#P#p1.ibd
DROP TABLE t1;
# List of files after DROP (.cfg files should also be removed).
#
# Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT
# Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE
#
CREATE TABLE t1
(a INT,
b INT,
PRIMARY KEY (a))
ENGINE = InnoDB
PARTITION BY HASH (a) PARTITIONS 3;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
# con1
ALTER TABLE t1 ADD INDEX idx1 (b);
# con default
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT * FROM t1;
ERROR HY000: Table definition has changed, please retry transaction
DROP TABLE t1;
# Same test without partitioning
CREATE TABLE t1
(a INT,
b INT,
PRIMARY KEY (a))
ENGINE = InnoDB;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
# con1
ALTER TABLE t1 ADD INDEX idx1 (b);
# con default
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT * FROM t1;
ERROR HY000: Table definition has changed, please retry transaction
DROP TABLE t1;
Bug 17896265	 PARTITIONED TABLE HAS MISPLACED ROWS, AFTER INPLACE ALTER
CREATE TABLE t1 (
f1 INT(11) NOT NULL,
f2 INT(11) NOT NULL
)
ENGINE=InnoDB
PARTITION BY KEY (f1,f2) PARTITIONS 2;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 VALUES (9585,5);
ALTER TABLE t1 CHANGE f1 f1 INT AFTER f2, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
CREATE TABLE t2 (
f1 INT(11) NOT NULL,
f2 INT(11) NOT NULL,
f3 INT(11) NOT NULL,
f4 INT(11) NOT NULL
)
ENGINE=InnoDB
PARTITION BY KEY (f2,f3) PARTITIONS 2;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t2 VALUES (10,9585,5,20);
ALTER TABLE t2 CHANGE f3 f3 INT AFTER f4, ALGORITHM=INPLACE;
CHECK TABLE t2;
Table	Op	Msg_type	Msg_text
test.t2	check	status	OK
ALTER TABLE t2 CHANGE f3 f3 INT AFTER f1, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
ALTER TABLE t2 CHANGE f4 f4 INT AFTER f3, ALGORITHM=INPLACE;
CHECK TABLE t2;
Table	Op	Msg_type	Msg_text
test.t2	check	status	OK
ALTER TABLE t2 CHANGE f1 f1 INT AFTER f4, ALGORITHM=INPLACE;
CHECK TABLE t2;
Table	Op	Msg_type	Msg_text
test.t2	check	status	OK
ALTER TABLE t2 CHANGE f1 f1 INT AFTER f2, ALGORITHM=INPLACE;
CHECK TABLE t2;
Table	Op	Msg_type	Msg_text
test.t2	check	status	OK
ALTER TABLE t2 CHANGE f2 f2 INT AFTER f4, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
CREATE TABLE t3 (f1 INT,f2 INT) ENGINE=INNODB
PARTITION BY RANGE(f1) (
PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (200),
PARTITION p2 VALUES LESS THAN (600),
PARTITION p3 VALUES LESS THAN MAXVALUE
);
insert into t3 values (90,120);
insert into t3 values (120,300);
ALTER TABLE t3 CHANGE f1 f1 int AFTER f2, ALGORITHM=INPLACE;
CHECK TABLE t3;
Table	Op	Msg_type	Msg_text
test.t3	check	status	OK
CREATE TABLE t4 (
f1 INT(11) NOT NULL,
f2 INT(11) NOT NULL
)
ENGINE=InnoDB
PARTITION BY HASH (MOD(f1,f2)) PARTITIONS 2;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t4 VALUES (9585,5);
ALTER TABLE t4 CHANGE f1 f1 INT AFTER f2, ALGORITHM=INPLACE;
CHECK TABLE t4;
Table	Op	Msg_type	Msg_text
test.t4	check	status	OK
CREATE TABLE t5 (
f1 INT,
f2 INT
)
ENGINE=InnoDB
PARTITION BY RANGE COLUMNS(f1,f2) (
PARTITION p0 VALUES LESS THAN (10000,12),
PARTITION p1 VALUES LESS THAN (MAXVALUE, MAXVALUE)
);
INSERT INTO t5 VALUES (1,20000);
ALTER TABLE t5 CHANGE f1 f1 INT AFTER f2, ALGORITHM=INPLACE;
CHECK TABLE t5;
Table	Op	Msg_type	Msg_text
test.t5	check	status	OK
CREATE TABLE t6 (
a INT,
b INT
)
ENGINE=InnoDB
PARTITION BY RANGE COLUMNS(a,b)
SUBPARTITION BY KEY(a,b)
SUBPARTITIONS 2 (
PARTITION p0 VALUES LESS THAN (10000,12),
PARTITION p1 VALUES LESS THAN (MAXVALUE, MAXVALUE)
);
INSERT INTO t6 VALUES (9585,5);
ALTER TABLE t6 CHANGE a a INT AFTER b, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
CREATE TABLE t7 (
f1 INT(11) NOT NULL,
f2 INT(11) NOT NULL,
f3 INT(11) NOT NULL,
f4 INT(11) NOT NULL,
f5 INT(11) NOT NULL
)
ENGINE=InnoDB
PARTITION BY KEY (f1,f5) PARTITIONS 2;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t7 VALUES (9585,10,20,10,5);
ALTER TABLE t7 CHANGE f5 f5 INT AFTER f3, ALGORITHM=INPLACE;
CHECK TABLE t7;
Table	Op	Msg_type	Msg_text
test.t7	check	status	OK
ALTER TABLE t7 CHANGE f5 f5 INT AFTER f2, ALGORITHM=INPLACE;
CHECK TABLE t7;
Table	Op	Msg_type	Msg_text
test.t7	check	status	OK
ALTER TABLE t7 CHANGE f1 f1 INT AFTER f4, ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
# Coverage tests for Native InnoDB Partitioning
#
# Test enable/disable keys.
#
CREATE TABLE t1 (a int, b int, primary key (a), key (b))
ENGINE = InnoDB
PARTITION BY HASH (a) PARTITIONS 3;
INSERT INTO t1 VALUES (1,1),(2,1),(3,3),(4,1),(5,3),(6,1),(7,1),(8,1),(9,4),
(10,1),(11,3),(12,1),(13,3),(14,1),(15,1),(16,3),(17,1),(18,1),(19,1),(20,3);
EXPLAIN SELECT * FROM t1 WHERE b = 4;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p0,p1,p2	ref	b	b	5	const	1	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 4)
ALTER TABLE t1 DISABLE KEYS;
Warnings:
Note	1031	Table storage engine for 't1' doesn't have this option
INSERT INTO t1 VALUES (21,1),(22,1),(23,3),(24,1);
EXPLAIN SELECT * FROM t1 WHERE b = 4;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p0,p1,p2	ref	b	b	5	const	1	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 4)
ALTER TABLE t1 ENABLE KEYS;
Warnings:
Note	1031	Table storage engine for 't1' doesn't have this option
EXPLAIN SELECT * FROM t1 WHERE b = 4;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p0,p1,p2	ref	b	b	5	const	1	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` = 4)
DROP TABLE t1;
#
# Test with different key sizes
#
CREATE TABLE t1
(a int NOT NULL,
b int NOT NULL,
c varchar(10) NOT NULL,
INDEX(a),
UNIQUE KEY  (c(5), a, b)
)
ENGINE=InnoDB
PARTITION BY HASH (b) PARTITIONS 2;
SELECT * FROM t1 WHERE a = '92' AND c = '0.73';
a	b	c
SELECT * FROM t1 WHERE a = '1224';
a	b	c
DROP TABLE t1;
#
# Test with index_merge using PK
#
CREATE TABLE t1
(
a int NOT NULL,
b int NOT NULL DEFAULT 2,
c int NOT NULL DEFAULT 3,
PRIMARY KEY (a),
INDEX i2(b),
INDEX i3(c)
)
ENGINE = InnoDB
PARTITION BY HASH (a) PARTITIONS 3;
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
INSERT INTO t1 (a) SELECT a+8 FROM t1;
UPDATE t1 SET b=a,c=a;
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
EXPLAIN SELECT * FROM t1 WHERE a=3 OR b=4;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	p0,p1,p2	index_merge	PRIMARY,i2	PRIMARY,i2	4,4	NULL	#	100.00	Using union(PRIMARY,i2); Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`a` = 3) or (`test`.`t1`.`b` = 4))
SELECT * FROM t1 WHERE a=3 OR b=4;
a	b	c
3	3	3
4	4	4
DROP TABLE t1;
#
# Test error handling in mysql_admin
#
CREATE TABLE t1 (a int)
PARTITION BY LINEAR HASH (a) PARTITIONS 8;
LOAD INDEX INTO CACHE t1 PARTITION (ALL);
Table	Op	Msg_type	Msg_text
test.t1	preload_keys	note	The storage engine for the table doesn't support preload_keys
ALTER TABLE t1 COALESCE PARTITION 2;
DROP TABLE t1;
#
# Bug #17299181  CREATE_TIME AND UPDATE_TIME ARE
#                WRONG FOR PARTITIONED TABLES
#
CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB
PARTITION BY HASH (a) PARTITIONS 2;
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
CREATE_TIME IS NOT NULL AND TABLE_NAME='t1';
COUNT(*)
1
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
CREATE_TIME IS NOT NULL AND UPDATE_TIME IS NOT NULL
AND TABLE_NAME='t1' OR FALSE;
COUNT(*)
1
DROP TABLE t1;
#
# Bug#20160327 OPTIMIZE TABLE REMOVES THE DATA DIRECTORY IN PARTITIONS
#
CREATE TABLE `t1` (
`f1` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`f2` MEDIUMTEXT NOT NULL,
`f3` CHAR(100) NOT NULL,
`f4` TINYINT(1) unsigned NOT NULL,
PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1
PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir' ENGINE = InnoDB);
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir/' ENGINE = InnoDB) */
OPTIMIZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
test.t1	optimize	status	OK
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir/' ENGINE = InnoDB) */
t1#p#p1.ibd
t1#p#p0.ibd
ALTER TABLE t1 OPTIMIZE PARTITION p0;
Table	Op	Msg_type	Msg_text
test.t1	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
test.t1	optimize	status	OK
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir/' ENGINE = InnoDB) */
t1#p#p1.ibd
t1#p#p0.ibd
ALTER TABLE t1 OPTIMIZE PARTITION p1;
Table	Op	Msg_type	Msg_text
test.t1	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
test.t1	optimize	status	OK
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir/' ENGINE = InnoDB) */
t1#p#p1.ibd
t1#p#p0.ibd
ALTER TABLE t1 REBUILD PARTITION ALL;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir/' ENGINE = InnoDB) */
t1#p#p1.ibd
t1#p#p0.ibd
ALTER TABLE t1 ADD extracol VARCHAR(32) NULL;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int unsigned NOT NULL AUTO_INCREMENT,
  `f2` mediumtext NOT NULL,
  `f3` char(100) NOT NULL,
  `f4` tinyint unsigned NOT NULL,
  `extracol` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`f1`,`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (`f4`)
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB,
 PARTITION p1 VALUES IN (1) DATA DIRECTORY = 'MYSQL_TMP_DIR/temp_dir' ENGINE = InnoDB) */
t1#p#p1.ibd
t1#p#p0.ibd
DROP TABLE t1;

Bug #25942592    INNODB: FAILING ASSERTION: INDEX->PAGE != 0XFFFFFFFF
IN BTR0CUR.CC LINE 816

call mtr.add_suppression("Missing .ibd file for table");
CREATE TABLE t1(c1 INT,c2 CHAR (1),c3 DATE) ENGINE=InnoDB PARTITION BY HASH
(TO_DAYS(c3)) PARTITIONS 12;
ALTER TABLE t1 ADD INDEX(c1);
ALTER TABLE t1 DISCARD PARTITION p2 TABLESPACE;
SELECT COUNT(*)FROM t1,t1 AS b WHERE t1.c1=''AND t1.c2=b.c1;
ERROR HY000: Tablespace has been discarded for table 't1'
CREATE TABLE t2 (c1 int,c2 CHAR (1),c3 date,key(c1)) ENGINE=InnoDB
PARTITION BY RANGE (TO_DAYS(c3))
(
PARTITION p0 VALUES LESS THAN (TO_DAYS('1979-01-01')),
PARTITION p1 VALUES LESS THAN (TO_DAYS('1989-01-01')),
PARTITION p2 VALUES LESS THAN (TO_DAYS('1999-01-01'))
);
ALTER TABLE t2 DISCARD PARTITION p2 TABLESPACE;
SELECT COUNT(*)FROM t2,t2 AS b WHERE t2.c1=''AND t2.c2=b.c1;
ERROR HY000: Tablespace has been discarded for table 't2'
DROP TABLE t1,t2;

Bug #26034430    ASSERTION `PART_REC_BUF_PTR' FAILED.


CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, PRIMARY KEY(a,b)) PARTITION BY RANGE (a)(PARTITION x1 VALUES LESS THAN (1));
SELECT * FROM t1 WHERE (a = 1 and b = 1 and c = 'b') OR (a > 2) ORDER BY a DESC;
a	b	c
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: 'b'
CREATE TABLE t(id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, dttm DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, msg
TEXT,PRIMARY KEY (id,dttm))ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 ROW_FORMAT=DYNAMIC PARTITION BY RANGE
COLUMNS(dttm) (PARTITION pf_201612 VALUES LESS THAN ('20170101') ENGINE = INNODB);
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
SELECT * FROM t WHERE dttm > '2017-01-19' ORDER BY id DESC;
id	dttm	msg
DROP TABLE t,t1;

Bug #26731025	INNODB PARTITION TABLE WILL LOCK INTO THE NEAR RECORD AS A CONDITION IN THE USE


create table test12 (name varchar(30),age bigint,grade bigint,date datetime
not null,partition_id int not null,
PRIMARY KEY (`name`,`PARTITION_ID`),
KEY `IDX_DATE` (`date`,`name`,`partition_id`),
KEY `IDX_AGE` (`age`,`partition_id`) ) PARTITION BY RANGE
COLUMNS(PARTITION_ID)
(PARTITION p0 VALUES LESS THAN (0) ENGINE = InnoDB,
PARTITION P1 VALUES LESS THAN (1) ENGINE = InnoDB,
PARTITION P2 VALUES LESS THAN (2) ENGINE = InnoDB,
PARTITION P3 VALUES LESS THAN (3) ENGINE = InnoDB,
PARTITION P4 VALUES LESS THAN (4) ENGINE = InnoDB,
PARTITION P5 VALUES LESS THAN (5) ENGINE = InnoDB,
PARTITION P6 VALUES LESS THAN (6) ENGINE = InnoDB,
PARTITION P7 VALUES LESS THAN (7) ENGINE = InnoDB,
PARTITION P8 VALUES LESS THAN (8) ENGINE = InnoDB,
PARTITION P9 VALUES LESS THAN (9) ENGINE = InnoDB);
insert into test12 values('Tom1',20,1,'2017-08-25
12:12:12',1),('Tom2',21,1,'2017-08-25 12:12:12',1),('Tom3',23,1,'2017-08-25
12:12:12',1);
Warnings:
Warning	4095	Delimiter '\n' in position 10 in datetime value '2017-08-25
12:12:12' at row 1 is deprecated. Prefer the standard ' '.
Warning	4095	Delimiter '\n' in position 10 in datetime value '2017-08-25
12:12:12' at row 3 is deprecated. Prefer the standard ' '.
begin;
update test12 set grade=3,date=now()  where age=23 and
partition_id=1;
begin;
update test12 set grade=1,date=now()  where age=21 and
partition_id=1;
begin;
update test12 set grade=0,date=now()  where age=20 and
partition_id=1;
drop table test12;
#
# Bug#27073100: PARTITION UPDATE_TIME NOT CORRECT AFTER RESTART/REBUILD
#
# Set up.
CREATE TABLE t1 (fld1 INT(11) NOT NULL, fld2 INT(11) NOT NULL,
fld3 DATE NOT NULL,  fld4 DATE NOT NULL,
PRIMARY KEY (fld1, fld3),  KEY(fld1)) PARTITION
BY RANGE (YEAR(fld3))
(PARTITION p01 VALUES LESS THAN (1985) ENGINE = InnoDB,
PARTITION p02 VALUES LESS THAN (1986) ENGINE = InnoDB,
PARTITION p03 VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 VALUES('11', '11111', '1984-11-16',
'2008-11-16'), ('12', '11112', '1985-11-16', '2008-11-16'),
('13', '11113', '1986-11-16', '2008-11-16');
# Fetch the count of 'update_time' which is not null.
SELECT TABLE_NAME, COUNT(UPDATE_TIME) FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1' ORDER BY
PARTITION_ORDINAL_POSITION;
TABLE_NAME	COUNT(UPDATE_TIME)
t1	3
# Rebuild the table.
ALTER TABLE t1 ENGINE=INNODB;
# After table rebuild, the 'update_time' will be set to NULL.
# Hence the count would return 0.
SELECT TABLE_NAME, COUNT(UPDATE_TIME) FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1' ORDER BY
PARTITION_ORDINAL_POSITION;
TABLE_NAME	COUNT(UPDATE_TIME)
t1	0
# Update the table where partition p02 is updated.
UPDATE t1 SET fld2 = 71000 WHERE fld1 = 12 AND fld3 = '1985-11-16';
# Without fix, the count for 'update_time' will be 3. After fix,
# it will be 1 since only partition 'p02' is updated.
SELECT TABLE_NAME, COUNT(UPDATE_TIME)
FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA = 'test' AND
TABLE_NAME = 't1' ORDER BY PARTITION_ORDINAL_POSITION;
TABLE_NAME	COUNT(UPDATE_TIME)
t1	1
DROP TABLE t1;

BUG#26553164 - INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK

CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`dt` datetime NOT NULL,
`data` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`,`dt`),
KEY `idx_dt` (`dt`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (to_days(dt))
(PARTITION p20170218 VALUES LESS THAN (736744) ENGINE = InnoDB,
PARTITION p20170219 VALUES LESS THAN (736745) ENGINE = InnoDB,
PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 VALUES (1, '2018-04-25 10:18:00', '1');
INSERT INTO t1 VALUES (2, '2018-04-25 10:18:01', '2');
INSERT INTO t1 VALUES (3, '2018-04-25 10:18:02', '3');
SELECT * FROM t1;
id	dt	data
1	2018-04-25 10:18:00	1
2	2018-04-25 10:18:01	2
3	2018-04-25 10:18:02	3
begin;
UPDATE t1 SET data = '11' WHERE id = 1;
begin;
UPDATE t1 SET data = '22' WHERE id = 2;
commit;
SELECT * FROM t1;
id	dt	data
1	2018-04-25 10:18:00	11
2	2018-04-25 10:18:01	22
3	2018-04-25 10:18:02	3
DROP TABLE t1;
#
# WL#1074 - Descending index support.
#
CREATE TABLE t1
(a VARCHAR(10),
b VARCHAR(10),
PRIMARY KEY (a DESC, b DESC),
KEY ab_asc (a ASC, b ASC),
KEY a_asc_b_desc (a ASC, b DESC),
key a_desc_b_asc (a DESC, b ASC))
ENGINE = InnoDB
PARTITION BY KEY (a, b) PARTITIONS 3;
INSERT INTO t1 VALUES ("0", "0"), ("1", "1"), ("2", "2"), ("3", "3"),
("4", "4"), ("55", "55"), ("54", "54"), ("1", "2"), ("1", "4"), ("1", "3"),
("55", "54"), ("0", "1");
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# Test non ordered index access
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`PRIMARY`);
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`ab_asc`);
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`a_asc_b_desc`);
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`a_desc_b_asc`);
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
# Test sorted index access
FLUSH STATUS;
SELECT * FROM t1 ORDER BY a DESC, b DESC;
a	b
55	55
55	54
54	54
4	4
3	3
2	2
1	4
1	3
1	2
1	1
0	1
0	0
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 ORDER BY a, b;
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 ORDER BY a, b DESC;
a	b
0	1
0	0
1	4
1	3
1	2
1	1
2	2
3	3
4	4
54	54
55	55
55	54
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 ORDER BY a DESC, b;
a	b
55	54
55	55
54	54
4	4
3	3
2	2
1	1
1	2
1	3
1	4
0	0
0	1
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a DESC, b DESC;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "PRIMARY",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b` desc
EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a, b;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "ab_asc",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b`
EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a, b DESC;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "a_asc_b_desc",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a`,`test`.`t1`.`b` desc
EXPLAIN FORMAT=JSON SELECT * FROM t1 ORDER BY a DESC, b;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "a_desc_b_asc",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` order by `test`.`t1`.`a` desc,`test`.`t1`.`b`
# Test index access in different sort order
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a, b;
a	b
0	0
0	1
1	1
1	2
1	3
1	4
2	2
3	3
4	4
54	54
55	54
55	55
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_key	3
Handler_read_last	3
Handler_read_prev	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a DESC, b;
a	b
55	54
55	55
54	54
4	4
3	3
2	2
1	1
1	2
1	3
1	4
0	0
0	1
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a, b DESC;
a	b
0	1
0	0
1	4
1	3
1	2
1	1
2	2
3	3
4	4
54	54
55	55
55	54
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
FLUSH STATUS;
SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a DESC, b;
a	b
55	54
55	55
54	54
4	4
3	3
2	2
1	1
1	2
1	3
1	4
0	0
0	1
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	1
Handler_external_lock	2
Handler_read_first	3
Handler_read_key	3
Handler_read_next	12
EXPLAIN FORMAT=JSON SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a, b;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "PRIMARY",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "backward_index_scan": true,
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`a`,`test`.`t1`.`b`
EXPLAIN FORMAT=JSON SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a DESC, b;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "X"
      },
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "PRIMARY",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`a` desc,`test`.`t1`.`b`
EXPLAIN FORMAT=JSON SELECT * FROM t1 FORCE INDEX (`PRIMARY`) ORDER BY a, b DESC;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "X"
    },
    "ordering_operation": {
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "X"
      },
      "table": {
        "table_name": "t1",
        "partitions": [
          "p0",
          "p1",
          "p2"
        ],
        "access_type": "index",
        "key": "PRIMARY",
        "used_key_parts": [
          "a",
          "b"
        ],
        "key_length": "84",
        "rows_examined_per_scan": "X",
        "rows_produced_per_join": "X",
        "filtered": "X",
        "using_index": true,
        "cost_info": {
          "read_cost": "X",
          "eval_cost": "X",
          "prefix_cost": "X",
          "data_read_per_join": "X"
        },
        "used_columns": [
          "a",
          "b"
        ]
      }
    }
  }
}
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` FORCE INDEX (PRIMARY) order by `test`.`t1`.`a`,`test`.`t1`.`b` desc
# Test HANDLER statements.
FLUSH STATUS;
HANDLER t1 OPEN;
HANDLER t1 READ `PRIMARY` FIRST;
a	b
55	55
HANDLER t1 READ `PRIMARY` NEXT;
a	b
55	54
HANDLER t1 READ `PRIMARY` NEXT;
a	b
54	54
HANDLER t1 READ `PRIMARY` NEXT;
a	b
4	4
HANDLER t1 READ `PRIMARY` NEXT;
a	b
3	3
HANDLER t1 READ `PRIMARY` LAST;
a	b
0	0
HANDLER t1 READ `PRIMARY` PREV;
a	b
0	1
HANDLER t1 READ `PRIMARY` PREV;
a	b
1	1
HANDLER t1 READ `PRIMARY` PREV;
a	b
1	2
HANDLER t1 READ ab_asc FIRST;
a	b
0	0
HANDLER t1 READ ab_asc NEXT;
a	b
0	1
HANDLER t1 READ ab_asc NEXT;
a	b
1	1
HANDLER t1 READ ab_asc NEXT;
a	b
1	2
HANDLER t1 READ ab_asc NEXT;
a	b
1	3
HANDLER t1 READ ab_asc LAST;
a	b
55	55
HANDLER t1 READ ab_asc PREV;
a	b
55	54
HANDLER t1 READ ab_asc PREV;
a	b
54	54
HANDLER t1 READ ab_asc PREV;
a	b
4	4
HANDLER t1 CLOSE;
SHOW STATUS WHERE Variable_name LIKE 'Handler%' AND Value >0;
Variable_name	Value
Handler_commit	18
Handler_external_lock	36
Handler_read_first	6
Handler_read_key	12
Handler_read_last	6
Handler_read_next	8
Handler_read_prev	6
DROP TABLE t1;