3 ms·
They should have made "utf8" have UTF-8 semantics by default as soon as the defect was discovered, not twenty plus years later.
by butlerm 5y ago
They should have made "utf8" have UTF-8 semantics by default as soon as the defect was discovered, not twenty plus years later.
- ars 5y agoThey couldn't. The storage size is different internally. The article covers this in the section in migrating from utf8 to utf8mb4. Do you actually use MySQL or are you just complaining from a theoretical POV?
- butlerm 5y agoPretty sure the name "utf8" isn't metaphysically wired to a defective physical representation. All they have to do is wait until the next minor release, add a compatibility name, make the generic name refer to a non-defective representation, and update the documentation and release notes accordingly. If they were really conservative, they could wait until the next major release to repoint the name like that. Haven't there been four major releases since 2003?
- evanelias 5y agoThis would be problematic for existing applications. Even if you leave existing binary data as-is (in existing tables utf8 becomes utf8mb3), changing the meaning of "utf8" in only new tables is still very problematic. Think about logical dumps, e.g. CREATE TABLE statements which use the "utf8" alias. For example, any self-host application which runs a .sql file in its install process. Or spinning up a dev environment for a new hire. Basically, anything that contains a CREATE TABLE with the utf8 alias now has a landmine: In older versions of MySQL, InnoDB indexes were limited to 767 bytes. Meanwhile, VARCHAR(N) can store N characters. So with utf8mb3, that's a max of 3N bytes worst-case; but with utf8mb4 ("proper" utf8), it's now 4N. This meant that VARCHAR(255) CHARACTER SET utf8mb4 could not be indexed (in its entirety) in these older versions; the CREATE TABLE would fail if you try. When you have a massive installed base of users, and those users have lots of dumps / install scripts containing "VARCHAR(255) CHARACTER SET utf8", you simply cannot change the meaning of "utf8" in a minor release. I fully agree that MySQL could have made this transition faster/earlier than they did, but I disagree that it could be done trivially or terribly quickly.
- butlerm 5y agoAdvertising the ability to store UTF-8 characters when you can do no such thing is a serious problem. Obviously you have to do whatever it takes to fix it, including fixing a deficient indexing implementation if necessary. I believe the limitation you mention was fixed in MySQL 5.7, which would have been a reasonable opportunity to make "utf8" live up to its name.
- evanelias 5y agoKeep in mind that prior to 2010, MySQL and InnoDB were owned by different companies. Unilaterally deciding to increase the InnoDB index size limitation to permit utf8mb4 varchar(255) was not physically possible for the MySQL team prior to that point. Anyway, I fully agree that the utf8 alias swap should have been done in MySQL 5.7, or perhaps even 5.6. I'm just disagreeing with your assertions that this would have been a trivial change. Nor do I think it should have been a "stop the world" high-priority change prior to emoji existing in unicode (~late 2010). Non-BMP characters were very rare before that point. Hard to justify a business need for a complex migration just to store archaic hieroglyphs. For another point of comparison, MS SQL Server only added support for non-BMP characters in 2012, and only added support for utf8 encoding in 2019!
- ruiquelhas 5y agoIt kind-of is "wired" to a "physical" representation, but in a different sense. https://blog.koehntopp.info/2022/01/12/utf8mb4.html#so-what-would-happen-if-utf8-suddently-meant-utf8mb4 https://blog.koehntopp.info/2022/01/12/utf8mb4.html#so-what-...