Commit 6882f9fa authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4024 Found Index PRIMARY whose column info does not match that of MySQL

For compatibility purposes let InnoDB use DATA_INT for MYSQL_TYPE_ENUM and MYSQL_TYPE_SET.
Silence the warning for these types and let the index translation table to be built anyway.

Test case by Jeremy Cole.
parent bd3dc542
# Create a table with a 1-byte ENUM, 1-byte SET, and TINYINT UNSIGNED.
CREATE TABLE t1
(
t1_enum ENUM("a", "b", "c"),
t1_set SET("a", "b", "c"),
t1_tinyint_s TINYINT,
t1_tinyint_u TINYINT UNSIGNED
) ENGINE=InnoDB;
# All t1 fields' mtypes should be 6 (DATA_INT).
SELECT
name,
mtype,
(prtype & 512) = 512 AS is_unsigned
FROM information_schema.INNODB_SYS_COLUMNS
WHERE name LIKE "t1\_%"
ORDER BY name;
name mtype is_unsigned
t1_enum 6 1
t1_set 6 1
t1_tinyint_s 6 0
t1_tinyint_u 6 1
# Cleanup
DROP TABLE t1;
--source include/have_innodb.inc
--echo # Create a table with a 1-byte ENUM, 1-byte SET, and TINYINT UNSIGNED.
CREATE TABLE t1
(
t1_enum ENUM("a", "b", "c"),
t1_set SET("a", "b", "c"),
t1_tinyint_s TINYINT,
t1_tinyint_u TINYINT UNSIGNED
) ENGINE=InnoDB;
--echo # All t1 fields' mtypes should be 6 (DATA_INT).
SELECT
name,
mtype,
(prtype & 512) = 512 AS is_unsigned
FROM information_schema.INNODB_SYS_COLUMNS
WHERE name LIKE "t1\_%"
ORDER BY name;
--echo # Cleanup
DROP TABLE t1;
......@@ -4585,6 +4585,12 @@ innobase_match_index_columns(
}
}
// MariaDB-5.5 compatibility
if ((key_part->field->real_type() == MYSQL_TYPE_ENUM ||
key_part->field->real_type() == MYSQL_TYPE_SET) &&
mtype == DATA_FIXBINARY)
col_type= DATA_FIXBINARY;
if (col_type != mtype) {
/* Column Type mismatches */
DBUG_RETURN(FALSE);
......@@ -5757,7 +5763,10 @@ get_innobase_type_from_mysql_type(
case HA_KEYTYPE_DOUBLE:
return(DATA_DOUBLE);
case HA_KEYTYPE_BINARY:
if (field->type() == MYSQL_TYPE_TINY)
if (field->type() == MYSQL_TYPE_TINY ||
field->real_type() == MYSQL_TYPE_ENUM ||
field->real_type() == MYSQL_TYPE_SET
)
{ // compatibility workaround
*unsigned_flag= DATA_UNSIGNED;
return DATA_INT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment