Bug #4176 | Incorrect metadata from DATE_ADD() with JOIN and ORDER BY | ||
---|---|---|---|
Submitted: | 17 Jun 2004 0:46 | Modified: | 13 Aug 2004 16:02 |
Reporter: | Matt Solnit | Email Updates: | |
Status: | Won't fix | Impact on me: | |
Category: | MySQL Server: Data Types | Severity: | S2 (Serious) |
Version: | 4.0.20a | OS: | Windows (Windows XP Professional SP1) |
Assigned to: | CPU Architecture: | Any | |
Tags: | affects_connectors |
[17 Jun 2004 0:46]
Matt Solnit
[17 Jun 2004 20:28]
MySQL Verification Team
Thank you very much for writting to us and thank you for such a very nicely elaborated test case. What you have informed us about is not a bug, but a deficiency in our code of which we are aware of very much. This deficiency occurs when a query has to be resolved by usage of temporary tables. Unlike in case of CREATE .. SELECT, internal temporary tables, that are used to resolve a query, are created much faster and with lesser regard to column type precision. That is why some functions which normally return DATETIME (or similar) field type, here return a string. Our current internal temporary tables only are provided with ability to store integer, float and string type. We intend to solve this in 4.1 or 5.0, but not in 4.0.
[1 Jul 2004 18:00]
Paolo Campanella
Resubmitting here as requested (originally submitted a duplicate of this bug report): Typing is broken when GROUPing by on a SUMmed INT column (outputs a floating point number - strange: it's claimed in this ticket that temp tables support integers). try { Statement cstmt = con.createStatement(); cstmt.executeUpdate("create table intbug(x int, y int)"); cstmt.executeUpdate("insert into intbug values(1,1)"); cstmt.executeUpdate("insert into intbug values(1,1)"); ResultSet rs = cstmt.executeQuery("select x from intbug"); if (rs.next()) System.out.println("Class is " + rs.getObject("x").getClass()); cstmt = con.createStatement(); String query = "select sum(x) as x from intbug"; query += " group by y"; rs = cstmt.executeQuery(query); if (rs.next()) System.out.println("Class is " + rs.getObject("x").getClass()); cstmt.executeUpdate("drop table intbug"); } catch (Exception e) { e.printStackTrace(); } Output is: Class is class java.lang.Integer Class is class java.lang.Double Test case of timestamps returned as a String when group and date_add are both used. try { Statement cstmt = con.createStatement(); cstmt.executeUpdate("create table timestampbug(created_time timestamp)"); // NB - table must have at least 2 rows for bug to show up): cstmt.executeUpdate("insert into timestampbug values(now())"); cstmt.executeUpdate("insert into timestampbug values(now())"); ResultSet rs = cstmt.executeQuery("select created_time as x from timestampbug"); if (rs.next()) System.out.println("Class is " + rs.getObject("x").getClass()); cstmt = con.createStatement(); String query = "select date_add(created_time, interval 1 hour) as x from timestampbug"; query += " group by created_time"; rs = cstmt.executeQuery(query); if (rs.next()) System.out.println("Class is " + rs.getObject("x").getClass()); cstmt.executeUpdate("drop table timestampbug"); } catch (Exception e) { e.printStackTrace(); } // Output is: // Class is class java.sql.Timestamp // Class is class java.lang.String
[13 Aug 2004 16:02]
MySQL Verification Team
If a query is resolved by the usage of temporary tables then this is expected behaviour. We have a WorkLog entry to fix this in 4.1. Fix will not come in 4.0.