Open a Base file with direct connection to MariaDB. Create a table. Try to create a varchar field with more than 255. Couldn't be created. Base would show ENUM instead of VARCHAR, if VARCHAR(1000) (or more) has been created with PHPMyAdmin. Note from https://mariadb.com/kb/en/varchar/: A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,532. The effective maximum length of a VARCHAR is subject to the maximum row size and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters.
Have had a look where the limit come from: In MySQL 4 there had been a limit of 255 characters. Since MySQL 5.0 (and since the start of MariaDB with 5.1) the limit has been updated to 65535 characters. This happen in October 2005. We should update the limit for better handling.
I've submitted a patch here: https://gerrit.libreoffice.org/c/core/+/183400 (I put 65535)
On Debian testing, I gave a try on phpmyadmin (Version: 4:5.2.2-really5.2.2+20250121+dfsg-1) with on MariaDB 11.8.1 and when trying to create a VARCHAR of 65535 characters, phpmyadmin displays an error proposing to use a BLOB since max length is 16383 (ie 65535 / 4 which must correspond to the max bytes which can be used by utf-8). Has someone got Mysql (and not Mariadb) to compare?
Just rethinking, I wonder if "precision" field means the number of bytes here and so 65535 would be ok or if it means the number of characters and in this case, it depends on the encoding. Doing tests again with phpmyadmin, and when choosing one type of ucs2, it indicates this time max at 32766 Reading https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html: " The PRECISION column represents the specified column size for the given column. For numeric data, this is the maximum precision. For character data, this is the length in characters..." So either we should find a way to retrieve the default encoding of the database if it's possible (on my desktop on Mariadb, it seems to be utf8mb4_general_ci, so 4 bytes per character) or to try to be safe and use 16383.
(In reply to Julien Nabet from comment #4) You could set it to 21844, as described on the homepage of MariaDB. Have a look at the bug description. Its the same as discussed for Firebird. There could be set 32000, but we devided it by 4 to 8000 for utf-8 On description of MariaDB there is posted 3 bytes for a utf8 - so devided by 3 bytes… If we say 4 bytes as maximum for a character it might also be 16383. But all this solutions are much better than 255! Note there are fields for more text content. My problem appears because I have copied tables from internal Firebird to MariaDB and that won't work directly at this moment.
(In reply to Robert Großkopf from comment #5) > (In reply to Julien Nabet from comment #4) ... > If we say 4 bytes as maximum for a character it might also be 16383. > > But all this solutions are much better than 255! Note there are fields for > more text content. My problem appears because I have copied tables from > internal Firebird to MariaDB and that won't work directly at this moment. Ok I put back 16383 to keep it safe and put some comments and a TODO in the code.
Julien Nabet committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/4b7ddc149990f21a98deb8ba0cc6a97e62b201d7 tdf#165928: MySQL/MariaDB direct connection: VARCHAR can be > 255 characters It will be available in 25.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco cherry-picked the patch for 25.2 here: https://gerrit.libreoffice.org/c/core/+/183439 => let's put this one to FIXED. Again, as put in the comment of the patch, ideally we should detect encoding to adjust the precision.
Julien Nabet committed a patch related to this issue. It has been pushed to "libreoffice-25-2": https://git.libreoffice.org/core/commit/1ef0b26c70e2f5320829066350e8102e4d4f2a0e tdf#165928: MySQL/MariaDB direct connection: VARCHAR can be > 255 characters It will be available in 25.2.3. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.