[CONJ-841] ResultSetMetaData::getColumnTypeName() returns incorrect type name for LONGTEXT Created: 2020-11-15  Updated: 2020-12-02  Resolved: 2020-11-16

Status: Closed
Project: MariaDB Connector/J
Component/s: metadata
Affects Version/s: None
Fix Version/s: 2.7.1

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None

Attachments: File conj841.diff    

 Description   

https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getColumnTypeName-int- says that getColumnTypeName "Returns: type name used by the database.", but for LONGTEXT type it will return VARCHAR.
Also apparently MEDIUMTEXT and TEXT are affected. For TINYTEXT VARCHAR is probably ok

The solution could be to change the branch in the switch in the method to look like
case VARSTRING:
case VARCHAR:
if (binary)

{ return "VARBINARY"; }

if (len < 0)

{ return "LONGTEXT"; }

else if (len <= 255)

{ return "VARCHAR"; }

else if (len <= 65535)

{ return "TEXT"; }

else if (len <= 16777215)

{ return "MEDIUMTEXT"; }

else

{ return "LONGTEXT"; }

 Comments   
Comment by Lawrin Novitsky [ 2020-11-15 ]

The diff against master. No testcase.

Comment by Diego Dupin [ 2020-11-16 ]

Corrected with https://github.com/mariadb-corporation/mariadb-connector-j/commit/fd276551dc98549d13f600b721596a6bc43c8d60

small difference compare to description:

Comment by Lawrin Novitsky [ 2020-12-02 ]

diego dupin Shouldn't then MariaDbResultSetMetaData.getColumnType changed accordingly? i.e. size in characters to be considered, and Types.VARCHAR returned up to the length 65532, and Types.LONGVARCHAR for longer types?

Generated at Thu Feb 08 03:18:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.