8.4.4: Exception executing CREATE TABLE VARCHAR(256) Specified key too long

Permalink
Hello,

Some websites, depending on database settings, throw exceptions when a 256 long key is used:
An exception occurred while executing 'CREATE TABLE ... VARCHAR(256) NOT NULL... DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB': SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Does it only happen with DBs set up without unicode? Is there a solution to fix the exception without reducing the key length, e.g. changing from ANSI to Unicode or something? Or what should be the max length of the key? Is this concrete5 related or DB related?

Thank you.

linuxoid
 
mnakalay replied on at Permalink Reply
mnakalay
I believe the max for VARCHAR is 255 characters and you have 256
linuxoid replied on at Permalink Reply
linuxoid
Looks like this is DB server related. Most servers are configured with the full utf8 charset 'utf8mb4' using 4 bytes per character, some are with just utf8 'utf8' using 3 bytes and some are latin1 using just 1 byte. This creates exceptions during installation with DB table setup using string keys.

How can I know the DB configuration with Doctrine setup? Or should I limit the max char length to the worst case of 'utf8mb4', i.e. 191?

What does concrete5's Doctrine use by default: utf8 or utf8mb4?

Is that server or concrete5 related?