Opened 4 years ago

Last modified 4 years ago

#31144 closed Bug

MySQL unique constraints incorrectly limited to 255 char when it should be 1000 — at Initial Version

Reported by: Steven Mapes Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: MySQL, MariaDB, Indexes, Unique Keys
Cc: Claude Paroz, Adam Johnson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is a bug within db.backends.mysql.validation.check_field_type where the maximum unique constraints is still being limited to 255 characters even though MySQL supports unique keys of up to 1000 characters by default and InnoDB supports 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format and 767 bytes for InnoDB tables that use the REDUNDANT or COMPACT row format.

Reference -
InnoDB - https://dev.mysql.com/doc/refman/8.0/en/innodb-limits.html

MyISAM - https://dev.mysql.com/doc/refman/8.0/en/myisam-storage-engine.html

Example

CREATE DATABASE testCHARACTER SET utf8 COLLATE utf8_general_ci;
USE test;

CREATE TABLE `example_innodb` (
  `example1` VARCHAR(1024) DEFAULT NULL,
  `example2` VARCHAR(1024) DEFAULT NULL,
  UNIQUE KEY `UQ_example1` (`example1`),
  UNIQUE KEY `UQ_example2` (`example2`)
) ENGINE=INNODB DEFAULT CHARSET=utf8

DROP TABLE example_innodb;
DROP DATABASE test;

It just needs the max length to be increased on line 38 of db.backends.mysql.validation

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top