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
|
# Test the ability to remove AUTO_INCREMENT attribute
--source include/have_innodb.inc
--source include/have_partition.inc
CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t1 MODIFY c INT NULL, ALGORITHM=INSTANT;
INSERT INTO t1 SET c=1;
CREATE TABLE t2 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t2 MODIFY c INT NULL, FORCE, ALGORITHM=INPLACE;
INSERT INTO t2 SET c=1;
CREATE TABLE t3 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t3 MODIFY c INT NULL, ALGORITHM=INPLACE;
INSERT INTO t3 SET c=1;
CREATE TABLE t4 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB;
ALTER TABLE t4 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
INSERT INTO t4 SET c1=1;
CREATE TABLE t5 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT, c3 INTEGER GENERATED ALWAYS AS (c2)) ENGINE=InnoDB;
# ha_innobase::commit_inplace_alter_table() should invoke innobase_reload_table()
ALTER TABLE t5 MODIFY c1 INT NULL, MODIFY COLUMN c2 INT FIRST, ALGORITHM=INPLACE;
INSERT INTO t5 SET c1=1;
CREATE TABLE t6 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
PARTITION BY LIST(c) (
PARTITION p1 VALUES IN (1),
PARTITION p2 VALUES IN (2)
);
ALTER TABLE t6 MODIFY c INT NULL, ALGORITHM=INSTANT;
INSERT INTO t6 SET c=1;
INSERT INTO t6 SET c=2;
CREATE TABLE t7 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB
PARTITION BY LIST(c) (
PARTITION p1 VALUES IN (1),
PARTITION p2 VALUES IN (2)
);
ALTER TABLE t7 MODIFY c INT NULL, ALGORITHM=INPLACE;
INSERT INTO t7 SET c=1;
INSERT INTO t7 SET c=2;
CREATE TABLE t8 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB
PARTITION BY LIST(c1) (
PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t8 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE;
INSERT INTO t8 SET c1=1;
INSERT INTO t8 SET c1=2;
FLUSH TABLES t1, t2, t3, t4, t5, t6, t7, t8 FOR EXPORT;
--let INNODB_PAGE_SIZE=`select @@innodb_page_size`
--let MYSQLD_DATADIR = `SELECT @@datadir`
--perl
my $ps= $ENV{INNODB_PAGE_SIZE};
my $PAGE_HEADER = 38;
my $PAGE_ROOT_AUTO_INC = 18;
print "AUTO_INCREMENT not partitioned: ";
for (my $i = 1; $i <= 5; ++$i) {
my $autoinc= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i.ibd");
print "$autoinc ";
}
print "\n";
print "AUTO_INCREMENT partitioned: ";
for (my $i = 6; $i <= 8; ++$i) {
my $p1= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p1.ibd");
my $p2= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p2.ibd");
print "($p1, $p2) ";
}
print "\n";
sub read_autoinc {
my $file= shift;
open(FILE, "<", $file) || die "Unable to open $file\n";
sysseek(FILE, 3*$ps + $PAGE_HEADER + $PAGE_ROOT_AUTO_INC + 4, 0)
|| die "Unable to seek $file\n";
die "Unable to read $file\n" unless sysread(FILE, $_, 4) == 4;
my $t1=unpack("N",$_);
close(FILE);
return $t1;
}
EOF
UNLOCK TABLES;
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
|