[CONJ-1067] When some numeric data types are set to UNSIGNED, ResultSetMetaData.getColumnTypeName() does not return UNSIGNED Created: 2023-04-03  Updated: 2023-04-04  Resolved: 2023-04-03

Status: Closed
Project: MariaDB Connector/J
Component/s: metadata
Affects Version/s: 3.1.3
Fix Version/s: 3.1.4

Type: Bug Priority: Minor
Reporter: Wenqian Deng Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

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();
    }
}



 Comments   
Comment by Diego Dupin [ 2023-04-03 ]

confirmed : ResultSetMetaData.getColumnTypeName() does not return UNSIGNED for DECIMAL, DOUBLE and FLOAT columns.

Comment by Diego Dupin [ 2023-04-03 ]

corrected with https://github.com/mariadb-corporation/mariadb-connector-j/commit/7a2e898e8a5c12b9178377cc246c4a6cb0fb52fa

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