openid/python-openid

MySQLStore.createTables fails if MySQL’s default character set is utf8mb4

dairiki opened this issue · 1 comments

The issue with with the oid_associations.handle VARCHAR(255) column. It is part of the primary key for the table. MySQL imposes an upper limit on index prefix length in bytes. For the InnoDB backend, the limit is 767 bytes. Since the utf8mb4 character set uses four bytes per character that limit is exceeded. This results in an “OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')” error from MySQL.

The solution, I think, is to explicitly declare the character set to use for oid_associations.handle column (or perhaps for declare the character set for the whole table, as well as the oid_nonces table.) (I haven't looked into this enough to know what character set would be best — is unicode required or would plain ascii work?)

There’s a bit more information here at trac-hacks/authopenid-plugin#11.