[Libreoffice-bugs] [Bug 143895] Mysql MEDIUMINT data type but interpreted correctly by Base table definition

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Mon Aug 16 09:47:16 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=143895

Julien Nabet <serval2412 at yahoo.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lionel at mamane.lu,
                   |                            |serval2412 at yahoo.fr

--- Comment #1 from Julien Nabet <serval2412 at yahoo.fr> ---
Lionel: I took a look at it and noticed this:
git grep -in mediumint
source/drivers/mysqlc/mysqlc_databasemetadata.cxx:426:           "LOOP,
LOW_PRIORITY, MATCH, MEDIUMBLOB, MEDIUMINT,"
source/drivers/mysqlc/mysqlc_general.cxx:200:    if
(sType.equalsIgnoreAsciiCase("int") ||
sType.equalsIgnoreAsciiCase("mediumint"))
source/drivers/mysqlc/mysqlc_general.cxx:278:            return isUnsigned ?
(isZerofill ? OUString{ "MEDIUMINT UNSIGNED ZEROFILL" }
source/drivers/mysqlc/mysqlc_general.cxx:279:                                  
         : OUString{ "MEDIUMINT UNSIGNED" })
source/drivers/mysqlc/mysqlc_general.cxx:280:                              :
OUString{ "MEDIUMINT" };
source/drivers/mysqlc/mysqlc_types.cxx:428:    // ----------- MySQL-Type:
MEDIUMINT SDBC-Type: INTEGER ----------
source/drivers/mysqlc/mysqlc_types.cxx:430:        "MEDIUMINT", // Typename
source/drivers/mysqlc/mysqlc_types.cxx:442:        "MEDIUMINT", // local type
name

    // ----------- MySQL-Type: MEDIUMINT SDBC-Type: INTEGER ----------
    {
        "MEDIUMINT", // Typename
        com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
        7, // Precision
        "", // Literal prefix
        "", // Literal suffix
        "[(M)] [UNSIGNED] [ZEROFILL]", // Create params
        com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
        false, // case sensitive
        com::sun::star::sdbc::ColumnSearch::FULL, // searchable
        true, // unsignable
        false, // fixed_prec_scale
        true, // auto_increment
        "MEDIUMINT", // local type name
        0, // minimum scale
        0 // maximum scale
    },
See
https://opengrok.libreoffice.org/xref/core/connectivity/source/drivers/mysqlc/mysqlc_types.cxx?r=1dd9200b#657


    277         case MYSQL_TYPE_INT24:
    278             return isUnsigned ? (isZerofill ? OUString{ "MEDIUMINT
UNSIGNED ZEROFILL" }
    279                                             : OUString{ "MEDIUMINT
UNSIGNED" })
    280                               : OUString{ "MEDIUMINT" };

See
https://opengrok.libreoffice.org/xref/core/connectivity/source/drivers/mysqlc/mysqlc_general.cxx?r=c558ad61#277

So I thought about this patch:
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
index 7ed11fe3ff13..878efdc3be24 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
@@ -193,11 +193,11 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType)
     // TODO other types.
     if (sType.equalsIgnoreAsciiCase("tiny") ||
sType.equalsIgnoreAsciiCase("tinyint"))
         return css::sdbc::DataType::TINYINT;
-    if (sType.equalsIgnoreAsciiCase("smallint") ||
sType.equalsIgnoreAsciiCase("mediumint"))
+    if (sType.equalsIgnoreAsciiCase("smallint"))
         return css::sdbc::DataType::SMALLINT;
     if (sType.equalsIgnoreAsciiCase("longtext"))
         return css::sdbc::DataType::LONGVARCHAR;
-    if (sType.equalsIgnoreAsciiCase("int"))
+    if (sType.equalsIgnoreAsciiCase("int") ||
sType.equalsIgnoreAsciiCase("mediumint"))
         return css::sdbc::DataType::INTEGER;
     if (sType.equalsIgnoreAsciiCase("varchar") ||
sType.equalsIgnoreAsciiCase("set")
         || sType.equalsIgnoreAsciiCase("enum"))

I'm not sure if it's sufficient but I think it may help.

Also Mysql has 5 int and derived types:
https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
TINYINT
SMALLINT
MEDIUMINT
INT
BIGINT

and LO has only 4:
https://opengrok.libreoffice.org/xref/core/offapi/com/sun/star/sdbc/DataType.idl?r=2b383d19
TINYINT
SMALLINT
INT
BIGINT

Not sure if the patch may have wrong side effect.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210816/2b2b08bf/attachment.htm>


More information about the Libreoffice-bugs mailing list