[CONJ-717] JDBC Conversion Function support Created: 2019-07-10  Updated: 2019-08-02  Resolved: 2019-07-30

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.4.2
Fix Version/s: 2.4.3

Type: Bug Priority: Major
Reporter: Khalid Shakir Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

The JDBC escape syntax scalar conversion functions are technically optional but there are inconsistencies and only partial support in the MariaDB Connector/J:

  • The no args override org.mariadb.jdbc.MariaDbDatabaseMetaData#supportsConvert() always returns true
  • However the overloaded and also overridden org.mariadb.jdbc.MariaDbDatabaseMetaData#supportsConvert(int, int) returns false for all from/to SQL types
  • Appendix C.5 of the JDBC 4.2 specification lists several (optional) Conversion Function SQL types
  • org.mariadb.jdbc.internal.util.Utils#replaceFunctionParameter actually does handle implement some of the JDBC convert implementations, primarily by stripping "SQL_" from the SQL type parameter, and then only supporting the server side version of convert()

Ideally more of the JDBC Conversion Function SQL types could be supported, such as {fn convert(SomeColumn, VARCHAR)} being replaced client side with something like CONCAT(SomeColumn).

The above was discovered trying to use Lightbend's Slick MySQLProfile with the MariaDB Connector/J. The Slick method .asColumnOf[String] is what invokes the JDBC escape syntax conversion function with a SQL type of VARCHAR.



 Comments   
Comment by Diego Dupin [ 2019-07-30 ]

Correction done in next release 2.4.3 with this commit

Implementation is simpler: Just a conversion from some SQL_XXX to corresponding supported MariaDB type.
example: "SELECT

{fn convert(2147483648, SQL_BIGINT)}

" => "SELECT convert(2147483648, INTEGER)"
The server will automatically send BIGINT type if the value is bigger than INTEGER max value.

Comment by Diego Dupin [ 2019-07-31 ]

erratum. MariaDB server has this kind of capabilities since 5.5, but not MySQL. so real client conversion is needed

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