--source include/have_innodb.inc

CREATE TABLE t1 (a CHAR(8), id INT, PRIMARY KEY (a,id)) COLLATE utf8_nopad_bin
ENGINE=InnoDB ROW_FORMAT=REDUNDANT;

INSERT INTO t1 VALUES ('',1);
ALTER TABLE t1 ROW_FORMAT=DYNAMIC;
INSERT INTO t1 VALUES ('',2);
ALTER TABLE t1 ROW_FORMAT=REDUNDANT;
DROP TABLE t1;


--echo #
--echo # MDEV-26743 InnoDB: CHAR+nopad does not work well
--echo #

--echo #
--echo # Basic Latin letter vs equal accented letter
--echo #

SET NAMES utf8mb3;
CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES ('a'),('ä');
DROP TABLE t1;

--echo #
--echo # Two letters vs equal (but space padded) expansion
--echo #

CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES ('ss'),('ß');
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
SELECT HEX(a) FROM t1;
SET sql_mode=DEFAULT;
DROP TABLE t1;

--echo #
--echo # Basic Latin letter (but followed by an ignorable character) vs equal accented letter
--echo #

SET NAMES utf8mb3;
CREATE TABLE t1 (a CHAR(3), PRIMARY KEY(a)) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES (CONCAT('a',_utf8mb3 0x01)),('ä');
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
SELECT HEX(a) FROM t1 ORDER BY HEX(a);
SET sql_mode=DEFAULT;
DROP TABLE t1;

SET NAMES utf8mb3;
CREATE TABLE t1 (a CHAR(2), PRIMARY KEY(a)) COLLATE utf8_unicode_nopad_ci ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES (CONCAT('a',_utf8mb3 0x01)),('ä');
SET sql_mode=PAD_CHAR_TO_FULL_LENGTH;
SELECT HEX(a) FROM t1 ORDER BY HEX(a);
SET sql_mode=DEFAULT;
DROP TABLE t1;
