List:Commits« Previous MessageNext Message »
From:mmatthews Date:February 28 2008 6:34am
Subject:Connector/J commit: r6751 - in branches/branch_5_1: . src/com/mysql/jdbc src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_1/CHANGES
   branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java
   branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Fixed Bug#34913 - ResultSet.getTimestamp() returns incorrect
      values for month/day of TIMESTAMPs when using server-side
      prepared statements (not enabled by default).

Modified: branches/branch_5_1/CHANGES
===================================================================
--- branches/branch_5_1/CHANGES	2008-02-28 04:05:18 UTC (rev 6750)
+++ branches/branch_5_1/CHANGES	2008-02-28 05:34:19 UTC (rev 6751)
@@ -148,8 +148,8 @@
       
     - Fixed BUG#33162 - NullPointerException instead of SQLException 
       thrown for ResultSet.getTimestamp() when not positioned on a
-      row. 
-    
+      row.
+
     - The ConnectionLifecycleInterceptor interface now has callback methods for
       transaction initiation (transactionBegun()), and completion 
       (transactionCompleted()), as reported by the *server* (i.e. 
@@ -158,7 +158,11 @@
       which causes a transaction to start on the server will cause
       transactionBegun() to be called *after* the statement has been processed
       on the server).
-      
+
+    - Fixed Bug#34913 - ResultSet.getTimestamp() returns incorrect
+      values for month/day of TIMESTAMPs when using server-side
+      prepared statements (not enabled by default).
+    
 10-09-07 - Version 5.1.5
 
     - Released instead of 5.1.4 to pickup patch for BUG#31053

Modified: branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java
===================================================================
--- branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java	2008-02-28 04:05:18 UTC (rev
6750)
+++ branches/branch_5_1/src/com/mysql/jdbc/ResultSetRow.java	2008-02-28 05:34:19 UTC (rev
6751)
@@ -667,8 +667,8 @@
 
 		if (length != 0) {
 			year = (bits[offset + 0] & 0xff) | ((bits[offset + 1] & 0xff) << 8);
-			month = bits[2];
-			day = bits[3];
+			month = bits[offset + 2];
+			day = bits[offset + 3];
 
 			if (length > 4) {
 				hour = bits[offset + 4];

Modified: branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java	2008-02-28
04:05:18 UTC (rev 6750)
+++ branches/branch_5_1/src/testsuite/regression/ResultSetRegressionTest.java	2008-02-28
05:34:19 UTC (rev 6751)
@@ -4652,5 +4652,23 @@
 		while (this.rs.relative(1)) {
 			this.rs.getTimestamp(1);
 		}
-	}	
+	}
+	
+	/**
+	 * @deprecated because we use deprecated methods
+	 */
+	public void testBug34913() throws Exception {
+		try {
+			Timestamp ts = new Timestamp(System.currentTimeMillis());
+			
+			this.pstmt = ((com.mysql.jdbc.Connection) this.conn).serverPrepareStatement("SELECT
'abcdefghij', ?");
+			this.pstmt.setTimestamp(1, ts);
+			this.rs = this.pstmt.executeQuery();
+			this.rs.next();
+			assertTrue(this.rs.getTimestamp(2).getMonth() != 5);
+			assertTrue(this.rs.getTimestamp(2).getDate() != 21);
+		} finally {
+			closeMemberJDBCResources();
+		}
+	}
 }

Thread
Connector/J commit: r6751 - in branches/branch_5_1: . src/com/mysql/jdbc src/testsuite/regressionmmatthews28 Feb 2008