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

Wrong text type names in result set metadata

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.0.5
    • metadata
    • None
    • driver 3.0.4

    Description

      How to reproduce:

      connection.createStatement().execute("drop table if exists text_types_text");
                  connection.createStatement().execute(
                          "create table text_types_text (varchar100           varchar(100),\n" +
                                  "  varchar255           varchar(255),\n" +
                                  "  text                 text,\n" +
                                  "  `tinytext`           tinytext,\n" +
                                  "  `mediumtext`         mediumtext,\n" +
                                  "  `longtext`           longtext)"
                  );
                  try (ResultSet resultSet = connection.createStatement().executeQuery("select * from text_types_text")) {
                      ResultSetMetaData metaData = resultSet.getMetaData();
                      System.out.println("name | type | type name | precision");
                      for (int i = 0; i < metaData.getColumnCount(); i++) {
                          String columnName = metaData.getColumnName(i + 1);
                          int columnType = metaData.getColumnType(i + 1);
                          String columnTypeName = metaData.getColumnTypeName(i + 1);
                          int precision = metaData.getPrecision(i + 1);
                          System.out.println(columnName + " | " + columnType + " | " + columnTypeName + " | " + precision);
                      }
                  }
                  connection.createStatement().execute("drop table text_types_text");
      

      Expected:

      name       | type | type name  | precision
      varchar100 | 12   | VARCHAR    | 100
      varchar255 | 12   | VARCHAR    | 255
      text       | 12   | TEXT       | 65535
      tinytext   | 12   | TINYTEXT   | 255
      mediumtext | 12   | MEDIUMTEXT | 16777215
      longtext   | 12   | LONGTEXT   | 4294967295
      

      Actual:

      name       | type | type name  | precision
      varchar100 | 12   | VARCHAR    | 100
      varchar255 | 12   | VARCHAR    | 255
      text       | 12   | MEDIUMTEXT | 262140
      tinytext   | 12   | VARCHAR    | 1020
      mediumtext | 12   | LONGTEXT   | 67108860
      longtext   | 12   | LONGTEXT   | -1
      

      As you can see type names are pretty random.
      And they change from driver version to driver version!
      Also precision of all types except VARCHAR is now multiplied by 4 in new version of driver. Why?

      I'm a developer from JetBrains, I'm working on MariaDB support in JetBrains IDEs (see https://www.jetbrains.com/datagrip/). This type names issue makes it really complicated for me to support MariaDB properly

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            lucinda Liudmila Kornilova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.