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

When some numeric data types are set to UNSIGNED, ResultSetMetaData.getColumnTypeName() does not return UNSIGNED

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 3.1.3
    • 3.1.4
    • metadata
    • None
    • MariaDB 10.11

    Description

      When I use DECIMAL(or FLOAT or DOUBLE) UNSIGNED to create a new table and ResultSetMetaData.getColumnTypeName() to get the column type name, I find that the result does not contain `UNSIGNED`.
      For example, in the provided test case, MariaDB Connector J returns `DECIMAL` but Mysql Connector J returns `DECIMAL UNSIGNED`.

      @Test
      public void test() throws SQLException {
          String url = "jdbc:mariadb://localhost:3306?user=user&password=password";
          Connection con = DriverManager.getConnection(url);
       
          execute(con, "DROP DATABASE IF EXISTS test");
          execute(con, "CREATE DATABASE test");
          execute(con, "USE test");
          execute(con, "CREATE TABLE IF NOT EXISTS t0(c0 DECIMAL UNSIGNED)");
          execute(con, "INSERT INTO t0 VALUES(23987)");
       
          Statement stmt = con.createStatement();
          if (stmt.execute("SELECT * FROM t0")) {
              ResultSet rs = stmt.getResultSet();
              ResultSetMetaData rsMetaData = rs.getMetaData();
              int count = rsMetaData.getColumnCount();
              StringBuffer sb = new StringBuffer();
       
              for (int i = 1; i <= count; i++) {
                  sb.append("* " + rsMetaData.getColumnTypeName(i) + " *");
              }
              System.out.println(sb);
          }
      }
       
      public void execute(Connection con, String sql)  {
          try {
              Statement statement = con.createStatement();
              statement.execute(sql);
              statement.close();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
      

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            dwenking chaos
            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.