Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-850

MariaDbResultSetMetaData#getPrecision(int) returns wrong length for character data

    XMLWordPrintable

    Details

      Description

      Given the following table definition:

      CREATE TABLE mytable(
        col1 CHAR(100)
      ) DEFAULT CHARSET=utf8mb4;
      

      When executing a query and calling resultSet.getMetaData().getPrecision(1) the return value is 400, the length in bytes.

      java.sql.ResultSetMetaData#getPrecision​(int) says that

      Get the designated column's specified column size. For numeric data, this is the maximum precision. For character data, this is the length in characters. For datetime datatypes, this is the length in characters of the String representation (assuming the maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype, this is the length in bytes. 0 is returned for data types where the column size is not applicable.

      The expected result for resultSet.getMetaData().getPrecision(1) in this case is 100.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            shorke Staffan Hörke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: