connectivity/source/drivers/mysqlc/mysqlc_types.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 4b7ddc149990f21a98deb8ba0cc6a97e62b201d7
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Thu Mar 27 14:58:12 2025 +0100
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Fri Mar 28 09:59:12 2025 +0100

    tdf#165928: MySQL/MariaDB direct connection: VARCHAR can be > 255 characters
    
    Change-Id: If3d5163416508d0f9e26978e2d853542f7a01961
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183400
    Tested-by: Julien Nabet <serval2...@yahoo.fr>
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/connectivity/source/drivers/mysqlc/mysqlc_types.cxx 
b/connectivity/source/drivers/mysqlc/mysqlc_types.cxx
index 85d3df43dfe0..b29360c59077 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_types.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_types.cxx
@@ -543,7 +543,15 @@ TypeInfoDef const mysqlc_types[] = {
     {
         "VARCHAR", // Typename
         css::sdbc::DataType::VARCHAR, // sdbc-type
-        255, // Precision
+        // tdf#165928: a VARCHAR should be more than 255 characters
+        // Mysql/MariaDB accepts 65535 bytes
+        // see 
https://mariadb.com/docs/skysql-dbaas/ref/xpand/data-types/VARCHAR/
+        // but precision corresponds to the number of characters and not the 
number of bytes:
+        // see 
https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html
+        // Knowing that Unicode can use until 4 bytes, it means a varchar 
field can contain:
+        // 65535 / 4, so 16383 characters
+        // TODO if there's a way to retrieve the encoding, we could be more 
precise
+        16383, // Precision
         "'", // Literal prefix
         "'", // Literal suffix
         "(M)", // Create params

Reply via email to