frengor / UltimateAdvancementAPI

A powerful API to create custom advancements for your Minecraft server.
https://modrinth.com/plugin/ultimateadvancementapi
GNU General Public License v3.0
116 stars 13 forks source link

Update MySQL.java #89

Open 3328429240 opened 1 month ago

3328429240 commented 1 month ago

Fix MySQL creation failure issue When the plugin creates a database in utf8mb4 format, it will report the error 'Specified key was too long' because the table length is greater than the maximum limit; The maximum key length is 1000 bytes and cannot be created. But after modifying utf8mb4 to utf8, the occupation becomes smaller and the above problems will not occur

CrazyDev05 commented 1 month ago

@frengor do we even need utf8 at all? cause from what I saw the tables should only contain latin1 characters (a-z0-9_-/:)

If we do i suppose changing the row format to either compressed or dynamic would fix it without sacrificing lesser used characters

frengor commented 1 month ago

My biggest fear is that changing the default charset may break something. Also, utf8 in MySQL in reality is utf8 limited to 3 bytes max, whereas utf8mb4 is the "real" uft8 with max 4 bytes, so I wouldn't change it.

@CrazyDev05 I used utf8 because Java strings are unicode, but yes you're right, we could probably even use ASCII. Although, is it really worth it? (utf8 is already optimized for ASCII strings)

Also, does changing the row format to compressed or dynamic reduce the key length?

CrazyDev05 commented 1 month ago

@frengor from what I read changing the row format to dynamic or compressed doesn't change the actual key length but it increases the max length 1kb to 3kb

this is also described on the link i already sent here the specific section https://dev.mysql.com/doc/refman/8.4/en/innodb-row-format.html#innodb-row-format-dynamic

3328429240 commented 4 days ago

在我的测试中,使用MySQL5.7如果不使用此修改将会报错:Specified key was too long; max key length is 1000 bytes In my test, using MySQL 5.7 without this modification will get an error: Specified key was too long; max key length is 1000 bytes