#
# Bug#20977779 CANNOT IMPORT TABLES CONTAINING PREFIX INDEXES
#
CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32),
PRIMARY KEY (c1, c2, c3))
ENGINE=InnoDB;
ALTER TABLE t1 ADD INDEX ind1(c1(5), c2, c3);
ALTER TABLE t1 ADD INDEX ind2(c3, c1(10), c2);
ALTER TABLE t1 ADD INDEX ind3(c2, c3, c1(20));
INSERT INTO t1 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3');
# Test with 2ndary index having prefix
FLUSH TABLES test.t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE test.t1 DISCARD TABLESPACE;
ALTER TABLE test.t1 IMPORT TABLESPACE;
CHECK TABLE test.t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
SHOW CREATE TABLE test.t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varchar(32) NOT NULL DEFAULT '',
  `c2` varchar(32) NOT NULL DEFAULT '',
  `c3` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`c1`,`c2`,`c3`),
  KEY `ind1` (`c1`(5),`c2`,`c3`),
  KEY `ind2` (`c3`,`c1`(10),`c2`),
  KEY `ind3` (`c2`,`c3`,`c1`(20))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM test.t1;
c1	c2	c3
Test Data -1	Test Data -2	Test Data -3
# Test with PK & 2ndary index with prefix
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1(5), c2(10), c3(20));
FLUSH TABLES test.t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE test.t1 DISCARD TABLESPACE;
ALTER TABLE test.t1 IMPORT TABLESPACE;
CHECK TABLE test.t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
SHOW CREATE TABLE test.t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varchar(32) NOT NULL DEFAULT '',
  `c2` varchar(32) NOT NULL DEFAULT '',
  `c3` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`c1`(5),`c2`(10),`c3`(20)),
  KEY `ind1` (`c1`(5),`c2`,`c3`),
  KEY `ind2` (`c3`,`c1`(10),`c2`),
  KEY `ind3` (`c2`,`c3`,`c1`(20))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT * FROM test.t1;
c1	c2	c3
Test Data -1	Test Data -2	Test Data -3
DROP TABLE t1;
