Bug 126852 - MYSQL/MariaDB native connector: Column Type "TEXT" is reported as "VARCHAR"
Summary: MYSQL/MariaDB native connector: Column Type "TEXT" is reported as "VARCHAR"
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.4.0 target:6.3.3
Keywords:
Depends on:
Blocks: MariaDB
  Show dependency treegraph
 
Reported: 2019-08-12 14:51 UTC by Robert Großkopf
Modified: 2019-11-30 08:34 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2019-08-12 14:51:09 UTC
Connect to MariaDB with the native connector, which is included in LO 6.3.0.4.

Start this commands in Tools > SQL

CREATE TABLE strtest (d TEXT(10));
INSERT INTO strtest VALUES('Maria   ');

Refresh the tables by View > Refresh Tables.

Open the table for editing.
Column d is reported as Text[VARCHAR], not as Memo[TEXT].
Memo[TEXT] should be the right data type, but it is impossible to save a table with this type.
Comment 1 Alex Thurgood 2019-08-19 07:39:32 UTC
Confirming with 

Version: 6.2.5.2
Build ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
Threads CPU : 4; OS : Mac OS X 10.14.6; UI Render : par défaut; VCL: osx; 
Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR
Calc: threaded
Comment 2 Alex Thurgood 2019-08-19 07:40:29 UTC
I connected to a mysql server instance instead of MariaDB, but the result is the same.
Comment 3 Commit Notification 2019-09-17 11:25:26 UTC
Tamas Bunth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/47a62ede2403772b8743bfcfa0b6dd4be17fec9c%5E%21

tdf#126852 Bind TEXT mysql type to Clob

It will be available in 6.4.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.
Comment 4 Commit Notification 2019-09-18 10:34:42 UTC
Tamas Bunth committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

https://git.libreoffice.org/core/commit/882cfc31f88cf62b46c29b737c24afd11b6d560c

tdf#126852 Bind TEXT mysql type to Clob

It will be available in 6.3.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.
Comment 5 Julien Nabet 2019-11-29 22:25:21 UTC
Robert: I took a look at https://chartio.com/resources/tutorials/understanding-strorage-sizes-for-mysql-text-data-types/, are you sure it should be "MEMO TEXT" and not "MEMO TINYTEXT" ?

Indeed, with this patch:
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
index 4c7c8465c798..5345bb418908 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
@@ -189,7 +189,10 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType)
         return css::sdbc::DataType::TINYINT;
     if (sType.equalsIgnoreAsciiCase("smallint") || sType.equalsIgnoreAsciiCase("mediumint"))
         return css::sdbc::DataType::SMALLINT;
-    if (sType.equalsIgnoreAsciiCase("longtext"))
+    if (sType.equalsIgnoreAsciiCase("longtext")
+         || sType.equalsIgnoreAsciiCase("tinytext")
+         || sType.equalsIgnoreAsciiCase("mediumtext")
+       )
         return css::sdbc::DataType::LONGVARCHAR;
     if (sType.equalsIgnoreAsciiCase("int"))
         return css::sdbc::DataType::INTEGER;


I retrieved "MEMO TINYTEXT" but I must recognize I'm not "fluent" about Mysql types.
Comment 6 Robert Großkopf 2019-11-30 07:50:07 UTC
(In reply to Julien Nabet from comment #5)
> Robert: I took a look at
> https://chartio.com/resources/tutorials/understanding-strorage-sizes-for-
> mysql-text-data-types/, are you sure it should be "MEMO TEXT" and not "MEMO
> TINYTEXT" ?

The original MySQL/MariaDB datatype is TEXT. If you open the tableeditor in Base you see Memo[TEXT]. "Memo" is only a description in Base, has nothing to do with MySQL/MariaDB. TEXT is the type an it will have a maximum of 65525 characters.
TINYTEXT has a maximum of 255 characters.

This bug has been fixed now. The code for creating a table is misleading. Must be 

CREATE TABLE strtest (d TEXT);

without a defined length. This will work right now with LO 6.3.4.1, fails with LO 6.2.6.2.

I will set this one to RESOLVED FIXED
Comment 7 Julien Nabet 2019-11-30 08:34:06 UTC
Robert: Thank you for your feedback.