Connector/J does not return sub-second precision of fields when retrieving database metadata

Bug #740973 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Won't Fix
Low
Sergei Golubchik

Bug Description

The metadata returned by this.conn.getMetaData() appears to have hard-coded values for COLUMN_SIZE when it comes to temporal fields. For TIMESTAMP for example, 19 is always returned regardless of how many precision digits there are.

This happens regardless of whether the "useInformationSchema" property is set on the connection.

junit test case:

        public void testTableMetadata() throws SQLException {

                        createTable("ms_metadata", "(ts0 TIMESTAMP(0), ts3 TIMESTAMP(3))");
                        DatabaseMetaData metaData = this.conn.getMetaData();
                        this.rs = metaData.getColumns(null, null, "ms_metadata", null);

                        this.rs.next();
                        assertEquals(java.sql.Types.TIMESTAMP, this.rs.getInt("DATA_TYPE"));
                        assertEquals("TIMESTAMP", this.rs.getString("TYPE_NAME"));
                        assertEquals(19, this.rs.getInt("COLUMN_SIZE"));

                        this.rs.next();
                        assertEquals(java.sql.Types.TIMESTAMP, this.rs.getInt("DATA_TYPE"));
                        assertEquals("TIMESTAMP", this.rs.getString("TYPE_NAME"));
                        assertEquals(23, this.rs.getInt("COLUMN_SIZE"));
}

The last assert will fail. Same applies to DATETIME and TIME types.

Related branches

Changed in maria:
milestone: none → 5.3
assignee: nobody → Sergei (sergii)
Changed in maria:
importance: Undecided → Medium
importance: Medium → Low
status: New → Won't Fix
Revision history for this message
Sergei Golubchik (sergii) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.