[MDEV-2207] LP:740973 - Connector/J does not return sub-second precision of fields when retrieving database metadata Created: 2011-03-23  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Trivial
Reporter: Philip Stoev (Inactive) Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug740973.xml    

 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.



 Comments   
Comment by Sergei Golubchik [ 2011-03-23 ]

Re: Connector/J does not return sub-second precision of fields when retrieving database metadata
These values are hard-coded in the Connector/J, the sever cannot influence them.

http://bazaar.launchpad.net/~mark-mysql/connectorj/5.1/view/1053/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java#L1190

Comment by Rasmus Johansson (Inactive) [ 2011-03-23 ]

Launchpad bug id: 740973

Generated at Thu Feb 08 06:40:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.