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
|
set @save_persistent=@@global.innodb_stats_persistent;
set global innodb_stats_persistent= 0;
call mtr.add_suppression("need more HISTORY partitions");
set system_versioning_alter_history=keep;
# Check conventional partitioning on temporal tables
create or replace table t1 (
x int,
row_start SYS_DATATYPE as row start invisible,
row_end SYS_DATATYPE as row end invisible,
period for system_time(row_start, row_end))
with system versioning
partition by range columns (x) (
partition p0 values less than (100),
partition p1 values less than (1000));
insert into t1 values (3), (300);
select * from t1;
x
3
300
select * from t1 partition (p0);
x
3
select * from t1 partition (p1);
x
300
delete from t1;
select * from t1;
x
select * from t1 partition (p0);
x
select * from t1 partition (p1);
x
select * from t1 for system_time all;
x
3
300
select * from t1 partition (p0) for system_time all;
x
3
select * from t1 partition (p1) for system_time all;
x
300
# Engine change native <-> non-native versioning prohibited
create or replace table t1 (
i int,
row_start SYS_DATATYPE as row start invisible,
row_end SYS_DATATYPE as row end invisible,
period for system_time(row_start, row_end))
engine=DEFAULT_ENGINE
with system versioning partition by hash(i);
alter table t1 engine=NON_DEFAULT_ENGINE;
ERROR HY000: Not allowed for system-versioned `test`.`t1`. Change to/from native system versioning engine is not supported.
## CREATE TABLE
create or replace table t1 (x int)
partition by system_time (
partition p0 history,
partition pn current);
ERROR HY000: Table `t1` is not system-versioned
create or replace table t1 (x int);
alter table t1
partition by system_time (
partition p0 history,
partition pn current);
ERROR HY000: Table `t1` is not system-versioned
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 current,
partition p1 current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 history,
partition p1 history);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition pn current,
partition p0 history);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0,
partition pn current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 history,
partition pn current);
## ALTER TABLE
alter table t1 add partition (
partition p1 current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
alter table t1 add partition (
partition p1 history);
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
(PARTITION `p0` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
insert into t1 values (1), (2);
alter table t1 drop partition pn;
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
alter table t1 drop partition p1;
alter table t1 drop partition p0;
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
select x from t1;
x
1
2
# rename works
create or replace table t1 (x int) with system versioning
partition by system_time;
alter table t1 reorganize partition p0 into
(partition custom_name history);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
(PARTITION `custom_name` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
# merge and split doesn't (MDEV-19938)
create or replace table t1 (x int) with system versioning
partition by system_time limit 10 partitions 3;
alter table t1 reorganize partition p0, p1 into (partition p00 history);
ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
alter table t1 reorganize partition p1 into (partition p1 history, partition p2 history);
ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
# Bug tempesta-tech/mariadb#260: incorrect IB partitioning warning
create or replace table t1 (x int)
with system versioning
partition by system_time limit 1;
alter table t1 change x big int;
create or replace table t1 (i int) engine myisam partition by hash(i) partitions 2;
alter table t1 add partition (partition px history);
ERROR HY000: Wrong partitioning type, expected type: `SYSTEM_TIME`
## INSERT, UPDATE, DELETE
create or replace table t1 (x int)
with system versioning
partition by system_time;
set @now= now(6);
insert into t1 values (1);
set @str= concat('select x, row_start < @now as A, row_end > @now as B from t1 partition (p0)');
prepare select_p0 from @str;
set @str= concat('select x, row_start > @now as C, row_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
prepare select_pn from @str;
execute select_p0;
x A B
execute select_pn;
x C D
1 1 1
set @str= concat('select row_start from t1 partition (pn) into @ts0');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
set @now= now(6);
delete from t1;
execute select_p0;
x A B
1 1 1
execute select_pn;
x C D
set @str= concat('select row_start from t1 partition (p0) into @ts1');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
select @ts0 = @ts1;
@ts0 = @ts1
1
set @now= now(6);
insert into t1 values (2);
execute select_p0;
x A B
1 1 0
execute select_pn;
x C D
2 1 1
set @str= concat('select row_start from t1 partition (pn) into @ts0');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
set @now= now(6);
update t1 set x = x + 1;
execute select_p0;
x A B
1 1 0
2 1 1
execute select_pn;
x C D
3 1 1
drop prepare select_p0;
drop prepare select_pn;
set @str= concat('select row_start from t1 partition (p0) where x = 2 into @ts1');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
set @str= concat('select row_end from t1 partition (p0) where x = 2 into @ts2');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
set @str= concat('select row_start from t1 partition (pn) into @ts3');
prepare stmt from @str;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
execute stmt;
drop prepare stmt;
select @ts0 = @ts1;
@ts0 = @ts1
1
select @ts2 = @ts3;
@ts2 = @ts3
1
## rotation by LIMIT
create or replace table t1 (x int)
with system versioning
partition by system_time limit 0 partitions 3;
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
create or replace table t1 (x int)
with system versioning
partition by system_time limit 2 partitions 3;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 2
PARTITIONS 3
alter table t1 drop partition non_existent;
ERROR HY000: Error in list of partitions to DROP
insert into t1 values (1), (2), (3), (4), (5), (6);
select * from t1 partition (pn);
x
1
2
3
4
5
6
delete from t1 where x < 4;
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select * from t1 partition (p0);
x
1
2
3
select * from t1 partition (p1);
x
4
5
6
insert into t1 values (7), (8);
### warn about full partition
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select * from t1 partition (p1) order by x;
x
4
5
6
7
8
## rotation by INTERVAL
create or replace table t1 (x int)
with system versioning
partition by system_time interval 0 second partitions 3;
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
create table t1 (i int) with system versioning
partition by system_time interval 6 day limit 98;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'limit 98' at line 2
create or replace table t1 (pk int) with system versioning
partition by system_time interval 10 year partitions 3;
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
# INTERVAL and ALTER TABLE
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 hour;
set @ts=(select partition_description from information_schema.partitions
where table_schema='test' and table_name='t1' and partition_name='p0');
alter table t1 add column b int;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p0 1 SYSTEM_TIME 00:00:00.000000
pn 2 SYSTEM_TIME NULL
Warnings:
Warning 1292 Incorrect time value: 'CURRENT'
alter table t1 add partition (partition p1 history, partition p2 history);
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p0 1 SYSTEM_TIME 00:00:00.000000
p1 2 SYSTEM_TIME 01:00:00.000000
p2 3 SYSTEM_TIME 02:00:00.000000
pn 4 SYSTEM_TIME NULL
Warnings:
Warning 1292 Incorrect time value: 'CURRENT'
alter table t1 drop partition p0;
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p1 1 SYSTEM_TIME 01:00:00.000000
p2 2 SYSTEM_TIME 02:00:00.000000
pn 3 SYSTEM_TIME NULL
Warnings:
Warning 1292 Incorrect time value: 'CURRENT'
alter table t1 drop partition p2;
ERROR HY000: Can only drop oldest partitions when rotating by INTERVAL
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
partition_name partition_ordinal_position partition_method timediff(partition_description, @ts)
p1 1 SYSTEM_TIME 01:00:00.000000
p2 2 SYSTEM_TIME 02:00:00.000000
pn 3 SYSTEM_TIME NULL
Warnings:
Warning 1292 Incorrect time value: 'CURRENT'
set timestamp=unix_timestamp('2001-02-03 10:20:30');
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day
subpartition by key (i) subpartitions 2
(partition p1 history, partition pn current);
set timestamp=unix_timestamp('2001-02-03 10:20:40');
insert t1 values (1);
delete from t1;
set timestamp=unix_timestamp('2001-02-04 10:20:50');
insert t1 values (2);
delete from t1;
select subpartition_name,partition_description,table_rows from information_schema.partitions where table_schema='test' and table_name='t1';
subpartition_name partition_description table_rows
p1sp0 2001-02-04 00:00:00 1
p1sp1 2001-02-04 00:00:00 1
pnsp0 CURRENT 0
pnsp1 CURRENT 0
set timestamp=unix_timestamp('2001-02-04 10:20:55');
alter table t1 add partition (partition p0 history, partition p2 history);
set timestamp=unix_timestamp('2001-02-04 10:30:00');
insert t1 values (4),(5);
set timestamp=unix_timestamp('2001-02-04 10:30:10');
update t1 set i=6 where i=5;
select subpartition_name,partition_description,table_rows from information_schema.partitions where table_schema='test' and table_name='t1';
subpartition_name partition_description table_rows
p1sp0 2001-02-04 00:00:00 1
p1sp1 2001-02-04 00:00:00 0
p0sp0 2001-02-05 00:00:00 1
p0sp1 2001-02-05 00:00:00 1
p2sp0 2001-02-06 00:00:00 0
p2sp1 2001-02-06 00:00:00 0
pnsp0 CURRENT 0
pnsp1 CURRENT 2
## pruning check
set @ts=(select partition_description from information_schema.partitions
where table_schema='test' and table_name='t1' and partition_name='p0' limit 1);
select * from t1;
i
4
6
explain partitions select * from t1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL # Using where
explain partitions select * from t1 for system_time as of '2001-02-04 10:20:30';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p2_p2sp0,p2_p2sp1,pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL # Using where
set @ts=(select row_end from t1 for system_time all where i=1);
select * from t1 for system_time all where row_end = @ts;
i
1
explain partitions select * from t1 for system_time all where row_end = @ts;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1_p1sp0,p1_p1sp1 # NULL NULL NULL NULL # #
#
# MDEV-16023 Unfortunate error message WARN_VERS_PART_FULL
#
set timestamp= unix_timestamp('2020-07-29 10:30:10');
create or replace table t1 (a int) with system versioning
partition by system_time interval 1 second (
partition p0 history,
partition p1 history,
partition pc current
);
set timestamp= unix_timestamp('2020-07-29 10:30:14');
insert into t1 values (1),(2),(3);
show warnings;
Level Code Message
# Cleanup
set timestamp= default;
## INTERVAL ... STARTS
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts 'a';
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '00:00:00';
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-00-01 00:00:00';
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts 946684800;
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'STARTS'
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:00';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
PARTITIONS 2
# Test STARTS warning
set timestamp= unix_timestamp('2000-01-01 00:00:00');
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:01';
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
# Test default STARTS rounding
set timestamp= unix_timestamp('1999-12-15 13:33:33');
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 second;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 SECOND STARTS TIMESTAMP'1999-12-15 13:33:33'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 minute;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 MINUTE STARTS TIMESTAMP'1999-12-15 13:33:00'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 hour;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR STARTS TIMESTAMP'1999-12-15 13:00:00'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-15 00:00:00'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 month;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 MONTH STARTS TIMESTAMP'1999-12-15 00:00:00'
PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 year;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 YEAR STARTS TIMESTAMP'1999-12-15 00:00:00'
PARTITIONS 2
# seconds equivalent of 1 day does not round:
create or replace table t1 (i int) with system versioning
partition by system_time interval 86400 second;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 86400 SECOND STARTS TIMESTAMP'1999-12-15 13:33:33'
PARTITIONS 2
# STARTS value is in local time_zone:
set time_zone="+03:00";
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:00';
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
set timestamp= unix_timestamp('2000-01-01 00:00:00');
create or replace table t2 (i int) with system versioning
partition by system_time interval 1 day;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
PARTITIONS 2
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'2000-01-01 00:00:00'
PARTITIONS 2
set time_zone="+00:00";
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-31 21:00:00'
PARTITIONS 2
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 1 DAY STARTS TIMESTAMP'1999-12-31 21:00:00'
PARTITIONS 2
# Test rotation
set timestamp= unix_timestamp('2001-01-01 00:00:00');
# it's ok to add partitions for past:
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:00'
partitions 3;
# we are warned when we push to present:
insert into t1 values (0);
set timestamp= unix_timestamp('2001-01-01 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2001-01-01 00:00:02');
update t1 set i= i + 1;
select *, row_end from t1 partition (p0);
i row_end
select *, row_end from t1 partition (p1);
i row_end
0 2001-01-01 00:00:01.000000
1 2001-01-01 00:00:02.000000
set timestamp= unix_timestamp('2000-01-01 00:00:00');
# now we "overflow" first partition a bit:
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-03 00:00:00'
partitions 3;
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
insert into t1 values (0);
set timestamp= unix_timestamp('2000-01-01 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-02 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-03 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-04 00:00:01');
update t1 set i= i + 1;
select *, row_end from t1 partition (p0);
i row_end
0 2000-01-01 00:00:01.000000
1 2000-01-02 00:00:01.000000
2 2000-01-03 00:00:01.000000
select *, row_end from t1 partition (p1);
i row_end
3 2000-01-04 00:00:01.000000
set timestamp= unix_timestamp('2000-01-01 00:00:00');
# and this is how it usually goes:
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day
partitions 3;
insert into t1 values (0);
set timestamp= unix_timestamp('2000-01-01 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-02 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-03 00:00:01');
update t1 set i= i + 1;
set timestamp= unix_timestamp('2000-01-04 00:00:01');
update t1 set i= i + 1;
alter table t1 add partition (partition p2 history, partition p3 history);
select *, row_end from t1 partition (p0);
i row_end
0 2000-01-01 00:00:01.000000
select *, row_end from t1 partition (p1);
i row_end
1 2000-01-02 00:00:01.000000
select *, row_end from t1 partition (p2);
i row_end
2 2000-01-03 00:00:01.000000
select *, row_end from t1 partition (p3);
i row_end
3 2000-01-04 00:00:01.000000
drop tables t1, t2;
## Subpartitions
create or replace table t1 (x int)
with system versioning
partition by system_time limit 2 partitions 3
subpartition by key (x)
subpartitions 2;
insert into t1 (x) values (1), (2), (3), (4), (5);
select * from t1 partition (pnsp0);
x
1
3
5
select * from t1 partition (pnsp1);
x
2
4
### warn about full partition
delete from t1 where x < 3;
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^ (no matter if nothing was deleted)
select * from t1 partition (p0sp0);
x
1
select * from t1 partition (p0sp1);
x
2
select * from t1 partition (p1sp0);
x
3
5
select * from t1 partition (p1sp1);
x
4
# check implicit sys fields for implicit engine of partitioned table
create or replace table t1 (a bigint)
with system versioning
partition by range (a)
(partition p0 values less than (20) engine innodb,
partition p1 values less than maxvalue engine innodb);
insert into t1 values (1);
select * from t1 partition (p0);
a
1
# check for partition engine
create or replace table t1 (
f_int1 integer default 0
) with system versioning
partition by range(f_int1)
subpartition by hash(f_int1)
( partition part1 values less than (1000)
(subpartition subpart11 storage engine = 'innodb',
subpartition subpart12 storage engine = 'innodb'));
insert into t1 values (1);
select * from t1 partition (part1);
f_int1
1
#
# TRX_ID versioning (moved from partition_innodb.test)
#
# MDEV-15951 system versioning by trx id doesn't work with partitioning
# currently trx_id does not support partitioning by system_time
create or replace table t1(
i int,
row_start bigint unsigned generated always as row start,
row_end bigint unsigned generated always as row end,
period for system_time(row_start, row_end)
) engine=InnoDB with system versioning partition by system_time (
partition p0 history,
partition pn current
);
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
create or replace table t1(
i int,
row_start bigint unsigned generated always as row start,
row_end bigint unsigned generated always as row end,
period for system_time(row_start, row_end)
) engine=InnoDB with system versioning;
alter table t1 partition by system_time (
partition p0 history,
partition pn current
);
ERROR HY000: `row_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
drop table t1;
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by key() (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by key(a, row_start) (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by hash(a + row_end * 2) (
partition p1,
partition p2
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
create or replace table t (
a int primary key,
row_start bigint unsigned as row start invisible,
row_end bigint unsigned as row end invisible,
period for system_time(row_start, row_end)
) engine=innodb with system versioning
partition by range columns (a, row_start) (
partition p1 values less than (100, 100)
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
#
# Assertion in ALTER on warning from partitioning LIMIT [#446]
#
create or replace table t1 (x int) with system versioning;
insert into t1 values (1), (2);
delete from t1;
alter table t1 partition by system_time limit 1 (
partition p1 history,
partition pn current);
#
# MDEV-14649 Assertion `t->mysql_col_len == 8' failed in row_insert_for_mysql
#
create or replace table t1 (i int) engine=innodb partition by key(i);
alter table t1 add system versioning;
insert into t1 values();
#
# MDEV-14722 Assertion in ha_commit_trans for sub-statement
#
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day;
create or replace table t2 (f int);
create or replace trigger tr before insert on t2
for each row select table_rows from information_schema.tables
where table_name = 't1' into @a;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
insert into t2 values (1);
#
# MDEV-14740 Locking assertion for system_time partitioning
#
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 week;
create or replace table t2 (f int);
create or replace trigger tr before insert on t2
for each row select count(*) from t1 into @a;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
insert into t2 values (1);
#
# MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES
#
create or replace table t1 (x int) with system versioning;
lock table t1 write;
alter table t1 partition by system_time interval 1 week (
partition p1 history,
partition pn current);
unlock tables;
#
# MDEV-14748 Assertion in ha_myisammrg::attach_children()
#
create or replace table t1 (x int) engine=myisam with system versioning
partition by system_time interval 1 month (partition p1 history, partition pn current);
create or replace table t2 (x int) engine=myisam;
create or replace table t3 (x int) engine=merge union=(t2);
create or replace table t4 (x int) engine=myisam;
create or replace trigger tr after insert on t4 for each row insert into t2
( select x from t3 ) union ( select x from t1 );
insert into t4 values (1);
#
# MDEV-14821 Assertion failure
#
create or replace table t1 (x int) with system versioning;
insert into t1 values (0), (1);
update t1 set x= x + 1;
alter table t1 partition by system_time limit 1 (
partition p1 history,
partition p2 history,
partition pn current);
delete from t1 where x = 1;
# You see warning above ^
delete from t1 where x = 2;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
#
# MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
#
create or replace table t1 (x int) with system versioning
partition by system_time;
lock table t1 write;
alter table t1 add partition (partition p0 history);
ERROR HY000: Duplicate partition name p0
insert into t1 values (1);
unlock tables;
#
# MDEV-15103 Assertion in ha_partition::part_records() for updating VIEW
#
create or replace table t1 (pk int primary key, f int) with system versioning
partition by system_time limit 100;
insert into t1 values (1,10), (2,20);
create or replace view v1 as select * from t1;
update v1 set f= 30;
#
# MDEV-15168 Unexpected ER_VERS_ENGINE_UNSUPPORTED upon dropping versioning on a partitioned table
#
create or replace table t (a int) with system versioning
partition by system_time;
alter table t drop system versioning;
ERROR HY000: Can not DROP SYSTEM VERSIONING for table `t` partitioned BY SYSTEM_TIME
#
# MDEV-15191 Assertion `bit < (map)->n_bits' failed in bitmap_is_set upon INSERT
#
create or replace table t1 (i int) with system versioning;
insert into t1 values (1), (2);
update t1 set i= 3;
alter table t1 partition by system_time interval 1 month (partition p1 history, partition pn current);
lock table t1 write;
alter table t1 add partition (partition p2 history);
insert into t1 values (4);
unlock tables;
#
# MDEV-15036 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' in Diagnostics_area::set_ok_status or unexpected ER_RANGE_NOT_INCREASING_ERROR
#
create or replace table t1 (a int) with system versioning
partition by system_time limit 2 partitions 4;
insert into t1 values (1),(2),(3);
update t1 set a = 4;
delete from t1;
delete from t1 where a is not null;
#
# MDEV-14823 Wrong error message upon selecting from a system_time partition
#
create or replace table t1 (i int) with system versioning partition by system_time limit 10;
select * from t1 partition (p0) for system_time all;
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
# MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED
create or replace procedure sp()
select * from t1 partition (p0) for system_time all;
call sp;
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
call sp;
ERROR HY000: SYSTEM_TIME partitions in table `t1` does not support historical query
drop procedure sp;
#
# MDEV-15380 Index for versioned table gets corrupt after partitioning and DELETE
#
create or replace table t1 (pk int primary key)
engine=myisam
with system versioning
partition by key() partitions 3;
set timestamp=1523466002.799571;
insert into t1 values (11),(12);
set timestamp=1523466004.169435;
delete from t1 where pk in (11, 12);
Same test but for Aria storage engine
create or replace table t1 (pk int primary key)
engine=aria
with system versioning
partition by key() partitions 3;
set timestamp=1523466002.799571;
insert into t1 values (11),(12);
set timestamp=1523466004.169435;
delete from t1 where pk in (11, 12);
#
# MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_arguments
#
create or replace table t1 (pk int) with system versioning
partition by system_time interval 7 second;
alter table t1
partition by system_time interval column_get(column_create(7,7), 7 as int) second (
partition ver_p1 history,
partition ver_pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`pk` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL 7 SECOND STARTS TIMESTAMP'2018-04-11 17:00:04'
(PARTITION `ver_p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `ver_pn` CURRENT ENGINE = DEFAULT_ENGINE)
set timestamp= default;
#
# MDEV-18794 Assertion `!m_innodb' failed in ha_partition::cmp_ref upon SELECT from partitioned table
#
create or replace table t1 (pk int auto_increment, i int, c char(1), primary key (pk), key(i))
engine=innodb with system versioning partition by key() partitions 2;
insert into t1 (i, c) values (1, 'a'), (2, 'b'), (null, 'c'), (null, 'b');
alter table t1 drop system versioning;
replace into t1 select * from t1;
select * from t1 where i > 0 or pk = 1000 limit 1;
pk i c
1 1 a
drop table t1;
#
# MDEV-19175 Server crashes in ha_partition::vers_can_native upon INSERT DELAYED into versioned partitioned table
#
create or replace table t1 (f int) with system versioning partition by hash(f);
insert delayed into t1 values (1);
#
# MDEV-20068 History partition rotation is not done under LOCK TABLES
#
create or replace table t1 (x int) with system versioning partition by system_time limit 1
(partition p1 history, partition pn current);
lock tables t1 write;
insert into t1 values (0), (1), (2), (3);
delete from t1 where x < 3;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
unlock tables;
#
# MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table
#
create or replace table t1 (pk int primary key) with system versioning partition by system_time limit 100 (partition p1 history, partition pn current);
execute immediate 'select * from t1 for update';
pk
#
# MDEV-19903 Setup default partitions for system versioning
#
create or replace table t1 (x int) with system versioning partition by system_time;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITIONS 2
# 2 partitions are created: p0 and pn
select PARTITION_NAME, PARTITION_METHOD, PARTITION_DESCRIPTION from information_schema.partitions where table_name = 't1' order by PARTITION_NAME;
PARTITION_NAME PARTITION_METHOD PARTITION_DESCRIPTION
p0 SYSTEM_TIME NULL
pn SYSTEM_TIME CURRENT
create or replace table t1 (x int) with system versioning partition by system_time limit 10 partitions 4;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 10
PARTITIONS 4
# 4 partitions are created: p0, p1, p2 and pn
select PARTITION_NAME, PARTITION_METHOD, PARTITION_DESCRIPTION from information_schema.partitions where table_name = 't1' order by PARTITION_NAME;
PARTITION_NAME PARTITION_METHOD PARTITION_DESCRIPTION
p0 SYSTEM_TIME NULL
p1 SYSTEM_TIME NULL
p2 SYSTEM_TIME NULL
pn SYSTEM_TIME CURRENT
# Test cleanup
drop view v1;
drop tables t, t1, t2, t3, t4;
#
# MDEV-18957 UPDATE with LIMIT clause is wrong for versioned partitioned tables
#
create or replace table t1 (
x int,
a varchar(255)
) with system versioning partition by system_time (partition p1 history, partition pn current);
insert into t1 (x) values (1), (2), (3), (4);
update t1 set a= 'foo' limit 3;
update t1 set a= 'bar' limit 4;
select * from t1;
x a
1 bar
2 bar
3 bar
4 bar
drop table t1;
#
# MDEV-21011 Table corruption reported for versioned partitioned table after DELETE: "Found a misplaced row"
#
create table t1 (a int) with system versioning
partition by system_time limit 3
(partition p1 history, partition p2 history, partition pn current);
insert into t1 values (1),(2),(3),(4);
delete from t1;
delete from t1;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
#
# MDEV-21233 Assertion `m_extra_cache' failed in ha_partition::late_extra_cache
#
create table t1 (id int, a varchar(8)) with system versioning partition by key (id) partitions 2;
insert into t1 values (1,'foo'),(2,'bar');
create table t2 (b int);
insert into t2 values (1),(2);
update t1, t2 set a = 1;
drop table t1, t2;
#
# MDEV-20515 multi-update tries to position updated table by null reference
#
create or replace table t1 (a int);
insert into t1 values (0), (1);
create or replace table t2 (b int) with system versioning
partition by system_time
(partition p1 history, partition pn current);
insert into t2 values (0), (2);
update t1 left join t2 on a > b set b= 2 order by b;
drop table t1, t2;
#
# MDEV-17091 Assertion `old_part_id == m_last_part' failed in
# ha_partition::update_row or `part_id == m_last_part' in
# ha_partition::delete_row upon UPDATE/DELETE after dropping versioning
#
create or replace table t1 (pk int primary key, f int) engine=innodb
with system versioning
partition by key() partitions 2;
insert into t1 values (1,10),(2,20);
# expected to hit same partition
select * from t1 partition (p0);
pk f
1 10
2 20
alter table t1 drop system versioning;
# 1 and 2 are expected to be in different partitions
select * from t1 partition(p0);
pk f
1 10
select * from t1 partition(p1);
pk f
2 20
update t1 set f=pk;
delete from t1;
drop table t1;
#
# MDEV-22413 Server hangs upon UPDATE/DELETE on a view reading from versioned partitioned table
#
create or replace table t1 (f char(6)) engine innodb with system versioning;
insert into t1 values (null);
update t1 set f= 'foo';
update t1 set f= 'bar';
# You see warning above ^
create or replace view v1 as select * from t1 for system_time all;
update v1 set f = '';
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
create or replace table t1 (f char(6)) engine innodb with system versioning
partition by system_time limit 1
(partition p1 history, partition p2 history, partition pn current);
insert into t1 values (null);
update t1 set f= 'foo';
update t1 set f= 'bar';
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions
create or replace view v1 as select * from t1 for system_time all;
update v1 set f= '';
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
delete from v1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
drop view v1;
drop table t1;
#
# MDEV-22112 Assertion `tab_part_info->part_type == RANGE_PARTITION || tab_part_info->part_type == LIST_PARTITION' failed in prep_alter_part_table
#
create table t1 (a int) with system versioning partition by system_time;
drop table t1;
create table t1 (a int) with system versioning partition by system_time
(partition p1 history, partition pn current);
alter table t1 add partition (partition p2);
ERROR HY000: Wrong partitioning type, expected type: `SYSTEM_TIME`
# MDEV-17891 Assertion failures in select_insert::abort_result_set and
# mysql_load upon attempt to replace into a full table
set @@max_heap_table_size= 1024*1024;
create or replace table t1 (
pk integer auto_increment,
primary key (pk),
f varchar(45000)
) with system versioning engine=memory
partition by system_time interval 1 year (partition p1 history,
partition pn current);
# fill the table until full
insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
insert into t1 (f) select f from t1;
ERROR HY000: The table 't1' is full
# leave space for exactly one record in current partition
delete from t1 where pk = 1;
# copy all data into history partition
replace into t1 select * from t1;
replace into t1 select * from t1;
ERROR HY000: The table 't1' is full
create or replace table t1 (
pk integer auto_increment,
primary key (pk),
f varchar(45000)
) with system versioning engine=memory
partition by system_time interval 1 year (partition p1 history,
partition pn current);
insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
select * into outfile 'load.data' from t1;
load data infile 'load.data' replace into table t1;
load data infile 'load.data' replace into table t1;
ERROR HY000: The table 't1' is full
load data infile 'load.data' replace into table t1;
ERROR HY000: The table 't1' is full
set @@max_heap_table_size= 1048576;
drop table t1;
#
# MDEV-22178 Assertion `info->alias.str' failed in partition_info::check_partition_info instead of ER_VERS_WRONG_PARTS
#
create or replace table t1 (a int) with system versioning;
alter table t1 partition by system_time (partition pn current);
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
drop table t1;
#
# MDEV-22247 History partition overflow leads to wrong SELECT result
#
set timestamp= unix_timestamp('2000-01-01 00:00:00');
create or replace table t1 (x int) with system versioning
partition by system_time interval 1 hour
(partition p0 history, partition p1 history, partition pn current);
insert into t1 values (0);
update t1 set x= x + 1;
set timestamp= unix_timestamp('2000-01-01 02:00:01');
update t1 set x= x + 1;
select *, row_start, row_end from t1 for system_time as of '2000-01-01 02:00:00';
x row_start row_end
1 2000-01-01 00:00:00.000000 2000-01-01 02:00:01.000000
explain partitions select * from t1 for system_time as of '2000-01-01 02:00:00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,pn ALL NULL NULL NULL NULL # Using where
explain partitions select * from t1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn # NULL NULL NULL NULL # #
drop table t1;
#
# MDEV-27244 Table corruption upon adding serial data type
#
create table t1 (f int, key(f)) with system versioning
partition by system_time limit 10 (partition p0 history, partition pn current);
alter table t1 add x serial;
alter table t1 add partition (partition p1 history);
alter table t1 add partition (partition p2 history);
drop table t1;
#
# MDEV-27217 DELETE partition selection doesn't work for history partitions
#
create table t1 (f char) with system versioning
partition by system_time limit 10 (
partition p0 history,
partition p1 history,
partition p2 history,
partition pn current);
delete from t1 partition (p1);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
delete from t1 partition (p0, pn);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
delete from t1 partition (p0, p1);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
delete from t1 partition (p0, p1, pn);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
drop table t1;
set timestamp=unix_timestamp('2000-01-01 00:00:00');
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day (
partition p0 history,
partition p1 history,
partition pn current);
set timestamp=unix_timestamp('2000-01-02 00:00:00');
insert t1 values (1);
delete from t1 partition (p0, pn);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
delete from t1 partition (p0, p1, pn);
ERROR HY000: Not allowed for system-versioned table `test`.`t1`
drop table t1;
set timestamp= default;
#
# MDEV-25546 LIMIT partitioning does not respect ROLLBACK
#
create or replace table t1 (pk int primary key)
with system versioning engine innodb
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_1_to_90;
start transaction;
replace into t1 select seq from seq_1_to_80;
replace into t1 select seq from seq_1_to_70;
replace into t1 select seq from seq_1_to_60;
select partition_name, table_rows
from information_schema.partitions
where table_name = 't1';
partition_name table_rows
p0 150
p1 60
pn 90
rollback;
select partition_name, table_rows
from information_schema.partitions
where table_name = 't1';
partition_name table_rows
p0 0
p1 0
pn 90
replace into t1 select seq from seq_1_to_10;
select partition_name, table_rows
from information_schema.partitions
where table_name = 't1';
partition_name table_rows
p0 10
p1 0
pn 90
drop table t1;
#
# MDEV-28271 Assertion on TRUNCATE PARTITION for PARTITION BY SYSTEM_TIME
#
create table t1 (x int) with system versioning
partition by system_time limit 1 (
partition p0 history,
partition p1 history,
partition p2 history, # p2 just disables warning about p1 partition full
partition pn current);
insert into t1 values (0);
update t1 set x= x + 1;
update t1 set x= x + 1;
select * from t1 partition (p0);
x
0
select * from t1 partition (p1);
x
1
select * from t1 partition (pn);
x
2
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions
delete history from t1;
select * from t1 partition (p0);
x
select * from t1 partition (p1);
x
select * from t1 partition (pn);
x
insert into t1 values (0);
update t1 set x= x + 1;
update t1 set x= x + 1;
# TRUNCATE PARTITION ALL does the same
alter table t1 truncate partition all;
select * from t1 partition (p0);
x
select * from t1 partition (p1);
x
select * from t1 partition (pn);
x
insert into t1 values (0);
update t1 set x= x + 1;
update t1 set x= x + 1;
# TRUNCATE PARTITION deletes data from HISTORY partition
alter table t1 truncate partition p1;
select * from t1 partition (p0);
x
0
select * from t1 partition (p1);
x
select * from t1 partition (pn);
x
2
# or from CURRENT partition
alter table t1 truncate partition pn;
select * from t1 partition (p0);
x
0
select * from t1 partition (p1);
x
select * from t1 partition (pn);
x
drop table t1;
#
# MDEV-20077 Warning on full history partition is delayed until next DML statement
#
# DELETE
create table t1 (x int) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_200;
# p0 is filled with 100 records (no warnings):
delete from t1 where x <= 99;
# p1 is filled with 1 + 100 records (warning is printed):
delete from t1 where x <= 100;
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
101
drop table t1;
# DELETE under LOCK TABLES
create table t1 (x int) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_200;
lock tables t1 write;
# (LOCK TABLES) p0 is filled with 100 records (no warnings):
delete from t1 where x <= 99;
# (LOCK TABLES) p1 is filled with 1 + 100 records (warning is printed):
delete from t1 where x <= 100;
delete from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
unlock tables;
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
101
drop table t1;
# DELETE multitable
create table t1 (x int) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
create table t2 (y int);
insert into t1 select seq from seq_0_to_200;
insert into t2 select seq from seq_0_to_3;
delete t1, t2 from t1 join t2 where x < 50 and y = 0;
delete t1, t2 from t1 join t2 where x < 100 and y = 1;
delete t1, t2 from t1 join t2 where x < 150 and y = 2;
delete t1, t2 from t1 join t2;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
101
drop table t1;
# UDPATE
create table t1 (x int) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_49;
update t1 set x= x + 1;
update t1 set x= x + 1;
update t1 set x= x + 1;
update t1 set x= x + 1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
100
drop tables t1, t2;
# UPDATE multitable
create table t1 (x int) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
create table t2 (y int);
insert into t1 select seq from seq_0_to_49;
insert into t2 values (5);
update t1, t2 set x= x + 1;
update t1, t2 set x= x + 1;
update t1, t2 set x= x + 1;
update t1, t2 set x= x + 1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
100
drop tables t1, t2;
# INSERT .. ON DUPLICATE KEY UPDATE (ODKU)
create table t1 (x int primary key) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_100;
delete from t1 where x <= 99;
insert into t1 values (100) on duplicate key update x= 400;
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
1
drop table t1;
# INSERT .. SELECT .. ON DUPLICATE KEY UPDATE (ODKU)
create table t1 (x int primary key) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
create table t2 (y int);
insert into t2 values (100);
insert into t1 select seq from seq_0_to_100;
delete from t1 where x <= 99;
insert into t1 select * from t2 on duplicate key update x= 500;
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
1
drop tables t1, t2;
# REPLACE
create table t1 (x int primary key) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_100;
delete from t1 where x < 99;
replace t1 values (100);
replace t1 values (100);
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
1
drop table t1;
# LOAD DATA .. REPLACE
create table t1 (x int primary key) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_49;
select x into outfile 'MDEV-20077.data' from t1;
load data infile 'MDEV-20077.data' replace into table t1 (x);
load data infile 'MDEV-20077.data' replace into table t1 (x);
load data infile 'MDEV-20077.data' replace into table t1 (x);
load data infile 'MDEV-20077.data' replace into table t1 (x);
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
100
drop table t1;
# REPLACE .. SELECT
create table t1 (x int primary key) with system versioning
partition by system_time limit 100 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 select seq from seq_0_to_49;
replace t1 select * from t1;
replace t1 select * from t1;
replace t1 select * from t1;
replace t1 select * from t1;
Warnings:
Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
select count(*) from t1 partition (p0);
count(*)
100
select count(*) from t1 partition (p1);
count(*)
100
drop table t1;
#
# MDEV-28552 Assertion `inited==RND' failed in handler::ha_rnd_end
#
create table tcount (c int unsigned);
insert into tcount values (0);
create table t (f int) with system versioning
partition by system_time limit 1000
(partition p1 history, partition pn current);
insert into t values (1),(2);
create trigger tr before insert on t for each row update tcount set c = c + 1;
insert into t select * from t;
drop table tcount, t;
#
# MDEV-19569 Assertion `table_list->table' failed in find_field_in_table_ref and Assertion `table_ref->table || table_ref->view' in Field_iterator_table_ref::set_field_iterator
#
set timestamp=unix_timestamp('2000-01-01 00:00:00');
create table t1 (i int);
create table t2 (i int);
alter table t1 partition by system_time
interval (select i from t2) day (partition p1 history, partition pn current);
ERROR 42000: INTERVAL does not support subqueries or stored functions
drop table t1;
create table t1 (id int) with system versioning
partition by system_time
interval (select i from t2) day (partition p1 history, partition pn current);
ERROR 42000: INTERVAL does not support subqueries or stored functions
create table t1 (id int) with system versioning
partition by system_time
interval "hello" day (partition p1 history, partition pn current);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
create table t1 (id int) with system versioning
partition by system_time
interval 3.893 day (partition p1 history, partition pn current);
drop table t1, t2;
create table t1 (id int) with system versioning
partition by system_time interval "3-11" year_month (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '3-11' YEAR_MONTH STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "3 11" day_hour (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '3 11' DAY_HOUR STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "3 11:12" day_minute (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '3 11:12' DAY_MINUTE STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "3 11:12:13" day_second (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '3 11:12:13' DAY_SECOND STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "11:12" hour_minute (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '11:12' HOUR_MINUTE STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "11:12:13" hour_second (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '11:12:13' HOUR_SECOND STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "12:13" minute_second (partition p1 history, partition pn current);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME INTERVAL '12:13' MINUTE_SECOND STARTS TIMESTAMP'2000-01-01 00:00:00'
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop table t1;
create table t1 (id int) with system versioning
partition by system_time interval "12:13.123" minute_microsecond (partition p1 history, partition pn current);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
#
# End of 10.3 tests
#
#
# MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
#
create table t1 (a int primary key) engine=aria page_checksum=0
with system versioning
partition by system_time (partition p1 history, partition pn current);
alter table t1 add partition (partition p2 history);
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
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 Max_index_length Temporary
t1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Got error 174 "Fatal error during initialization of handler" from storage engine Aria NULL NULL
Warnings:
Warning 1030 Got error 174 "Fatal error during initialization of handler" from storage engine Aria
drop table t1;
create table t1 (b int) engine=aria row_format=dynamic with system versioning
partition by system_time (partition p1 history, partition pn current);
insert into t1 values (1);
replace into t1 values (1);
drop table t1;
#
# MDEV-18794 Assertion `!m_innodb' failed in ha_partition::cmp_ref upon SELECT from partitioned table
#
create or replace table t1 (pk int auto_increment, i int, c char(1), primary key (pk), key(i))
engine=innodb with system versioning partition by key() partitions 2;
insert into t1 (i, c) values (1, 'a'), (2, 'b'), (null, 'c'), (null, 'b');
alter table t1 drop system versioning;
replace into t1 select * from t1;
select * from t1 where i > 0 or pk = 1000 limit 1;
pk i c
1 1 a
drop table t1;
#
# End of 10.4 tests
#
#
# MDEV-22153 ALTER add default history partitions makes table inaccessible
#
create or replace table t1 (x int) with system versioning partition by system_time;
alter table t1 add partition partitions 1;
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITIONS 3
alter table t1 add partition partitions 2;
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITIONS 5
alter table t1 add partition partitions 3;
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME
PARTITIONS 8
drop tables t1;
#
# MDEV-22207 Drop default history partitions renders table inaccessible
#
create or replace table t1 (i int) with system versioning
partition by system_time limit 1 partitions 5;
alter table t1 drop partition p0, p2;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
alter table t1 add partition partitions 1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p2` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop tables t1;
#
# MDEV-22155 ALTER add default history partitions name clash on non-default partitions
#
create or replace table t1 (x int) with system versioning
partition by system_time limit 1
(partition p2 history, partition p8 history, partition pn current);
alter table t1 add partition partitions 1;
alter table t1 add partition partitions 2;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p2` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p8` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p4` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p5` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
alter table t1 add partition partitions 8;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION `p2` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p8` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p4` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p5` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p9` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p10` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p11` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p12` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p13` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p14` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p15` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `p16` HISTORY ENGINE = DEFAULT_ENGINE,
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
drop tables t1;
#
# MDEV-29727 ALTER and CREATE with default partitioning
# differently react to SQL_MODE => unusable SHOW CREATE
#
create table t (a int) with system versioning;
alter table t partition by system_time partitions 3;
ERROR HY000: Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
drop table t;
create table t (a int) with system versioning partition by system_time partitions 3;
ERROR HY000: Maybe missing parameters: no rotation condition for multiple HISTORY partitions.
#
# End of 10.5 tests
#
set global innodb_stats_persistent= @save_persistent;
|