Skip to content

Commit 7653cf1

Browse files
blauddendahlerlend
authored andcommitted
Bug#30766579 ADDING AN INDEX WITH INPLACE GENERATES
Add test for adding index on part of primary key using inplace alter table. Change-Id: Id2849c1cf429ca94317dbad89067b9d2c6e850fb
1 parent 58feb4b commit 7653cf1

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

mysql-test/suite/ndbcluster/alter_inplace_add_index.result

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,67 @@ a
1717
3
1818
37
1919
DROP TABLE t1;
20+
#
21+
# Bug#30766579 ADDING AN INDEX WITH INPLACE GENERATES
22+
# - test adding an index on first pk column using inplace alter
23+
#
24+
CREATE TABLE t1 (
25+
col1 varbinary(80) NOT NULL,
26+
pk2 varchar(46) NOT NULL,
27+
pk1 bigint(20) NOT NULL,
28+
col2 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
29+
col3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
30+
col4 varchar(320) CHARACTER SET utf8 NOT NULL,
31+
col5 varbinary(16) NOT NULL,
32+
col6 int(11) NOT NULL,
33+
col7 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
34+
col8 bigint(20) NOT NULL,
35+
col9 timestamp NULL DEFAULT NULL,
36+
col10 int(11) NOT NULL,
37+
col11 bit(1) NOT NULL,
38+
col12 binary(32) NOT NULL,
39+
col13 bit(1) NOT NULL DEFAULT b'0',
40+
col14 varchar(32) CHARACTER SET utf8 DEFAULT NULL,
41+
col15 bigint(10) DEFAULT NULL,
42+
col16 varchar(3) DEFAULT NULL,
43+
col17 bit(1) NOT NULL DEFAULT b'0',
44+
col18 bit(1) NOT NULL DEFAULT b'0',
45+
col19 varbinary(250) DEFAULT NULL,
46+
col20 varchar(20) DEFAULT NULL,
47+
col21 varchar(3) DEFAULT NULL,
48+
col22 int(11) DEFAULT NULL,
49+
PRIMARY KEY (pk1, pk2),
50+
UNIQUE KEY ix_pk2 (pk2),
51+
KEY ix_t1_col2 (col2),
52+
KEY ix_t1_col3 (col3),
53+
KEY ix_t1_pk1_col20 (pk1,col20),
54+
KEY ix_t1_pk1_col6 (pk1,col6)
55+
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
56+
PARTITION BY KEY (pk1);
57+
Warnings:
58+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
59+
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
60+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
61+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
62+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
63+
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
64+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
65+
Warning 1681 Integer display width is deprecated and will be removed in a future release.
66+
# Show indexes on t1
67+
SELECT index_name, columns FROM ndbinfo.index_columns
68+
WHERE table_name = 't1' ORDER BY index_name;
69+
index_name columns
70+
ix_pk2 pk2
71+
ix_pk2$unique pk2
72+
ix_t1_col2 col2
73+
ix_t1_col3 col3
74+
ix_t1_pk1_col20 pk1,col20
75+
ix_t1_pk1_col6 pk1,col6
76+
PRIMARY pk1,pk2
77+
ALTER TABLE t1 ALGORITHM = INPLACE, ADD INDEX ix_test (pk1);
78+
# Show that new index 'ix_test' was added to t1
79+
SELECT index_name, columns, index_type FROM ndbinfo.index_columns
80+
WHERE table_name = 't1' AND index_name = 'ix_test' ORDER BY index_name;
81+
index_name columns index_type
82+
ix_test pk1 6
83+
DROP TABLE t1;

mysql-test/suite/ndbcluster/alter_inplace_add_index.test

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,58 @@ ALTER TABLE t1 ALGORITHM=INPLACE, ADD INDEX c_idx1(c);
2121
SELECT a FROM t1 WHERE c > 8 ORDER by c;
2222

2323
DROP TABLE t1;
24+
25+
--echo #
26+
--echo # Bug#30766579 ADDING AN INDEX WITH INPLACE GENERATES
27+
--echo # - test adding an index on first pk column using inplace alter
28+
--echo #
29+
30+
CREATE TABLE t1 (
31+
col1 varbinary(80) NOT NULL,
32+
pk2 varchar(46) NOT NULL,
33+
pk1 bigint(20) NOT NULL,
34+
col2 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
35+
col3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
36+
col4 varchar(320) CHARACTER SET utf8 NOT NULL,
37+
col5 varbinary(16) NOT NULL,
38+
col6 int(11) NOT NULL,
39+
col7 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
40+
col8 bigint(20) NOT NULL,
41+
col9 timestamp NULL DEFAULT NULL,
42+
col10 int(11) NOT NULL,
43+
col11 bit(1) NOT NULL,
44+
col12 binary(32) NOT NULL,
45+
col13 bit(1) NOT NULL DEFAULT b'0',
46+
col14 varchar(32) CHARACTER SET utf8 DEFAULT NULL,
47+
col15 bigint(10) DEFAULT NULL,
48+
col16 varchar(3) DEFAULT NULL,
49+
col17 bit(1) NOT NULL DEFAULT b'0',
50+
col18 bit(1) NOT NULL DEFAULT b'0',
51+
col19 varbinary(250) DEFAULT NULL,
52+
col20 varchar(20) DEFAULT NULL,
53+
col21 varchar(3) DEFAULT NULL,
54+
col22 int(11) DEFAULT NULL,
55+
56+
PRIMARY KEY (pk1, pk2),
57+
UNIQUE KEY ix_pk2 (pk2),
58+
KEY ix_t1_col2 (col2),
59+
KEY ix_t1_col3 (col3),
60+
KEY ix_t1_pk1_col20 (pk1,col20),
61+
KEY ix_t1_pk1_col6 (pk1,col6)
62+
63+
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
64+
PARTITION BY KEY (pk1);
65+
66+
--echo # Show indexes on t1
67+
SELECT index_name, columns FROM ndbinfo.index_columns
68+
WHERE table_name = 't1' ORDER BY index_name;
69+
70+
ALTER TABLE t1 ALGORITHM = INPLACE, ADD INDEX ix_test (pk1);
71+
72+
--echo # Show that new index 'ix_test' was added to t1
73+
SELECT index_name, columns, index_type FROM ndbinfo.index_columns
74+
WHERE table_name = 't1' AND index_name = 'ix_test' ORDER BY index_name;
75+
76+
DROP TABLE t1;
77+
78+

0 commit comments

Comments
 (0)