Description:
This is documentation issue.
There is a description about TEXT type maximum length in the refman.
> TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
> A TEXT column with a maximum length of 65,535 (216 − 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length prefix that indicates the number of bytes in the value.
https://dev.mysql.com/doc/refman/9.4/en/string-type-syntax.html
By the way, the TEXT type maximum length is limited by 65,535 "bytes", not 65,535 "characters" .
How to repeat:
CREATE DATABASE d1;
use d1
CREATE TABLE t1 (txt TEXT);
mysql> INSERT INTO t1 VALUES(REPEAT(0xF09F8DA3, 65535)); -- 0xF09F8DA3 = '🍣', can't fit in 65535 characters.
ERROR 1406 (22001): Data too long for column 'txt' at row 1
mysql> INSERT INTO t1 VALUES(REPEAT(0xF09F8DA3, 16383)); -- 16383 * 4 = 65532 is less than 65535 bytes. This INSERT succeeds.
Query OK, 1 row affected (0.009 sec)
mysql> INSERT INTO t1 VALUES(REPEAT(0xF09F8DA3, 16384)); -- 16384 * 4 = 65536 is greater than 65535 bytes, This INSERT fails.
ERROR 1406 (22001): Data too long for column 'txt' at row 1
Suggested fix:
Fix TEXT datatype and its variants maximum length are "bytes" instead of "characters".